Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rollup): pass options to resolve #2842

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions src/rollup/plugins/externals-legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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,
};

Expand Down
8 changes: 6 additions & 2 deletions src/rollup/plugins/handlers-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions src/rollup/plugins/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down