Skip to content

Commit

Permalink
fix: source map plugin module should enable by default (#7545)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk authored Aug 13, 2024
1 parent 21dd3df commit af5a43f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/rspack_binding_options/src/options/raw_devtool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl From<RawSourceMapDevToolPluginOptions> for SourceMapDevToolPluginOptions {
no_sources,
public_path: opts.public_path,
module_filename_template,
module: opts.module.unwrap_or(false),
module: opts.module.unwrap_or(true),
source_root: opts.source_root,
test,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function App() {
return <div id="test">Hello Rspack!</div>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require("./App");

it("`module` should be enabled by default", async () => {
const path = require("path");
const fs = require("fs");

const source = fs.readFileSync(__filename + ".map", "utf-8");
const app = fs.readFileSync(path.resolve(CONTEXT, "./App.jsx"), "utf-8");
const map = JSON.parse(source);
const appSourceIndex = map.sources.indexOf("webpack:///./App.jsx")
expect(appSourceIndex).toBeGreaterThanOrEqual(0);
expect(map.sourcesContent[appSourceIndex]).toEqual(app);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const rspack = require("@rspack/core");
/** @type {import("@rspack/core").Configuration} */
module.exports = {
devtool: false,
resolve: {
extensions: ["...", ".ts", ".tsx", ".jsx"]
},
module: {
rules: [
{
test: /\.jsx$/,
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true
}
}
}
}
]
},
plugins: [
new rspack.DefinePlugin({
CONTEXT: JSON.stringify(__dirname)
}),
new rspack.SourceMapDevToolPlugin({
filename: '[file].map[query]',
}),
]
};

2 comments on commit af5a43f

@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 ❌ failure
_selftest ✅ success
nx ❌ failure
rspress ✅ success
rsbuild ✅ success
examples ✅ success

@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-08-13 bea8415) Current Change
10000_development-mode + exec 2.3 s ± 17 ms 2.31 s ± 19 ms +0.28 %
10000_development-mode_hmr + exec 701 ms ± 11 ms 699 ms ± 14 ms -0.30 %
10000_production-mode + exec 2.85 s ± 35 ms 2.88 s ± 39 ms +0.93 %
arco-pro_development-mode + exec 1.91 s ± 85 ms 1.91 s ± 68 ms +0.01 %
arco-pro_development-mode_hmr + exec 433 ms ± 2.2 ms 433 ms ± 2.2 ms -0.04 %
arco-pro_production-mode + exec 3.46 s ± 88 ms 3.44 s ± 104 ms -0.80 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.56 s ± 104 ms 3.48 s ± 61 ms -2.31 %
threejs_development-mode_10x + exec 1.7 s ± 20 ms 1.68 s ± 20 ms -1.11 %
threejs_development-mode_10x_hmr + exec 820 ms ± 13 ms 798 ms ± 9.5 ms -2.61 %
threejs_production-mode_10x + exec 5.49 s ± 19 ms 5.49 s ± 24 ms -0.14 %

Please sign in to comment.