Skip to content

MiniCssExtractPlugin tries and crashes on CSS injection in Web Workers  #1001

Closed
@paztis

Description

@paztis

Bug report

Actual Behavior

In Web Worker, when we try to import files that are also used into main frame , MiniCss frequently tries to inject CSS stylesheets
As document is not available inside Web Worker, it crashes (no existence check)

Uncaught (in promise) ReferenceError: document is not defined
    at findStylesheet (src_workers_index_worker_ts.js:455:36)
    at src_workers_index_worker_ts.js:472:17
    at new Promise (<anonymous>)
    at loadStylesheet (src_workers_index_worker_ts.js:469:20)
    at __webpack_require__.f.miniCss (src_workers_index_worker_ts.js:485:58)
    at src_workers_index_worker_ts.js:95:40
    at Array.reduce (<anonymous>)
    at __webpack_require__.e (src_workers_index_worker_ts.js:94:67)

Expected Behavior

Document existence must be checked before injection test.

How Do We Reproduce?

Create a simple webworker as specified in https://webpack.js.org/guides/web-workers/
Try to import file taht contains CSS to check the crash

Please paste the results of npx webpack-cli info here, and mention other relevant information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions