GeezerVison is showing github.com — Merge pull request #6583 from webpack/bugfix/import-cjs · webpack/webpack@9f9c3d1
File treeExpand file treeCollapse file tree Open diff view settings cases/mjs/non-mjs-namespace-object-lazy aggressive-splitting-entry named-chunks-plugin-async
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/ContextModule.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -269,12 +269,12 @@ class ContextModule extends Module { | 269 | 269 | getReturn(type) { | 270 | 270 | if (type === 1) return "module"; | 271 | 271 | if (type === 2) | 272 | | - return 'Object.assign({/* fake namespace object */}, module, { "default": module })'; | | 272 | + return 'Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module })'; | 273 | 273 | if (type === 0) { | 274 | 274 | if (this.options.namespaceObject === "strict") { | 275 | 275 | return '/* fake namespace object */ { "default": module }'; | 276 | 276 | } else { | 277 | | - return '(typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module })'; | | 277 | + return '(typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }))'; | 278 | 278 | } | 279 | 279 | } | 280 | 280 | } | |
Collapse file Copy file name to clipboardExpand all lines: lib/RuntimeTemplate.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -94,7 +94,7 @@ module.exports = class RuntimeTemplate { | 94 | 94 | } else { | 95 | 95 | return `Object(function() { var module = ${ | 96 | 96 | rawModule | 97 | | - }; return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; }())`; | | 97 | + }; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`; | 98 | 98 | } | 99 | 99 | } | 100 | 100 |
| @@ -150,7 +150,7 @@ module.exports = class RuntimeTemplate { | 150 | 150 | } else { | 151 | 151 | getModuleFunction = `function() { ${header}var module = ${ | 152 | 152 | rawModule | 153 | | - }; return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; }`; | | 153 | + }; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`; | 154 | 154 | } | 155 | 155 |
| 156 | 156 | return `${promise || "Promise.resolve()"}.then(${getModuleFunction})`; | |
Collapse file Copy file name to clipboardExpand all lines: test/cases/mjs/non-mjs-namespace-object-lazy/index.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | it("should receive a namespace object when importing commonjs", function(done) { | 2 | 2 | import("./cjs").then(function(result) { | 3 | | - result.should.be.eql({ default: { named: "named", default: "default" } }); | | 3 | + result.should.be.eql({ named: "named", default: { named: "named", default: "default" } }); | 4 | 4 | done(); | 5 | 5 | }).catch(done); | 6 | 6 | }); | @@ -60,9 +60,9 @@ function promiseTest(promise, equalsTo) { | 60 | 60 |
| 61 | 61 | it("should receive a namespace object when importing commonjs via context", function() { | 62 | 62 | return Promise.all([ | 63 | | - promiseTest(contextCJS("one"), { default: { named: "named", default: "default" } }), | | 63 | + promiseTest(contextCJS("one"), { named: "named", default: { named: "named", default: "default" } }), | 64 | 64 | promiseTest(contextCJS("two"), { __esModule: true, named: "named", default: "default" }), | 65 | | - promiseTest(contextCJS("three"), { default: { named: "named", default: "default" } }), | | 65 | + promiseTest(contextCJS("three"), { named: "named", default: { named: "named", default: "default" } }), | 66 | 66 | promiseTest(contextCJS("null"), { default: null }) | 67 | 67 | ]); | 68 | 68 | }); | @@ -77,7 +77,7 @@ it("should receive a namespace object when importing harmony via context", funct | 77 | 77 |
| 78 | 78 | it("should receive a namespace object when importing mixed content via context", function() { | 79 | 79 | return Promise.all([ | 80 | | - promiseTest(contextMixed("one"), { default: { named: "named", default: "default" } }), | | 80 | + promiseTest(contextMixed("one"), { named: "named", default: { named: "named", default: "default" } }), | 81 | 81 | promiseTest(contextMixed("two"), { __esModule: true, named: "named", default: "default" }), | 82 | 82 | promiseTest(contextMixed("three"), { named: "named", default: "default" }), | 83 | 83 | promiseTest(contextMixed("null"), { default: null }) | |
Collapse file Copy file name to clipboardExpand all lines: test/statsCases/aggressive-splitting-entry/expected.txt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ Child fitting: | 5 | 5 | Built at: Thu Jan 01 1970 00:00:00 GMT | 6 | 6 | Asset Size Chunks Chunk Names | 7 | 7 | fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted] | 8 | | - a1e683753eca705a0882.js 9.92 KiB 1 [emitted] | | 8 | + a1e683753eca705a0882.js 9.97 KiB 1 [emitted] | 9 | 9 | d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted] | 10 | 10 | 6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted] | 11 | 11 | Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js | @@ -31,7 +31,7 @@ Child content-change: | 31 | 31 | Built at: Thu Jan 01 1970 00:00:00 GMT | 32 | 32 | Asset Size Chunks Chunk Names | 33 | 33 | fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted] | 34 | | - a1e683753eca705a0882.js 9.92 KiB 1 [emitted] | | 34 | + a1e683753eca705a0882.js 9.97 KiB 1 [emitted] | 35 | 35 | d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted] | 36 | 36 | 6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted] | 37 | 37 | Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js | |
Collapse file Copy file name to clipboardExpand all lines: test/statsCases/import-weak/expected.txt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,7 @@ Time: Xms | 3 | 3 | Built at: Thu Jan 01 1970 00:00:00 GMT | 4 | 4 | Asset Size Chunks Chunk Names | 5 | 5 | 0.js 149 bytes 0 [emitted] | 6 | | -entry.js 7.63 KiB 1 [emitted] entry | | 6 | +entry.js 7.79 KiB 1 [emitted] entry | 7 | 7 | Entrypoint entry = entry.js | 8 | 8 | [0] ./modules/b.js 22 bytes {0} [built] | 9 | 9 | [1] ./entry.js 120 bytes {1} [built] | |
Collapse file Copy file name to clipboardExpand all lines: test/statsCases/limit-chunk-count-plugin/expected.txt +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,7 @@ Child 1 chunks: | 4 | 4 | Time: Xms | 5 | 5 | Built at: Thu Jan 01 1970 00:00:00 GMT | 6 | 6 | Asset Size Chunks Chunk Names | 7 | | - bundle.js 5.52 KiB 0 [emitted] main | | 7 | + bundle.js 5.68 KiB 0 [emitted] main | 8 | 8 | Entrypoint main = bundle.js | 9 | 9 | chunk {0} bundle.js (main) 191 bytes <{0}> >{0}< [entry] [rendered] | 10 | 10 | [0] ./index.js 73 bytes {0} [built] | @@ -17,9 +17,9 @@ Child 2 chunks: | 17 | 17 | Hash: f90c7b21ae5c6e853a0d | 18 | 18 | Time: Xms | 19 | 19 | Built at: Thu Jan 01 1970 00:00:00 GMT | 20 | | - Asset Size Chunks Chunk Names | 21 | | - 0.bundle.js 912 bytes 0 [emitted] | 22 | | - bundle.js 7.14 KiB 1 [emitted] main | | 20 | + Asset Size Chunks Chunk Names | | 21 | + 0.bundle.js 1 KiB 0 [emitted] | | 22 | + bundle.js 7.19 KiB 1 [emitted] main | 23 | 23 | Entrypoint main = bundle.js | 24 | 24 | chunk {0} 0.bundle.js 118 bytes <{0}> <{1}> >{0}< [rendered] | 25 | 25 | [0] ./d.js 22 bytes {0} [built] | @@ -34,9 +34,9 @@ Child 3 chunks: | 34 | 34 | Time: Xms | 35 | 35 | Built at: Thu Jan 01 1970 00:00:00 GMT | 36 | 36 | Asset Size Chunks Chunk Names | 37 | | - 0.bundle.js 774 bytes 0 [emitted] | | 37 | + 0.bundle.js 886 bytes 0 [emitted] | 38 | 38 | 1.bundle.js 245 bytes 1 [emitted] | 39 | | - bundle.js 7.14 KiB 2 [emitted] main | | 39 | + bundle.js 7.19 KiB 2 [emitted] main | 40 | 40 | Entrypoint main = bundle.js | 41 | 41 | chunk {0} 0.bundle.js 74 bytes <{0}> <{2}> >{0}< >{1}< [rendered] | 42 | 42 | [0] ./d.js 22 bytes {0} [built] | @@ -54,8 +54,8 @@ Child 4 chunks: | 54 | 54 | Asset Size Chunks Chunk Names | 55 | 55 | 0.bundle.js 236 bytes 0 [emitted] | 56 | 56 | 1.bundle.js 245 bytes 1 [emitted] | 57 | | - 2.bundle.js 603 bytes 2 [emitted] | 58 | | - bundle.js 7.14 KiB 3 [emitted] main | | 57 | + 2.bundle.js 715 bytes 2 [emitted] | | 58 | + bundle.js 7.19 KiB 3 [emitted] main | 59 | 59 | Entrypoint main = bundle.js | 60 | 60 | chunk {0} 0.bundle.js 44 bytes <{2}> <{3}> [rendered] | 61 | 61 | [0] ./d.js 22 bytes {0} [built] | |
Collapse file Copy file name to clipboardExpand all lines: test/statsCases/named-chunks-plugin-async/expected.txt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,9 +2,9 @@ Hash: c5b0089a4015e8744f8e | 2 | 2 | Time: Xms | 3 | 3 | Built at: Thu Jan 01 1970 00:00:00 GMT | 4 | 4 | Asset Size Chunks Chunk Names | 5 | | -chunk-containing-__a_js.js 453 bytes chunk-containing-__a_js [emitted] | | 5 | +chunk-containing-__a_js.js 509 bytes chunk-containing-__a_js [emitted] | 6 | 6 | chunk-containing-__b_js.js 173 bytes chunk-containing-__b_js [emitted] | 7 | | - entry.js 7.17 KiB entry [emitted] entry | | 7 | + entry.js 7.28 KiB entry [emitted] entry | 8 | 8 | Entrypoint entry = entry.js | 9 | 9 | [0] ./modules/b.js 22 bytes {chunk-containing-__b_js} [built] | 10 | 10 | [1] ./modules/a.js 37 bytes {chunk-containing-__a_js} [built] | |
|