sapphi-red / vite-plugin-static-copy

rollup-plugin-copy with dev server support.
MIT License
287 stars 31 forks source link

The entire module stopped working #71

Closed JasminDreasond closed 11 months ago

JasminDreasond commented 11 months ago

I made this update progress: Bump vite-plugin-static-copy from 0.17.1 to 1.0.0

"@vitejs/plugin-react": "4.2.1",
"vite": "5.0.7",
"vite-plugin-electron": "^0.15.4",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-plugin-static-copy": "1.0.0"

Now the module no longer loads on Vite in any way.

vite.config.js:4:31:
      4 │ import { viteStaticCopy } from 'vite-plugin-static-copy';

Error: Build failed with 1 error:
node_modules/esbuild/lib/main.js:1373:27: ERROR: [plugin: externalize-deps] "vite-plugin-static-copy" resolved to an ESM file. ESM file cannot be loaded by `require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.

When I downgraded, everything went back to normal. So the problem is in the version 1.0.0

sapphi-red commented 11 months ago

1.0.0+ is ESM only. See the link in the error messsage.

JasminDreasond commented 11 months ago

But I'm using an ES environment. Your module thinks I'm not in an ES environment. I am natively using Vite's own environment.

JasminDreasond commented 11 months ago

I renamed the file vite.config.js to vite.config.mjs and this is working now. Your module was using the file name as a reference to know if it was an ESM or not.