Skip to content

Import issue in Webpack 5 #71

@rafaucau

Description

@rafaucau

I encountered an issue while using your package with Webpack 5 in my project. The problem is related to the export statement in the index.js file:

export { toast } from './stores'

In Webpack 5, fully specified paths are required for ESM modules. The export statement is missing the file extension, which causes an error:

ERROR in ../../../node_modules/@zerodevx/svelte-toast/index.js 2:0-32
Module not found: Error: Can't resolve './stores' in '********node_modules/@zerodevx/svelte-toast'
Did you mean 'stores.js'?
BREAKING CHANGE: The request './stores' 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.
resolve './stores' in '********node_modules/@zerodevx/svelte-toast'
  using description file: ********node_modules/@zerodevx/svelte-toast/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: ********node_modules/@zerodevx/svelte-toast/package.json (relative path: ./stores)
      Field 'browser' doesn't contain a valid alias configuration
      ********node_modules/@zerodevx/svelte-toast/stores doesn't exist
 @ ./src/js/post/components/ReportContent.svelte 38:0-60 208:19-30 666:2-13 667:2-7
 @ ./src/js/post/index.ts 61:4-47

To resolve this issue, I suggest changing the export statement in the index.js file to include the .js file extension:

export { toast } from './stores.js'

I tried to configure Webpack to handle this issue on my end, but I still encounter the error. It would be great if you could apply the suggested fix to the package.

When I modified the index.js file manually in the node_modules folder, it works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions