Skip to content

Experiments.css reliance on fact that css should be loaded before js is a huge breaking change #17611

@IdeaHunter

Description

@IdeaHunter

Bug report/breaking change

Im trying experimental feature: #14893

Imagine you have following code
index.js:

import './index.css'
addEventListener("DOMContentLoaded", (event) => {
     //do something useful here
})

index.html:

<!DOCTYPE html>
<html>
    <head>
        <script src="./main.js"></script>
        <link rel="stylesheet" href="./main.css"></link>
    </head>
    <body>

    </body>
</html>

What is the current behavior?
This code would fail:

Uncaught TypeError: __webpack_modules__[moduleId] is not a function
    at __webpack_require__

If the current behavior is a bug, please provide the steps to reproduce.
Here I made a repo to reproduce:

  1. Clone https://github.com/IdeaHunter/webpack-serve-css-modules-repro
  2. yarn install
  3. yarn webpack or yarn webpack serve

What is the expected behavior?
No error should happen or if its intended behavior there should be a friendly error message and there should be a breaking change entry in migration docs for webpack 6

Other relevant information:
webpack version: 5.88.2
Node.js version: 18.16.0
Operating System: windows
Additional tools: yarn

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions