diff --git a/src/rollup/config.ts b/src/rollup/config.ts index 3af2024b1e..0bae6616e6 100644 --- a/src/rollup/config.ts +++ b/src/rollup/config.ts @@ -407,14 +407,14 @@ export const plugins = [ if (nitro.options.noExternals) { rollupConfig.plugins.push({ name: "no-externals", - async resolveId(id, from, options) { + async resolveId(id, from, resolveOpts) { if ( nitro.options.node && (id.startsWith("node:") || builtinModules.includes(id)) ) { return { id, external: true }; } - const resolved = await this.resolve(id, from, options); + const resolved = await this.resolve(id, from, resolveOpts); if (!resolved) { const _resolved = await resolvePath(id, { url: nitro.options.nodeModulesDirs, diff --git a/src/rollup/plugins/externals-legacy.ts b/src/rollup/plugins/externals-legacy.ts index be0dd201e0..5eb553a9d5 100644 --- a/src/rollup/plugins/externals-legacy.ts +++ b/src/rollup/plugins/externals-legacy.ts @@ -52,7 +52,7 @@ export function externals(opts: NodeExternalsOptions): Plugin { return { name: "node-externals", - async resolveId(originalId, importer, options) { + async resolveId(originalId, importer, resolveOpts) { // Skip internals if ( !originalId || @@ -86,7 +86,11 @@ export function externals(opts: NodeExternalsOptions): Plugin { } // Resolve id using rollup resolver - const resolved = (await this.resolve(originalId, importer, options)) || { + const resolved = (await this.resolve( + originalId, + importer, + resolveOpts + )) || { id, }; diff --git a/src/rollup/plugins/handlers-meta.ts b/src/rollup/plugins/handlers-meta.ts index 2b69cf423b..f2f3ddb8c1 100644 --- a/src/rollup/plugins/handlers-meta.ts +++ b/src/rollup/plugins/handlers-meta.ts @@ -18,12 +18,16 @@ const esbuildLoaders = { export function handlersMeta(nitro: Nitro) { return { name: "nitro:handlers-meta", - async resolveId(id) { + async resolveId(id, importer, resolveOpts) { if (id.startsWith("\0")) { return; } if (id.endsWith(`?meta`)) { - const resolved = await this.resolve(id.replace(`?meta`, ``)); + const resolved = await this.resolve( + id.replace(`?meta`, ``), + importer, + resolveOpts + ); if (!resolved) { return; } diff --git a/src/rollup/plugins/raw.ts b/src/rollup/plugins/raw.ts index 98345da3ee..d9ee2589c4 100644 --- a/src/rollup/plugins/raw.ts +++ b/src/rollup/plugins/raw.ts @@ -20,7 +20,7 @@ export function raw(opts: RawOptions = {}): Plugin { return { name: "raw", - async resolveId(id, importer) { + async resolveId(id, importer, resolveOpts) { if (id === HELPER_ID) { return id; } @@ -34,8 +34,7 @@ export function raw(opts: RawOptions = {}): Plugin { id = id.slice(4); } - const resolvedId = (await this.resolve(id, importer, { skipSelf: true })) - ?.id; + const resolvedId = (await this.resolve(id, importer, resolveOpts))?.id; if (!resolvedId || resolvedId.startsWith("\0")) { return resolvedId;