Closed AllySummers closed 2 months ago
Thanks for reporting this issue. It's the same problem that has been raised here: https://github.com/vitejs/vite/issues/5694
I suppose it has something to do with TSUP bundling the default export from my source file:
export default entrypoints;
as
var src_default = entrypoints;
export {
src_default as default
};
in the build output. This seems to cause trouble when using an ESM default import in vite.config.mjs
. The function is then only available as default
property on the imported identifier which is not how it's supposed to be.
I've followed your suggestion and added conditional exports to package.json
. Taking a look at the Vite plugin checker
from the issue linked at the top they've also included such exports directives.
I've released the new version 2.0.0 and as far as I've tested it, should work with your project setup.
Awesome, thanks for that quick fix!
Hi,
I've tried to use this package in a simple library and I've come across an issue with module resolution due to the
package.json
file with ESM module resolution, despite typescript being satisfied with the types.Node version:
v18.20.1
Using Windows 10I've made a repro here: https://github.com/AllySummers/vite-plugin-entrypoints-repro
Even just running
node
on the file doesn't work because the export cannot be resolved, however using CJS works (despite vite's CJS API being deprecated, at least in v5).Log of error
``` PS C:\node\vite-plugin-entrypoints-repro> npm run test1 > vite-plugin-entrypoints-repro@1.0.0 test1 > node vite.config.cjs The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. C:\node\vite-plugin-entrypoints-repro\node_modules\vite-plugin-entrypoints\dist\index.js:2 import { glob } from "glob"; ^^^^^^ SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:76:18) at wrapSafe (node:internal/modules/cjs/loader:1283:20) at Module._compile (node:internal/modules/cjs/loader:1328:27) at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) at Module.load (node:internal/modules/cjs/loader:1203:32) at Module._load (node:internal/modules/cjs/loader:1019:12) at Module.require (node:internal/modules/cjs/loader:1231:19) at require (node:internal/modules/helpers:177:18) at Object.I noticed adding this to the
package.json
fixed the error, however I'm not sure if this would be considered a breaking change: