Skip to content

Commit

Permalink
fix: update vite externals config
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jul 1, 2022
1 parent 837af6a commit 11bdafe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export const setupTranspile = () => {
]
.map(m => typeof m === 'string' ? m : Array.isArray(m) ? m[0] : m.src)
.filter(m => typeof m === 'string')
.map(m => m.split('node_modules/').pop())
.map(m => m.split(/node_modules[\\/]/g).pop())

// Try to sanitize modules to better match imports
nuxt.options.build.transpile =
nuxt.options.build.transpile.map(m => typeof m === 'string' ? m.split('node_modules/').pop()! : m)
nuxt.options.build.transpile.map(m => typeof m === 'string' ? m.split(/node_modules[\\/]/g).pop()! : m)

function isTranspilePresent (mod: string) {
return nuxt.options.build.transpile.some(t => !(t instanceof Function) && (t instanceof RegExp ? t.test(mod) : new RegExp(t).test(mod)))
Expand Down
8 changes: 5 additions & 3 deletions src/vite/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ export async function buildServer (ctx: ViteBuildContext) {
},
ssr: {
external: [
'axios'
'axios',
'#internal/nitro/utils',
'#internal/nitro'
],
noExternal: [
// TODO: Use externality for production (rollup) build
/\/esm\/.*\.js$/,
/\.(es|esm|esm-browser|esm-bundler).js$/,
'#app',
/@nuxt\/nitro\/(dist|src)/,
/nitropack\/(dist|src)/,
...ctx.nuxt.options.build.transpile.filter(i => typeof i === 'string')
]
},
Expand All @@ -58,7 +60,7 @@ export async function buildServer (ctx: ViteBuildContext) {
ssr: ctx.nuxt.options.ssr ?? true,
ssrManifest: true,
rollupOptions: {
external: ['#nitro'],
external: ['#internal/nitro/utils', '#internal/nitro'],
input: resolve(ctx.nuxt.options.buildDir, 'server.js'),
output: {
entryFileNames: 'server.mjs',
Expand Down

0 comments on commit 11bdafe

Please sign in to comment.