This repository has been archived by the owner on Feb 22, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove mirrors imports in transformed code.
- Loading branch information
1 parent
df28c17
commit cb2da41
Showing
20 changed files
with
159 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library js.static; | ||
|
||
// This is the public interface of js.dart | ||
// The exports must match those in static.dart | ||
export 'package:js/src/js_impl.dart'; | ||
export 'dart:js' show JsObject; | ||
export 'package:js/src/metadata.dart'; | ||
|
||
void initializeJavaScript() { | ||
throw new StateError("Non-transformed initialization is being called. " | ||
"You are using js.dart in deployed mode, but you probably haven't " | ||
"configured the initializer transformer, or you are calling " | ||
"initializeJavaScript() somewhere other than main(). " | ||
"Try adding '- js/initializer' to your applications transformers."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
library js.transformer.remove_mirrors_transformer; | ||
|
||
import 'package:barback/barback.dart' show Asset, AssetId, BarbackSettings, | ||
Transform, Transformer; | ||
import 'package:logging/logging.dart' show Logger; | ||
|
||
final _logger = new Logger('js.transformer.remove_mirrors_transformer'); | ||
|
||
class RemoveMirrorsTransformer extends Transformer { | ||
|
||
RemoveMirrorsTransformer(); | ||
|
||
RemoveMirrorsTransformer.asPlugin(BarbackSettings settings); | ||
|
||
@override | ||
isPrimary(AssetId id) => id.package == 'js' && id.path == 'lib/js.dart'; | ||
|
||
@override | ||
apply(Transform transform) { | ||
var input = transform.primaryInput; | ||
return input.readAsString().then((source) { | ||
var newSource = source.replaceAll( | ||
"export 'package:js/src/mirrors.dart';", | ||
"export 'package:js/src/static.dart';"); | ||
transform.addOutput(new Asset.fromString(input.id, newSource)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
library js.remove_mirrors_transformer_test; | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:barback/barback.dart'; | ||
import 'package:js/src/transformer/remove_mirrors_transformer.dart'; | ||
import 'package:unittest/unittest.dart'; | ||
|
||
import 'utils.dart'; | ||
|
||
main() { | ||
|
||
group("$RemoveMirrorsTransformer", () { | ||
test('should replace the mirrors.dart import', () { | ||
var transformer = new RemoveMirrorsTransformer(); | ||
var barback = new Barback(new TestPackageProvider()); | ||
barback.updateTransformers('js', [[transformer]]); | ||
var id = new AssetId('js', 'lib/js.dart'); | ||
barback.updateSources([id]); | ||
return barback.getAssetById(id) | ||
.then((asset) => asset.readAsString()) | ||
.then((source) { | ||
expect(source, | ||
contains("export 'package:js/src/static.dart';")); | ||
expect(source, | ||
isNot(contains( | ||
"export 'package:js/src/mirrors.dart';"))); | ||
}); | ||
}); | ||
}); | ||
|
||
} | ||
|
||
class TestPackageProvider implements PackageProvider { | ||
Iterable<String> get packages => ['js']; | ||
|
||
Future<Asset> getAsset(AssetId id) { | ||
if (id.package == 'js' && id.path == 'lib/js.dart') { | ||
return new Future.value( | ||
new Asset.fromString(id, readJsPackageFile('js.dart'))); | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.