forked from web-infra-dev/rspack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return url in CreateScriptUrlRuntimeModule (web-infra-dev#8088)
* fix: return url in CreateScriptUrlRuntimeModule * fix: return url in CreateScriptUrlRuntimeModule * fix: return url in CreateScriptUrlRuntimeModule
- Loading branch information
1 parent
6f08e69
commit 3153da6
Showing
14 changed files
with
89 additions
and
1 deletion.
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
10 changes: 10 additions & 0 deletions
10
...sts/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/rspack.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,10 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
output: { | ||
trustedTypes: "customPolicyName", | ||
chunkLoading: "import-scripts" | ||
}, | ||
entry: { | ||
other: "./src/index" | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
...s/tests/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const worker = new Worker(new URL("./worker.js", import.meta.url), { | ||
type: "module", | ||
name: "worker1" | ||
}); | ||
worker.postMessage("ok"); |
3 changes: 3 additions & 0 deletions
3
.../tests/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/src/module.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 @@ | ||
export function upper(str) { | ||
return str.toUpperCase(); | ||
} |
4 changes: 4 additions & 0 deletions
4
.../tests/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/src/worker.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 @@ | ||
onmessage = async event => { | ||
const { upper } = await import("./module"); | ||
postMessage(`data: ${upper(event.data)}, thanks`); | ||
}; |
5 changes: 5 additions & 0 deletions
5
...tests/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/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,5 @@ | ||
/** @type {import("../../..").TDiffCaseConfig} */ | ||
module.exports = { | ||
modules: false, | ||
runtimeModules: true | ||
}; |
10 changes: 10 additions & 0 deletions
10
...ts/runtimeDiffCases/runtime-module/create-script-url#with-trusted-types/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,10 @@ | ||
/** @type {import("webpack").Configuration} */ | ||
module.exports = { | ||
output: { | ||
trustedTypes: "customPolicyName", | ||
chunkLoading: "import-scripts" | ||
}, | ||
entry: { | ||
other: "./src/index" | ||
} | ||
}; |
16 changes: 16 additions & 0 deletions
16
...spack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/rspack.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 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
entry: { | ||
other: "./src/index" | ||
}, | ||
plugins: [{ | ||
apply(compiler) { | ||
const { RuntimeGlobals } = compiler.webpack; | ||
compiler.hooks.thisCompilation.tap("testPlugin", (compilation) => { | ||
compilation.hooks.additionalTreeRuntimeRequirements.tap("testPlugin", (chunk, set) => { | ||
set.add(RuntimeGlobals.createScriptUrl); | ||
}); | ||
}); | ||
} | ||
}] | ||
}; |
5 changes: 5 additions & 0 deletions
5
...es/rspack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const worker = new Worker(new URL("./worker.js", import.meta.url), { | ||
type: "module", | ||
name: "worker1" | ||
}); | ||
worker.postMessage("ok"); |
3 changes: 3 additions & 0 deletions
3
...s/rspack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/src/module.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 @@ | ||
export function upper(str) { | ||
return str.toUpperCase(); | ||
} |
4 changes: 4 additions & 0 deletions
4
...s/rspack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/src/worker.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 @@ | ||
onmessage = async event => { | ||
const { upper } = await import("./module"); | ||
postMessage(`data: ${upper(event.data)}, thanks`); | ||
}; |
5 changes: 5 additions & 0 deletions
5
.../rspack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/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,5 @@ | ||
/** @type {import("../../..").TDiffCaseConfig} */ | ||
module.exports = { | ||
modules: false, | ||
runtimeModules: true | ||
}; |
16 changes: 16 additions & 0 deletions
16
...pack-test-tools/tests/runtimeDiffCases/runtime-module/create-script-url/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,16 @@ | ||
/** @type {import("webpack").Configuration} */ | ||
module.exports = { | ||
entry: { | ||
other: "./src/index" | ||
}, | ||
plugins: [{ | ||
apply(compiler) { | ||
const { RuntimeGlobals } = compiler.webpack; | ||
compiler.hooks.thisCompilation.tap("testPlugin", (compilation) => { | ||
compilation.hooks.additionalTreeRuntimeRequirements.tap("testPlugin", (chunk, set) => { | ||
set.add(RuntimeGlobals.createScriptUrl); | ||
}); | ||
}); | ||
} | ||
}] | ||
}; |