Skip to content

source-map-loader runs over all of node_modules, producing spurious build warnings #310

Description

@arbrandes

Description

Production builds emit a "Failed to parse source map" warning for every third-party dependency that ships a broken or incomplete sourcemap. In frontend-template-site this is 9 warnings: 8 from timeago.js (its maps reference ../src/*.ts, which isn't published to npm, and carry no sourcesContent) and 1 from react-responsive (its map's sources is webpack:///dist/react-responsive.js, a scheme source-map-loader can't resolve). Neither is actionable downstream, and they bury the warnings that do matter.

The cause is in tools/webpack/common-config/all/getCodeRules.ts, where the production source-map-loader rule matches every .js/.jsx/.ts/.tsx with no exclude, so it attempts to load maps for all of node_modules.

The fix should be ignoreWarnings: [/Failed to parse source map/] in webpack.config.build.ts, not an exclude on the rule. Excluding node_modules would be actively harmful: under the 2.0 architecture the apps being debugged are themselves npm packages, and every @openedx/frontend-app-* package ships sourcemaps with sourcesContent embedded. Consuming those is what lets a bundle sourcemap resolve to the original .tsx/.jsx rather than to the published dist/*.js, so excluding node_modules would break stack traces and breakpoints across the learner dashboard, authn, instructor dashboard, and catalog.

Sites can't work around this themselves either way, since no webpack config override hook is exposed.

Reproduced with @openedx/frontend-base 2.0.0-alpha.10 and webpack 5.110.1.

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions