Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cjs build of vite node server #6389

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/vite-node/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const external = [
'node:events',
'node:vm',
]
const esmOnly = [
Copy link
Member

@sheremet-va sheremet-va Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be moved to devDependencies to be bundled, not just filtered. Otherwise consumers of CJS package will install a package that's not being used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be moved to devDependencies to be bundled, not just filtered. Otherwise consumers of CJS package will install a package that's not being used

Just check the bundle artifacts, it is ok, because rollup-plugin-esbuild bundle it, and the esm build still use the original dependency, only cjs build use the bundled version.

But move to devDependency maybe a better approach.

'tinyrainbow',
]

const plugins = [
resolve({
Expand Down Expand Up @@ -68,7 +71,7 @@ export default defineConfig([
entryFileNames: '[name].cjs',
chunkFileNames: 'chunk-[name].cjs',
},
external,
external: external.filter(v => !esmOnly.includes(v)),
plugins,
onwarn,
},
Expand Down
Loading