add deployMode and use it in test for inline scripts
diff --git a/lib/build/mirrors_remover.dart b/lib/build/mirrors_remover.dart
index 4cb8862..069a2a2 100644
--- a/lib/build/mirrors_remover.dart
+++ b/lib/build/mirrors_remover.dart
@@ -17,7 +17,7 @@
@override
Future apply(Transform transform) async {
String source = await transform.primaryInput.readAsString();
- source = source.replaceFirst(
+ source = source.replaceAll(
'mirror_initializer.dart', 'static_initializer.dart');
transform.addOutput(
new Asset.fromString(transform.primaryInput.id, source));
diff --git a/lib/src/init.dart b/lib/src/init.dart
index 512134d..47d39ea 100644
--- a/lib/src/init.dart
+++ b/lib/src/init.dart
@@ -7,6 +7,7 @@
import 'package:initialize/initialize.dart' show InitializerFilter;
import 'package:web_components/web_components.dart';
import 'mirror_initializer.dart' as init;
+export 'mirror_initializer.dart' show deployMode;
/// Performs html import aware initialization by crawling all imported documents
/// and initializing any script tags which appear in them.
diff --git a/lib/src/mirror_initializer.dart b/lib/src/mirror_initializer.dart
index 652031f..5f874f8 100644
--- a/lib/src/mirror_initializer.dart
+++ b/lib/src/mirror_initializer.dart
@@ -15,6 +15,8 @@
import 'dart:html';
import 'package:initialize/initialize.dart' as init;
+const bool deployMode = false;
+
Future run({List<Type> typeFilter, init.InitializerFilter customFilter}) async {
var libraryUris = _discoverLibrariesToLoad(document, window.location.href)
.map(Uri.parse);
diff --git a/lib/src/static_initializer.dart b/lib/src/static_initializer.dart
index dd23f8a..ca4b37b 100644
--- a/lib/src/static_initializer.dart
+++ b/lib/src/static_initializer.dart
@@ -9,5 +9,7 @@
import 'dart:async';
import 'package:initialize/initialize.dart' as init;
+const bool deployMode = true;
+
Future run({List<Type> typeFilter, init.InitializerFilter customFilter}) =>
init.run(typeFilter: typeFilter, customFilter: customFilter);
diff --git a/test/build/mirrors_remover_test.dart b/test/build/mirrors_remover_test.dart
index ab9fa08..0d3f2e4 100644
--- a/test/build/mirrors_remover_test.dart
+++ b/test/build/mirrors_remover_test.dart
@@ -18,7 +18,8 @@
'a|lib/src/init.dart': '''
libary web_components.init;
- import 'src/mirror_initializer.dart';
+ import 'src/mirror_initializer.dart' as init;
+ export 'src/mirror_initializer.dart' show deployMode;
foo() {}
''',
@@ -26,7 +27,8 @@
'a|lib/src/init.dart': '''
libary web_components.init;
- import 'src/static_initializer.dart';
+ import 'src/static_initializer.dart' as init;
+ export 'src/static_initializer.dart' show deployMode;
foo() {}
''',
diff --git a/test/init_web_components_test.dart b/test/init_web_components_test.dart
index 15279e5..9b66acf 100644
--- a/test/init_web_components_test.dart
+++ b/test/init_web_components_test.dart
@@ -20,8 +20,10 @@
var expectedInitializers = [
const LibraryIdentifier(
#web_components.test.deps.b, null, 'deps/b.dart'),
- const LibraryIdentifier(
- #web_components.test.deps.c, null, 'deps/c.html'),
+ // This one changes based on deploy mode because its an inline script.
+ const LibraryIdentifier(#web_components.test.deps.c, null, deployMode
+ ? 'init_web_components_test.html.0.dart'
+ : 'deps/c.html'),
const LibraryIdentifier(
#web_components.test.deps.a, null, 'deps/a.dart'),
const LibraryIdentifier(#web_components.test.init_web_components_test,