Skip to content

[webpack v5] Uncaught (in promise) ReferenceError: exports is not defined #12040

@sukano

Description

@sukano

Do you want to request a feature or report a bug?
A bug.

What is the current behavior?
I got this error since I updated webpack from v5.0.0-beta.25 to v5.6.0.

image

It happens when the browser want to load a CommonJS module/library.

image

If I add <script>var exports = {};</script> to my index.html file, this is the require function who is not defined.

If the current behavior is a bug, please provide the steps to reproduce.
I can't provide access to source code because is a companie project but I can provide the configuration.
https://gist.github.com/sukano/10a9cafc90e7e6b8591dd4f665c648ed

What is the expected behavior?
He should provide CommonJS capacity to load module.

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
This bug seems appear since v5.0.0-beta.26.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions