You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(css): crash when CSS @import is ignored with exportType: "style" #22842
When using native CSS (experiments.css: true) with parser.exportType: "style", @import rules that point to an ignored module (e.g., via IgnorePlugin or resolve.alias: { "...": false }) cause webpack to throw TypeError: Cannot read properties of null (reading 'userRequest') during code generation.
Current Behavior
Building a project that contains a CSS file with @import "./ignored.css"; and exportType: "style", combined with new webpack.IgnorePlugin({ resourceRegExp: /ignored\.css$/ }), crashes during code generation:
TypeError: Cannot read properties of null (reading 'userRequest')
at CssGenerator._generateImportExpressions (webpack/lib/css/CssGenerator.js:861:25)
at generateImportCode (webpack/lib/css/CssGenerator.js:364:20)
at CssGenerator.generate (webpack/lib/css/CssGenerator.js:558:9)
Expected Behavior
The compilation should succeed. If an @import dependency is ignored or has no resolved module (moduleGraph.getModule(dep) is null), CssGenerator._generateImportExpressions should skip it without crashing, matching the behavior in CssGenerator._renderMergedCss.
When dep resolves to false (ignored), moduleGraph.getModule(dep) returns null. Accessing depModule.userRequest causes an unhandled TypeError. Adding if (!depModule) continue; resolves this issue, consistent with _renderMergedCss.
Activity
fix: resolve issue #22842 skip ignored CSS imports with exportType st…