readd previous checks - refactor System polyfill
use webpacks "own" System polyfill, do not try to access a previously existing one. Instead make sure everything will be "shadowed" by the webpack System. thx @sokra for the help!
This commit is contained in:
parent
d056ba7d40
commit
d2de851b83
|
@ -1,3 +1,7 @@
|
||||||
/* global System */
|
// Provide a "System" global.
|
||||||
// "fix" for users of "System" global
|
module.exports = {
|
||||||
module.exports = typeof System === "undefined" ? {} : System;
|
// Make sure import is only used as "System.import"
|
||||||
|
import: function() {
|
||||||
|
throw new Error("System.import cannot be used indirectly");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -26,6 +26,8 @@ class SystemPlugin {
|
||||||
|
|
||||||
parser.plugin("typeof System.import", ParserHelpers.toConstantDependency(JSON.stringify("function")));
|
parser.plugin("typeof System.import", ParserHelpers.toConstantDependency(JSON.stringify("function")));
|
||||||
parser.plugin("evaluate typeof System.import", ParserHelpers.evaluateToString("function"));
|
parser.plugin("evaluate typeof System.import", ParserHelpers.evaluateToString("function"));
|
||||||
|
parser.plugin("typeof System", ParserHelpers.toConstantDependency(JSON.stringify("object")));
|
||||||
|
parser.plugin("evaluate typeof System", ParserHelpers.evaluateToString("object"));
|
||||||
|
|
||||||
setNotSupported("System.set");
|
setNotSupported("System.set");
|
||||||
setNotSupported("System.get");
|
setNotSupported("System.get");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
it("should polyfill System", function() {
|
it("should polyfill System", function() {
|
||||||
if (typeof System.register === "function") {
|
if (typeof System === "object" && typeof System.register === "function") {
|
||||||
require("fail");
|
require("fail");
|
||||||
}
|
}
|
||||||
(typeof System).should.be.eql("object");
|
(typeof System).should.be.eql("object");
|
||||||
|
|
|
@ -45,6 +45,7 @@ it("should not parse filtered stuff", function() {
|
||||||
if(typeof module === "undefined") module = require("fail");
|
if(typeof module === "undefined") module = require("fail");
|
||||||
if(typeof module != "object") module = require("fail");
|
if(typeof module != "object") module = require("fail");
|
||||||
if(typeof exports == "undefined") exports = require("fail");
|
if(typeof exports == "undefined") exports = require("fail");
|
||||||
|
if(typeof System !== "object") exports = require("fail");
|
||||||
if(typeof System.import !== "function") exports = require("fail");
|
if(typeof System.import !== "function") exports = require("fail");
|
||||||
if(typeof require.include !== "function") require.include("fail");
|
if(typeof require.include !== "function") require.include("fail");
|
||||||
if(typeof require.ensure !== "function") require.ensure(["fail"], function(){});
|
if(typeof require.ensure !== "function") require.ensure(["fail"], function(){});
|
||||||
|
|
Loading…
Reference in New Issue