Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return url in CreateScriptUrlRuntimeModule #8088

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
}
}]
};
Loading