mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25: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 viteServer = ctx.ssrServer!
|
||||||
const options: TransformOptions = {
|
const options: TransformOptions = {
|
||||||
viteServer,
|
viteServer,
|
||||||
isExternal: createIsExternal(viteServer, ctx.nuxt.options.rootDir)
|
isExternal: createIsExternal(viteServer, ctx.nuxt.options.rootDir, ctx.nuxt.options.modulesDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build and watch
|
// Build and watch
|
||||||
|
@ -2,7 +2,7 @@ import type { ExternalsOptions } from 'externality'
|
|||||||
import { ExternalsDefaults, isExternal } from 'externality'
|
import { ExternalsDefaults, isExternal } from 'externality'
|
||||||
import type { ViteDevServer } from 'vite'
|
import type { ViteDevServer } from 'vite'
|
||||||
|
|
||||||
export function createIsExternal (viteServer: ViteDevServer, rootDir: string) {
|
export function createIsExternal (viteServer: ViteDevServer, rootDir: string, modulesDirs?: string[]) {
|
||||||
const externalOpts: ExternalsOptions = {
|
const externalOpts: ExternalsOptions = {
|
||||||
inline: [
|
inline: [
|
||||||
/virtual:/,
|
/virtual:/,
|
||||||
@ -15,6 +15,7 @@ export function createIsExternal (viteServer: ViteDevServer, rootDir: string) {
|
|||||||
/node_modules/
|
/node_modules/
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
modules: modulesDirs,
|
||||||
type: 'module',
|
type: 'module',
|
||||||
extensions: ['.ts', '.js', '.json', '.vue', '.mjs', '.jsx', '.tsx', '.wasm']
|
extensions: ['.ts', '.js', '.json', '.vue', '.mjs', '.jsx', '.tsx', '.wasm']
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ function createViteNodeApp (ctx: ViteBuildContext, invalidates: Set<string> = ne
|
|||||||
web: []
|
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) => {
|
node.shouldExternalize = async (id: string) => {
|
||||||
const result = await isExternal(id)
|
const result = await isExternal(id)
|
||||||
if (result?.external) {
|
if (result?.external) {
|
||||||
|
Loading…
Reference in New Issue
Block a user