-
-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(runtime-diff): alignment of startup chunk dependencies runtime …
…module (#4508) * feat(runtime-diff): Align startup chunks dependencies Align startup chunk dependencies runtime module * fix: clippy error
- Loading branch information
1 parent
05d366c
commit 77f57e5
Showing
39 changed files
with
423 additions
and
29 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
5 changes: 0 additions & 5 deletions
5
crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies.js
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...rspack_plugin_runtime/src/runtime_module/runtime/startup_chunk_dependencies_with_async.js
This file was deleted.
Oops, something went wrong.
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
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/async.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 @@ | ||
import { value } from "./shared"; | ||
export const result = value; |
25 changes: 25 additions & 0 deletions
25
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/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,25 @@ | ||
const fs = require("fs"); | ||
const vm = require("vm"); | ||
const path = require("path"); | ||
|
||
const requireAsync = file => { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(file, { encoding: "utf8" }, function (err, data) { | ||
const sandbox = { | ||
module: { | ||
exports: {} | ||
}, | ||
require: require, | ||
__dirname: __dirname, | ||
__filename: __filename | ||
}; | ||
vm.runInNewContext(data, sandbox); | ||
sandbox.module.exports.MyLib.then(resolve).catch(reject); | ||
}); | ||
}); | ||
}; | ||
|
||
it("should work with chunkLoading=async-node and only one entrypoint chunk", async () => { | ||
const chunk = await requireAsync(path.join(__dirname, "async.js")); | ||
expect(chunk.result).toBe("1"); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/lib-1.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 @@ | ||
export default "1"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/other.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 @@ | ||
import xxx from "./shared"; |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/shared.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 @@ | ||
import lib1 from "./lib-1"; | ||
export const value = lib1; |
29 changes: 29 additions & 0 deletions
29
packages/rspack/tests/configCases/chunk-loading/startup-async-node-1/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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
entry: { | ||
main: "./index.js", | ||
async: "./async.js", | ||
other: "./other.js" | ||
}, | ||
output: { | ||
filename: "[name].js", | ||
chunkLoading: "async-node", | ||
library: { | ||
name: "MyLib", | ||
type: "commonjs-module" | ||
} | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
minSize: 0, | ||
cacheGroups: { | ||
lib1: { | ||
test: /lib-1/, | ||
name: "lib1", | ||
chunks: "all", | ||
priority: 3 | ||
} | ||
} | ||
} | ||
}, | ||
target: "node" | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/async.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 @@ | ||
import { value } from "./shared"; | ||
export const result = value; |
25 changes: 25 additions & 0 deletions
25
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/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,25 @@ | ||
const fs = require("fs"); | ||
const vm = require("vm"); | ||
const path = require("path"); | ||
|
||
const requireAsync = file => { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(file, { encoding: "utf8" }, function (err, data) { | ||
const sandbox = { | ||
module: { | ||
exports: {} | ||
}, | ||
require: require, | ||
__dirname: __dirname, | ||
__filename: __filename | ||
}; | ||
vm.runInNewContext(data, sandbox); | ||
sandbox.module.exports.MyLib.then(resolve).catch(reject); | ||
}); | ||
}); | ||
}; | ||
|
||
it("should work with chunkLoading=async-node and only two entrypoint chunks", async () => { | ||
const chunk = await requireAsync(path.join(__dirname, "async.js")); | ||
expect(chunk.result).toBe("12"); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/lib-1.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 @@ | ||
export default "1"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/lib-2.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 @@ | ||
export default "2"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/other.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 @@ | ||
import xxx from "./shared"; |
3 changes: 3 additions & 0 deletions
3
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/shared.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 @@ | ||
import lib1 from "./lib-1"; | ||
import lib2 from "./lib-2"; | ||
export const value = lib1 + lib2; |
35 changes: 35 additions & 0 deletions
35
packages/rspack/tests/configCases/chunk-loading/startup-async-node-2/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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module.exports = { | ||
entry: { | ||
main: "./index.js", | ||
async: "./async.js", | ||
other: "./other.js" | ||
}, | ||
output: { | ||
filename: "[name].js", | ||
chunkLoading: "async-node", | ||
library: { | ||
name: "MyLib", | ||
type: "commonjs-module" | ||
} | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
minSize: 0, | ||
cacheGroups: { | ||
lib1: { | ||
test: /lib-1/, | ||
name: "lib1", | ||
chunks: "all", | ||
priority: 3 | ||
}, | ||
lib2: { | ||
test: /lib-2/, | ||
name: "lib2", | ||
chunks: "all", | ||
priority: 2 | ||
} | ||
} | ||
} | ||
}, | ||
target: "node" | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/async.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 @@ | ||
import { value } from "./shared"; | ||
export const result = value; |
25 changes: 25 additions & 0 deletions
25
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/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,25 @@ | ||
const fs = require("fs"); | ||
const vm = require("vm"); | ||
const path = require("path"); | ||
|
||
const requireAsync = file => { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(file, { encoding: "utf8" }, function (err, data) { | ||
const sandbox = { | ||
module: { | ||
exports: {} | ||
}, | ||
require: require, | ||
__dirname: __dirname, | ||
__filename: __filename | ||
}; | ||
vm.runInNewContext(data, sandbox); | ||
sandbox.module.exports.MyLib.then(resolve).catch(reject); | ||
}); | ||
}); | ||
}; | ||
|
||
it("should work with chunkLoading=async-node and only three or more entrypoint chunks", async () => { | ||
const chunk = await requireAsync(path.join(__dirname, "async.js")); | ||
expect(chunk.result).toBe("123"); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/lib-1.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 @@ | ||
export default "1"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/lib-2.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 @@ | ||
export default "2"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/lib-3.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 @@ | ||
export default "3"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/other.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 @@ | ||
import xxx from "./shared"; |
4 changes: 4 additions & 0 deletions
4
packages/rspack/tests/configCases/chunk-loading/startup-async-node-3/shared.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 @@ | ||
import lib2 from "./lib-2"; | ||
import lib1 from "./lib-1"; | ||
import lib3 from "./lib-3"; | ||
export const value = lib1 + lib2 + lib3; |
Oops, something went wrong.