mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
fix(vite): pass modulesDir to isExternal
(#21966)
This commit is contained in:
parent
d590c85c35
commit
1605a532a1
@ -229,7 +229,7 @@ export async function initViteDevBundler (ctx: ViteBuildContext, onBuild: () =>
|
||||
const viteServer = ctx.ssrServer!
|
||||
const options: TransformOptions = {
|
||||
viteServer,
|
||||
isExternal: createIsExternal(viteServer, ctx.nuxt.options.rootDir)
|
||||
isExternal: createIsExternal(viteServer, ctx.nuxt.options.rootDir, ctx.nuxt.options.modulesDir)
|
||||
}
|
||||
|
||||
// Build and watch
|
||||
|
@ -2,7 +2,7 @@ import type { ExternalsOptions } from 'externality'
|
||||
import { ExternalsDefaults, isExternal } from 'externality'
|
||||
import type { ViteDevServer } from 'vite'
|
||||
|
||||
export function createIsExternal (viteServer: ViteDevServer, rootDir: string) {
|
||||
export function createIsExternal (viteServer: ViteDevServer, rootDir: string, modulesDirs?: string[]) {
|
||||
const externalOpts: ExternalsOptions = {
|
||||
inline: [
|
||||
/virtual:/,
|
||||
@ -15,6 +15,7 @@ export function createIsExternal (viteServer: ViteDevServer, rootDir: string) {
|
||||
/node_modules/
|
||||
],
|
||||
resolve: {
|
||||
modules: modulesDirs,
|
||||
type: 'module',
|
||||
extensions: ['.ts', '.js', '.json', '.vue', '.mjs', '.jsx', '.tsx', '.wasm']
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ function createViteNodeApp (ctx: ViteBuildContext, invalidates: Set<string> = ne
|
||||
web: []
|
||||
}
|
||||
})
|
||||
const isExternal = createIsExternal(viteServer, ctx.nuxt.options.rootDir)
|
||||
const isExternal = createIsExternal(viteServer, ctx.nuxt.options.rootDir, ctx.nuxt.options.modulesDir)
|
||||
node.shouldExternalize = async (id: string) => {
|
||||
const result = await isExternal(id)
|
||||
if (result?.external) {
|
||||
|
Loading…
Reference in New Issue
Block a user