Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
194 additions
and
163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
/* This test verifies that webpack externals are properly indicated as dependencies to System. | ||
* Also that when System provides the external variables to webpack that the variables get plumbed | ||
* through correctly and are usable by the webpack bundle. | ||
*/ | ||
afterEach(function(done) { | ||
delete global.System; | ||
done() | ||
}) | ||
|
||
*/ | ||
it("should get an external from System", function() { | ||
const external1 = require("external1"); | ||
expect(external1).toBe('the external1 value'); | ||
expect(external1).toBe("the external1 value"); | ||
|
||
const external2 = require("external2"); | ||
expect(external2).toBe('the external2 value'); | ||
expect(external2).toBe("the external2 value"); | ||
}); |
16 changes: 16 additions & 0 deletions
16
test/configCases/externals/externals-system/test.config.js
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,16 @@ | ||
const System = require("../../../helpers/fakeSystem"); | ||
|
||
module.exports = { | ||
beforeExecute: () => { | ||
System.init({ | ||
external1: "the external1 value", | ||
external2: "the external2 value" | ||
}); | ||
}, | ||
moduleScope(scope) { | ||
scope.System = System; | ||
}, | ||
afterExecute: () => { | ||
System.execute("(anonym)"); | ||
} | ||
}; |
24 changes: 1 addition & 23 deletions
24
test/configCases/externals/externals-system/webpack.config.js
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 |
---|---|---|
@@ -1,31 +1,9 @@ | ||
const webpack = require("../../../../"); | ||
module.exports = { | ||
output: { | ||
libraryTarget: "system" | ||
}, | ||
externals: { | ||
external1: "external1", | ||
external2: "external2" | ||
}, | ||
plugins: [ | ||
new webpack.BannerPlugin({ | ||
raw: true, | ||
banner: ` | ||
System = { | ||
register: function(deps, fn) { | ||
function dynamicExport() {} | ||
var mod = fn(dynamicExport); | ||
deps.forEach((dep, i) => { | ||
mod.setters[i](System.registry[dep]); | ||
}) | ||
mod.execute(); | ||
}, | ||
registry: { | ||
external1: 'the external1 value', | ||
external2: 'the external2 value', | ||
}, | ||
} | ||
` | ||
}) | ||
] | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,22 +1,13 @@ | ||
// This test verifies that values exported by a webpack bundle are consumable by systemjs. | ||
|
||
export const namedThing = { | ||
hello: 'there' | ||
} | ||
hello: "there" | ||
}; | ||
|
||
export default 'the default export' | ||
export default "the default export"; | ||
|
||
it("should successfully export values to System", function(done) { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
|
||
// set timeout allows the webpack bundle to finish exporting, which exports to System at the very | ||
// end of its execution. | ||
setTimeout(() => { | ||
expect(global.SystemExports['default']).toBe('the default export') | ||
expect(global.SystemExports.namedThing).toBe(namedThing) | ||
delete global.System; | ||
delete global.SystemExports | ||
done() | ||
}) | ||
}); | ||
it("should successfully export values to System", function() { | ||
const exports = eval("System").registry["(anonym)"].exports; | ||
expect(exports["default"]).toBe("the default export"); | ||
expect(exports.namedThing).toBe(namedThing); | ||
}); |
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,13 @@ | ||
const System = require("../../../helpers/fakeSystem"); | ||
|
||
module.exports = { | ||
beforeExecute: () => { | ||
System.init(); | ||
}, | ||
moduleScope(scope) { | ||
scope.System = System; | ||
}, | ||
afterExecute: () => { | ||
System.execute("(anonym)"); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,28 +1,9 @@ | ||
const webpack = require("../../../../"); | ||
module.exports = { | ||
output: { | ||
libraryTarget: "system" | ||
}, | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
plugins: [ | ||
new webpack.BannerPlugin({ | ||
raw: true, | ||
banner: ` | ||
global.SystemExports = { | ||
'export': function(exports) { | ||
Object.assign(global.SystemExports, exports); | ||
} | ||
}; | ||
global.System = { | ||
register: function(deps, fn) { | ||
var mod = fn(global.SystemExports['export']); | ||
mod.execute(); | ||
} | ||
}; | ||
` | ||
}) | ||
] | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,15 +1,5 @@ | ||
/* This test verifies that when output.library is specified that the compiled bundle provides | ||
* the library name to System during the System.register | ||
*/ | ||
* the library name to System during the System.register | ||
*/ | ||
|
||
afterEach(function(done) { | ||
delete global.System; | ||
done() | ||
}) | ||
|
||
it("should call System.register with a name", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
|
||
expect(source).toMatch(/.*System\.register\("named-system-module", \[[^\]]*\]/); | ||
}); | ||
it("should call System.register with a name", function() {}); |
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,13 @@ | ||
const System = require("../../../helpers/fakeSystem"); | ||
|
||
module.exports = { | ||
beforeExecute: () => { | ||
System.init(); | ||
}, | ||
moduleScope(scope) { | ||
scope.System = System; | ||
}, | ||
afterExecute: () => { | ||
System.execute("named-system-module"); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,15 +1,5 @@ | ||
/* This test verifies that when there is no output.library specified that the call to | ||
* System.register does not include a name argument. | ||
*/ | ||
* System.register does not include a name argument. | ||
*/ | ||
|
||
afterEach(function(done) { | ||
delete global.System; | ||
done() | ||
}) | ||
|
||
it("should call System.register without a name", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
|
||
expect(source).toMatch(/.*System\.register\(\[[^\]]*\], function\(__WEBPACK_DYNAMIC_EXPORT__\) {\s+(var .*;)?\s*return \{\s+setters: [^]+,[^]+execute: function\(\) {/); | ||
}); | ||
it("should call System.register without a name", function() {}); |
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,13 @@ | ||
const System = require("../../../helpers/fakeSystem"); | ||
|
||
module.exports = { | ||
beforeExecute: () => { | ||
System.init(); | ||
}, | ||
moduleScope(scope) { | ||
scope.System = System; | ||
}, | ||
afterExecute: () => { | ||
System.execute("(anonym)"); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,25 +1,9 @@ | ||
const webpack = require("../../../../"); | ||
module.exports = { | ||
output: { | ||
libraryTarget: "system" | ||
}, | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
plugins: [ | ||
new webpack.BannerPlugin({ | ||
raw: true, | ||
banner: ` | ||
System = { | ||
register: function(deps, fn) { | ||
function dynamicExport() {} | ||
var mod = fn(dynamicExport) | ||
mod.execute() | ||
} | ||
} | ||
` | ||
}) | ||
] | ||
} | ||
}; |
Oops, something went wrong.