Skip to content

Webpack complains about strict ESM module and requires import clause with .js suffix #731

Closed
@Shellishack

Description

@Shellishack

Hi,

Thanks for the community's hard work on solving issues around ESM/CJS interpretation.

I noticed these build errors on my side since @uiw/react-codemirror4.23.10. Updating to 4.23.11 to adapt #729 doesn't seem to solve the problem. I am using Webpack along with React and ESM.

ERROR in ./node_modules/@uiw/react-codemirror/esm/index.js 5:0-48
Module not found: Error: Can't resolve './useCodeMirror' in 'C:\GitHub\pulse-editor-code-view\node_modules\@uiw\react-codemirror\esm'
Did you mean 'useCodeMirror.js'?
BREAKING CHANGE: The request './useCodeMirror' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./src/component/code-editor-view.tsx
 @ ./src/main.tsx 3:0-58 13:31-45

ERROR in ./node_modules/@uiw/react-codemirror/esm/index.js 11:0-39
Module not found: Error: Can't resolve './getDefaultExtensions' in 'C:\GitHub\pulse-editor-code-view\node_modules\@uiw\react-codemirror\esm'
Did you mean 'getDefaultExtensions.js'?
BREAKING CHANGE: The request './getDefaultExtensions' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./src/component/code-editor-view.tsx
 @ ./src/main.tsx 3:0-58 13:31-45

ERROR in ./node_modules/@uiw/react-codemirror/esm/index.js 12:0-24
Module not found: Error: Can't resolve './utils' in 'C:\GitHub\pulse-editor-code-view\node_modules\@uiw\react-codemirror\esm'     
Did you mean 'utils.js'?
BREAKING CHANGE: The request './utils' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./src/component/code-editor-view.tsx
 @ ./src/main.tsx 3:0-58 13:31-45

Workaround:
As #680 (comment) pointed out, rolling back to 4.23.8 worked for me.

I am happy to help, but I am reletively new to this community so please enlighten me if devs can look into this. A possible direction to look into might be some bugs introduced between 4.23.8 to 4.23.10

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