Skip to content

Commit

Permalink
fix: source map plugin module should enable by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Aug 13, 2024
1 parent bea8415 commit 0d7bfba
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]',
}),
]
};

0 comments on commit 0d7bfba

Please sign in to comment.