vite-plugin-svelte: npm run build retrieves `The argument 'filename' must be a file URL object, file URL string, or absolute path string`

Describe the bug

I’ve created a npm package that in development it works OK but when I run npm run build it retrieves the next error.

[vite-plugin-svelte] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
> The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'

Reproduction

This is the repo where this is happening.

https://github.com/silvestrevivo/solana-svelte-counter

I think it would be difficult to reproduce since you need to deploy the smart contract to run the project. With the SvelteKit version 251 this bug doesn’t occur. As soon as you upgrade SvelteKit, the error happens.

Logs

[vite-plugin-svelte] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
> The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '\x00__vite-browser-external?commonjs-proxy'
    at new NodeError (node:internal/errors:371:5)
    at createRequire (node:internal/modules/cjs/loader:1210:13)
    at resolveViaPackageJsonSvelte (file:///Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1427:26)
    at Object.resolveId (file:///Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:1585:24)
    at /Users/silvestrevivo/werk/2021/solana/solana-svelte-counter/app/node_modules/rollup/dist/shared/rollup.js:22795:37

System Info

.

Severity

annoyance

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 18 (5 by maintainers)

Commits related to this issue

Most upvoted comments

try, catch has been removed around resolveViaPackageJsonSvelte fn. Adding try catch seems to solve the error. Downgrade to @sveltejs/vite-plugin-svelte@1.0.0-next.37 to solve the issue for now