-
-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: diff context module lazy once mode (#6398)
- Loading branch information
Showing
20 changed files
with
216 additions
and
23 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
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/runtimeDiffCases/module-context-module/src/index.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,2 +1,3 @@ | ||
import "./dynamic-import"; | ||
import "./cjs-require"; | ||
import "./namespace-object-lazy" |
3 changes: 3 additions & 0 deletions
3
...ls/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/cjs-esmodule.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,3 @@ | ||
exports.__esModule = true; | ||
exports.default = "default"; | ||
exports.named = "named"; |
2 changes: 2 additions & 0 deletions
2
...-test-tools/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/cjs.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,2 @@ | ||
exports.default = "default"; | ||
exports.named = "named"; |
1 change: 1 addition & 0 deletions
1
...ls/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-cjs/null.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 @@ | ||
module.exports = null; |
2 changes: 2 additions & 0 deletions
2
...ols/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-cjs/one.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,2 @@ | ||
exports.named = "named"; | ||
exports.default = "default"; |
2 changes: 2 additions & 0 deletions
2
...s/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-cjs/three.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,2 @@ | ||
exports.named = "named"; | ||
exports.default = "default"; |
4 changes: 4 additions & 0 deletions
4
...ols/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-cjs/two.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,4 @@ | ||
exports.__esModule = true; | ||
exports.named = "named"; | ||
exports.default = "default"; | ||
|
2 changes: 2 additions & 0 deletions
2
...tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-harmony/one.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,2 @@ | ||
export default "default"; | ||
export var named = "named"; |
2 changes: 2 additions & 0 deletions
2
...sts/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-harmony/three.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,2 @@ | ||
export default "default"; | ||
export var named = "named"; |
2 changes: 2 additions & 0 deletions
2
...tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-harmony/two.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,2 @@ | ||
export default "default"; | ||
export var named = "named"; |
4 changes: 4 additions & 0 deletions
4
...ests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-mixed/json.json
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,4 @@ | ||
{ | ||
"default": "default", | ||
"named": "named" | ||
} |
1 change: 1 addition & 0 deletions
1
.../tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-mixed/null.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 @@ | ||
module.exports = null; |
2 changes: 2 additions & 0 deletions
2
...s/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-mixed/one.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,2 @@ | ||
exports.named = "named"; | ||
exports.default = "default"; |
2 changes: 2 additions & 0 deletions
2
...tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-mixed/three.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,2 @@ | ||
export default "default"; | ||
export var named = "named"; |
4 changes: 4 additions & 0 deletions
4
...s/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/dir-mixed/two.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,4 @@ | ||
exports.__esModule = true; | ||
exports.named = "named"; | ||
exports.default = "default"; | ||
|
88 changes: 88 additions & 0 deletions
88
...est-tools/tests/runtimeDiffCases/module-context-module/src/namespace-object-lazy/index.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,88 @@ | ||
// non-mjs-namespace-object-lazy | ||
|
||
it("should receive a namespace object when importing commonjs", function(done) { | ||
import("./cjs").then(function(result) { | ||
expect(result).toEqual(nsObj({ named: "named", default: { named: "named", default: "default" } })); | ||
done(); | ||
}).catch(done); | ||
}); | ||
|
||
it("should receive a namespace object when importing commonjs with __esModule", function(done) { | ||
import("./cjs-esmodule").then(function(result) { | ||
expect(result).toEqual({ __esModule: true, named: "named", default: "default" }); | ||
done(); | ||
}).catch(done); | ||
}); | ||
|
||
function contextCJS(name) { | ||
return Promise.all([ | ||
import(`./dir-cjs/${name}`), | ||
import(/* webpackMode: "lazy-once", webpackChunkName: "dir-cjs-1" */`./dir-cjs?1/${name}`), | ||
// import(/* webpackMode: "eager" */`./dir-cjs?2/${name}`) | ||
]).then(function(results) { | ||
// return import(/* webpackMode: "weak" */`./dir-cjs/${name}`).then(function(r) { | ||
// results.push(r); | ||
// return results; | ||
// }); | ||
}); | ||
} | ||
|
||
function contextHarmony(name) { | ||
return Promise.all([ | ||
import(`./dir-harmony/${name}`), | ||
import(/* webpackMode: "lazy-once", webpackChunkName: "dir-harmony-1" */`./dir-harmony?1/${name}`), | ||
// import(/* webpackMode: "eager" */`./dir-harmony?2/${name}`) | ||
]).then(function(results) { | ||
// return import(/* webpackMode: "weak" */`./dir-harmony/${name}`).then(function(r) { | ||
// results.push(r); | ||
// return results; | ||
// }); | ||
}); | ||
} | ||
|
||
function contextMixed(name) { | ||
return Promise.all([ | ||
import(`./dir-mixed/${name}`), | ||
import(/* webpackMode: "lazy-once", webpackChunkName: "dir-mixed-1" */`./dir-mixed?1/${name}`), | ||
// import(/* webpackMode: "eager" */`./dir-mixed?2/${name}`) | ||
]).then(function(results) { | ||
// return import(/* webpackMode: "weak" */`./dir-mixed/${name}`).then(function(r) { | ||
// results.push(r); | ||
// return results; | ||
// }); | ||
}); | ||
} | ||
|
||
function promiseTest(promise, equalsTo) { | ||
return promise.then(function(results) { | ||
for(const result of results) | ||
expect(result).toEqual(equalsTo); | ||
}); | ||
} | ||
|
||
it("should receive a namespace object when importing commonjs via context", function() { | ||
return Promise.all([ | ||
promiseTest(contextCJS("one"), nsObj({ named: "named", default: { named: "named", default: "default" } })), | ||
promiseTest(contextCJS("two"), { __esModule: true, named: "named", default: "default" }), | ||
promiseTest(contextCJS("three"), nsObj({ named: "named", default: { named: "named", default: "default" } })), | ||
promiseTest(contextCJS("null"), nsObj({ default: null })) | ||
]); | ||
}); | ||
|
||
it("should receive a namespace object when importing harmony via context", function() { | ||
return Promise.all([ | ||
promiseTest(contextHarmony("one"), nsObj({ named: "named", default: "default" })), | ||
promiseTest(contextHarmony("two"), nsObj({ named: "named", default: "default" })), | ||
promiseTest(contextHarmony("three"), nsObj({ named: "named", default: "default" })) | ||
]); | ||
}); | ||
|
||
it("should receive a namespace object when importing mixed content via context", function() { | ||
return Promise.all([ | ||
promiseTest(contextMixed("one"), nsObj({ named: "named", default: { named: "named", default: "default" } })), | ||
promiseTest(contextMixed("two"), { __esModule: true, named: "named", default: "default" }), | ||
promiseTest(contextMixed("three"), nsObj({ named: "named", default: "default" })), | ||
promiseTest(contextMixed("null"), nsObj({ default: null })), | ||
promiseTest(contextMixed("json.json"), nsObj({ named: "named", default: { named: "named", default: "default" } })) | ||
]); | ||
}); |
This file was deleted.
Oops, something went wrong.
5cf18b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
5cf18b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
Threshold exceeded: ["10000_production-mode + exec"]