Skip to content

Commit

Permalink
fix: return url in CreateScriptUrlRuntimeModule (#8088)
Browse files Browse the repository at this point in the history
* fix: return url in CreateScriptUrlRuntimeModule

* fix: return url in CreateScriptUrlRuntimeModule

* fix: return url in CreateScriptUrlRuntimeModule
  • Loading branch information
LingyuCoder authored Oct 11, 2024
1 parent 6f08e69 commit 3153da6
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RuntimeModule for CreateScriptUrlRuntimeModule {
RuntimeGlobals::GET_TRUSTED_TYPES_POLICY
)
} else {
"'{url}'".to_string()
"url".to_string()
}
))
.boxed(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const RUNTIME_MODULE_NAME_MAPPING = {
"webpack/runtime/compat": "webpack/runtime/compat",
"webpack/runtime/create_fake_namespace_object":
"webpack/runtime/create fake namespace object",
"webpack/runtime/create_script_url":
"webpack/runtime/trusted types script url",
"webpack/runtime/create_script": "webpack/runtime/trusted types script",
"webpack/runtime/define_property_getters":
"webpack/runtime/define property getters",
Expand Down
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"
}
};
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");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function upper(str) {
return str.toUpperCase();
}
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`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import("../../..").TDiffCaseConfig} */
module.exports = {
modules: false,
runtimeModules: true
};
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"
}
};
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);
});
});
}
}]
};
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");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function upper(str) {
return str.toUpperCase();
}
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`);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import("../../..").TDiffCaseConfig} */
module.exports = {
modules: false,
runtimeModules: true
};
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);
});
});
}
}]
};

2 comments on commit 3153da6

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-10-11 598d44e) Current Change
10000_development-mode + exec 2.16 s ± 42 ms 2.17 s ± 26 ms +0.48 %
10000_development-mode_hmr + exec 682 ms ± 13 ms 687 ms ± 4.4 ms +0.74 %
10000_production-mode + exec 2.74 s ± 39 ms 2.75 s ± 41 ms +0.50 %
arco-pro_development-mode + exec 1.84 s ± 93 ms 1.82 s ± 88 ms -0.69 %
arco-pro_development-mode_hmr + exec 436 ms ± 6.2 ms 435 ms ± 5.9 ms -0.23 %
arco-pro_production-mode + exec 3.14 s ± 85 ms 3.1 s ± 66 ms -1.36 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.13 s ± 85 ms 3.19 s ± 102 ms +1.77 %
threejs_development-mode_10x + exec 1.7 s ± 16 ms 1.7 s ± 17 ms -0.07 %
threejs_development-mode_10x_hmr + exec 802 ms ± 9 ms 803 ms ± 7.8 ms +0.12 %
threejs_production-mode_10x + exec 5.04 s ± 24 ms 5.05 s ± 38 ms +0.25 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
_selftest ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
examples ✅ success
devserver ✅ success

Please sign in to comment.