mirror of https://github.com/webpack/webpack.git
Compare commits
3 Commits
df17951e36
...
3d7da1d3d5
| Author | SHA1 | Date |
|---|---|---|
|
|
3d7da1d3d5 | |
|
|
85bacbdc6e | |
|
|
7634cd28bf |
|
|
@ -300,7 +300,7 @@ module.exports = __webpack_require__.tb("PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmc
|
||||||
/******/
|
/******/
|
||||||
/******/ /* webpack/runtime/jsonp chunk loading */
|
/******/ /* webpack/runtime/jsonp chunk loading */
|
||||||
/******/ (() => {
|
/******/ (() => {
|
||||||
/******/ __webpack_require__.b = (document && document.baseURI) || self.location.href;
|
/******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
|
||||||
/******/
|
/******/
|
||||||
/******/ // object to store loaded and loading chunks
|
/******/ // object to store loaded and loading chunks
|
||||||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
||||||
|
|
@ -476,10 +476,10 @@ files.forEach(item => {
|
||||||
asset output.js 19.2 KiB [emitted] (name: main)
|
asset output.js 19.2 KiB [emitted] (name: main)
|
||||||
asset images/89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main)
|
asset images/89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main)
|
||||||
asset images/afc10c70ed4ce2b33593.svg 656 bytes [emitted] [immutable] [from: images/url.svg] (auxiliary name: main)
|
asset images/afc10c70ed4ce2b33593.svg 656 bytes [emitted] [immutable] [from: images/url.svg] (auxiliary name: main)
|
||||||
chunk (runtime: main) output.js (main) 12.4 KiB (javascript) 15.2 KiB (asset) 1.46 KiB (runtime) [entry] [rendered]
|
chunk (runtime: main) output.js (main) 12.4 KiB (javascript) 15.2 KiB (asset) 1.48 KiB (runtime) [entry] [rendered]
|
||||||
> ./example.js main
|
> ./example.js main
|
||||||
dependent modules 9.59 KiB (javascript) 15.2 KiB (asset) [dependent] 6 modules
|
dependent modules 9.59 KiB (javascript) 15.2 KiB (asset) [dependent] 6 modules
|
||||||
runtime modules 1.46 KiB 5 modules
|
runtime modules 1.48 KiB 5 modules
|
||||||
./example.js 2.85 KiB [built] [code generated]
|
./example.js 2.85 KiB [built] [code generated]
|
||||||
[no exports]
|
[no exports]
|
||||||
[used exports unknown]
|
[used exports unknown]
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ export const add = (content, from) => {
|
||||||
/******/
|
/******/
|
||||||
/******/ /* webpack/runtime/jsonp chunk loading */
|
/******/ /* webpack/runtime/jsonp chunk loading */
|
||||||
/******/ (() => {
|
/******/ (() => {
|
||||||
/******/ __webpack_require__.b = (document && document.baseURI) || self.location.href;
|
/******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
|
||||||
/******/
|
/******/
|
||||||
/******/ // object to store loaded and loading chunks
|
/******/ // object to store loaded and loading chunks
|
||||||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
||||||
|
|
@ -722,7 +722,7 @@ function fibonacci(n) {
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
asset main.js 11.8 KiB [emitted] (name: main)
|
asset main.js 11.9 KiB [emitted] (name: main)
|
||||||
asset workers/fibonacci.js 4.99 KiB [emitted] (name: fibonacci)
|
asset workers/fibonacci.js 4.99 KiB [emitted] (name: fibonacci)
|
||||||
asset chat.js 839 bytes [emitted] (name: chat)
|
asset chat.js 839 bytes [emitted] (name: chat)
|
||||||
asset 129.js 741 bytes [emitted]
|
asset 129.js 741 bytes [emitted]
|
||||||
|
|
@ -746,9 +746,9 @@ chunk (runtime: 9a81d90cfd0dfd13d748) workers/fibonacci.js (fibonacci) 176 bytes
|
||||||
./fib-worker.js 176 bytes [built] [code generated]
|
./fib-worker.js 176 bytes [built] [code generated]
|
||||||
[no exports used]
|
[no exports used]
|
||||||
new Worker() ./fib-worker.js ./example.js 80:18-84:2
|
new Worker() ./fib-worker.js ./example.js 80:18-84:2
|
||||||
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.4 KiB (runtime) [entry] [rendered]
|
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.42 KiB (runtime) [entry] [rendered]
|
||||||
> ./example.js main
|
> ./example.js main
|
||||||
runtime modules 5.4 KiB 7 modules
|
runtime modules 5.42 KiB 7 modules
|
||||||
./example.js 2.25 KiB [built] [code generated]
|
./example.js 2.25 KiB [built] [code generated]
|
||||||
[no exports used]
|
[no exports used]
|
||||||
entry ./example.js main
|
entry ./example.js main
|
||||||
|
|
@ -758,7 +758,7 @@ webpack X.X.X compiled successfully
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
asset main.js 3.27 KiB [emitted] [minimized] (name: main)
|
asset main.js 3.29 KiB [emitted] [minimized] (name: main)
|
||||||
asset workers/fibonacci.js 776 bytes [emitted] [minimized] (name: fibonacci)
|
asset workers/fibonacci.js 776 bytes [emitted] [minimized] (name: fibonacci)
|
||||||
asset chat.js 270 bytes [emitted] [minimized] (name: chat)
|
asset chat.js 270 bytes [emitted] [minimized] (name: chat)
|
||||||
asset 129.js 159 bytes [emitted] [minimized]
|
asset 129.js 159 bytes [emitted] [minimized]
|
||||||
|
|
@ -782,9 +782,9 @@ chunk (runtime: 9a81d90cfd0dfd13d748) workers/fibonacci.js (fibonacci) 176 bytes
|
||||||
./fib-worker.js 176 bytes [built] [code generated]
|
./fib-worker.js 176 bytes [built] [code generated]
|
||||||
[no exports used]
|
[no exports used]
|
||||||
new Worker() ./fib-worker.js ./example.js 80:18-84:2
|
new Worker() ./fib-worker.js ./example.js 80:18-84:2
|
||||||
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.4 KiB (runtime) [entry] [rendered]
|
chunk (runtime: main) main.js (main) 2.25 KiB (javascript) 5.42 KiB (runtime) [entry] [rendered]
|
||||||
> ./example.js main
|
> ./example.js main
|
||||||
runtime modules 5.4 KiB 7 modules
|
runtime modules 5.42 KiB 7 modules
|
||||||
./example.js 2.25 KiB [built] [code generated]
|
./example.js 2.25 KiB [built] [code generated]
|
||||||
[no exports used]
|
[no exports used]
|
||||||
entry ./example.js main
|
entry ./example.js main
|
||||||
|
|
|
||||||
|
|
@ -134,11 +134,21 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
|
||||||
);
|
);
|
||||||
if (used) {
|
if (used) {
|
||||||
if (otherUnused || used !== exportInfo.name) {
|
if (otherUnused || used !== exportInfo.name) {
|
||||||
instructions.push(
|
if (exportInfo.name === "default") {
|
||||||
`${external}${propertyAccess([
|
// Ideally we should use `module && module.__esModule ? module['default'] : module`
|
||||||
used
|
// But we need to keep compatibility with SystemJS format libraries (they are using `default`) and bundled SystemJS libraries from commonjs format
|
||||||
])} = module${propertyAccess([exportInfo.name])};`
|
instructions.push(
|
||||||
);
|
`${external}${propertyAccess([
|
||||||
|
used
|
||||||
|
])} = module["default"] || module;`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
instructions.push(
|
||||||
|
`${external}${propertyAccess([
|
||||||
|
used
|
||||||
|
])} = module${propertyAccess([exportInfo.name])};`
|
||||||
|
);
|
||||||
|
}
|
||||||
handledNames.push(exportInfo.name);
|
handledNames.push(exportInfo.name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
const a = 10;
|
||||||
|
const b = 20;
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
getValue() {
|
||||||
|
return "my-class";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = MyClass;
|
||||||
|
module.exports.a = a;
|
||||||
|
module.exports.b = b;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
const a = 10;
|
||||||
|
const b = 20;
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
getValue() {
|
||||||
|
return "my-class";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MyClass;
|
||||||
|
export { a, b };
|
||||||
|
|
@ -914,5 +914,25 @@ module.exports = (env, { testPath }) => [
|
||||||
experiments: {
|
experiments: {
|
||||||
outputModule: true
|
outputModule: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry: "./esm.js",
|
||||||
|
output: {
|
||||||
|
uniqueName: "system-esm",
|
||||||
|
filename: "system-esm.js",
|
||||||
|
library: {
|
||||||
|
type: "system"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry: "./commonjs.js",
|
||||||
|
output: {
|
||||||
|
uniqueName: "system-commonjs",
|
||||||
|
filename: "system-commonjs.js",
|
||||||
|
library: {
|
||||||
|
type: "system"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import MyClass, {a, b} from "library-commonjs";
|
||||||
|
|
||||||
|
it("should get exports from systemjs library (" + NAME + ")", function() {
|
||||||
|
expect(new MyClass().getValue()).toBe("my-class")
|
||||||
|
expect(a).toBe(10);
|
||||||
|
expect(b).toBe(20);
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const System = require("../../../helpers/fakeSystem");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
beforeExecute: () => {
|
||||||
|
System.init();
|
||||||
|
},
|
||||||
|
moduleScope(scope) {
|
||||||
|
scope.System = System;
|
||||||
|
scope.System.setRequire(scope.require);
|
||||||
|
},
|
||||||
|
afterExecute() {
|
||||||
|
delete global.webpackChunk;
|
||||||
|
System.execute("(anonym)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const webpack = require("../../../../");
|
||||||
|
|
||||||
|
/** @type {(env: Env, options: TestOptions) => import("../../../../").Configuration[]} */
|
||||||
|
module.exports = (env, { testPath }) => [
|
||||||
|
{
|
||||||
|
entry: "./system-external-commonjs.js",
|
||||||
|
output: {
|
||||||
|
library: {
|
||||||
|
type: "system"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
"library-commonjs": path.resolve(
|
||||||
|
testPath,
|
||||||
|
"../0-create-library/system-commonjs.js"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
NAME: JSON.stringify("systemjs with external from commonjs format")
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import MyClass, {a, b} from "library-esm";
|
||||||
|
|
||||||
|
it("should get exports from systemjs library (" + NAME + ")", function() {
|
||||||
|
expect(new MyClass().getValue()).toBe("my-class")
|
||||||
|
expect(a).toBe(10);
|
||||||
|
expect(b).toBe(20);
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const System = require("../../../helpers/fakeSystem");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
beforeExecute: () => {
|
||||||
|
System.init();
|
||||||
|
},
|
||||||
|
moduleScope(scope) {
|
||||||
|
scope.System = System;
|
||||||
|
scope.System.setRequire(scope.require);
|
||||||
|
},
|
||||||
|
afterExecute() {
|
||||||
|
delete global.webpackChunk;
|
||||||
|
System.execute("(anonym)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
const webpack = require("../../../../");
|
||||||
|
|
||||||
|
/** @type {(env: Env, options: TestOptions) => import("../../../../").Configuration[]} */
|
||||||
|
module.exports = (env, { testPath }) => [
|
||||||
|
{
|
||||||
|
entry: "./system-external-esm.js",
|
||||||
|
output: {
|
||||||
|
library: {
|
||||||
|
type: "system"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
"library-esm": path.resolve(testPath, "../0-create-library/system-esm.js")
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
NAME: JSON.stringify("systemjs with external from ES module format")
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
Loading…
Reference in New Issue