Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

perf(vite): do not resolve module field for packages #2636

Merged
merged 5 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
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/bridge/src/vite/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export async function buildServer (ctx: ViteBuildContext) {
},
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite/server'),
resolve: {
alias
alias,
// By default Vite resolves `module` field, which not always a native ESM module
// Setting this option can bypass that and fallback to cjs version
mainFields: ctx.nuxt.options.dev ? ['main'] : undefined
pi0 marked this conversation as resolved.
Show resolved Hide resolved
},
ssr: {
external: [
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export async function buildServer (ctx: ViteBuildContext) {
'@vue/shared': _resolve(`@vue/shared/dist/shared.cjs${ctx.nuxt.options.dev ? '' : '.prod'}.js`),
'vue-router': _resolve(`vue-router/dist/vue-router.cjs${ctx.nuxt.options.dev ? '' : '.prod'}.js`),
vue: _resolve(`vue/dist/vue.cjs${ctx.nuxt.options.dev ? '' : '.prod'}.js`)
}
},
// By default Vite resolves `module` field, which not always a native ESM module
// Setting this option can bypass that and fallback to cjs version
pi0 marked this conversation as resolved.
Show resolved Hide resolved
mainFields: ctx.nuxt.options.dev ? ['main'] : undefined
},
ssr: {
external: [],
Expand Down