Skip to content

Commit aaa31cf

Browse files
authored
fix: changeDevtoolModuleFilename not work problem (#1402)
1 parent e068194 commit aaa31cf

File tree

8 files changed

+68
-263
lines changed

8 files changed

+68
-263
lines changed

examples/rspack-banner-minimal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
},
2020
"devDependencies": {
2121
"@rsdoctor/rspack-plugin": "workspace:*",
22-
"@rspack/cli": "1.4.11",
23-
"@rspack/core": "1.4.11",
24-
"@rspack/plugin-react-refresh": "1.4.3",
22+
"@rspack/cli": "1.6.1",
23+
"@rspack/core": "1.6.1",
24+
"@rspack/plugin-react-refresh": "1.5.2",
2525
"@types/react": "^18.0.25",
2626
"@types/react-dom": "^18.0.8",
2727
"react-refresh": "^0.14.0",

examples/rspack-layers-minimal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
},
1919
"devDependencies": {
2020
"@rsdoctor/rspack-plugin": "workspace:*",
21-
"@rspack/cli": "1.4.11",
22-
"@rspack/core": "1.4.11",
23-
"@rspack/plugin-react-refresh": "^1.4.3",
21+
"@rspack/cli": "1.6.1",
22+
"@rspack/core": "1.6.1",
23+
"@rspack/plugin-react-refresh": "^1.5.2",
2424
"@types/react": "^18.0.25",
2525
"@types/react-dom": "^18.0.8",
2626
"react-refresh": "^0.14.0",

examples/rspack-minimal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
},
2222
"devDependencies": {
2323
"@rsdoctor/rspack-plugin": "workspace:*",
24-
"@rspack/cli": "1.4.11",
25-
"@rspack/core": "1.4.11",
26-
"@rspack/plugin-react-refresh": "^1.4.3",
24+
"@rspack/cli": "1.6.1",
25+
"@rspack/core": "1.6.1",
26+
"@rspack/plugin-react-refresh": "^1.5.2",
2727
"@types/react": "^18.0.25",
2828
"@types/react-dom": "^18.0.8",
2929
"react-refresh": "^0.14.0",

packages/core/src/inner-plugins/plugins/bundle.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@ export class InternalBundlePlugin<
1515
try {
1616
// bundle depends on module graph
1717
this.scheduler.ensureModulesChunksGraphApplied(compiler);
18-
19-
compiler.hooks.compilation.tap(
20-
{
21-
name: 'ChangeDevtoolModuleFilename',
22-
stage: -100,
23-
},
24-
() => {
25-
this.changeDevtoolModuleFilename(compiler);
26-
},
27-
);
18+
this.changeDevtoolModuleFilename(compiler);
2819

2920
compiler.hooks.compilation.tap(this.tapPostOptions, this.thisCompilation);
3021
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this));
@@ -51,7 +42,7 @@ export class InternalBundlePlugin<
5142
);
5243

5344
if (devtool.includes('source-map')) {
54-
compiler.options.output.devtoolFallbackModuleFilenameTemplate =
45+
compiler.options.output.devtoolFallbackModuleFilenameTemplate = () =>
5546
'[absolute-resource-path]';
5647
}
5748
}

packages/core/src/inner-plugins/plugins/sourcemapTool.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export async function collectSourceMaps(
9797

9898
// Group all mappings by generated line number
9999
const lineMappings = new Map<number, Array<MappingItem>>();
100+
// @ts-ignore consumer._absoluteSources maybe has problem.
101+
consumer._absoluteSources = consumer._sources;
102+
100103
consumer.eachMapping((m: MappingItem) => {
101104
if (!lineMappings.has(m.generatedLine)) {
102105
lineMappings.set(m.generatedLine, []);

packages/graph/src/transform/module-graph/transform.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ function getModulesFromChunks(
5252
) {
5353
chunks?.forEach((chunk) => {
5454
if (chunk.modules?.length) {
55-
collectedModules.push(...chunk.modules);
55+
collectedModules.push(
56+
...chunk.modules.map((module) => ({
57+
...module,
58+
identifier: module.identifier ?? module.moduleIdentifier,
59+
name: module.name ?? module.moduleName,
60+
})),
61+
);
5662
}
5763
});
5864
}
@@ -88,7 +94,7 @@ export function getModuleGraphByStats(
8894

8995
const isConcatenated = Boolean(data.modules && data.modules.length > 0);
9096
const concatenatedModule = new Module(
91-
data.identifier!,
97+
data.identifier ?? data.moduleIdentifier!,
9298
getGetModuleName(root, data),
9399
data.depth === 0,
94100
isConcatenated ? SDK.ModuleKind.Concatenation : SDK.ModuleKind.Normal,

packages/types/src/plugin/baseStats.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export interface StatsModule {
5858
type?: string;
5959
moduleType?: string;
6060
identifier?: string;
61+
moduleIdentifier?: string;
6162
name?: string;
63+
moduleName?: string;
6264
id?: string | number;
6365
chunks?: Array<string | number>;
6466
size?: number;

0 commit comments

Comments
 (0)