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

feat(node-resolve): pass original importee to secondary resolve #1557

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export function nodeResolve(opts = {}) {
// `moduleSideEffects` information.
const resolvedResolved = await this.resolve(resolved.id, importer, {
...resolveOptions,
custom: { ...custom, 'node-resolve': { ...custom['node-resolve'], resolved } }
custom: { ...custom, 'node-resolve': { ...custom['node-resolve'], resolved, importee } }
});
if (resolvedResolved) {
// Handle plugins that manually make the result external
Expand Down
18 changes: 12 additions & 6 deletions packages/node-resolve/test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ test('marks a module as external if the resolved version is external', async (t)
});
});

test('passes on "isEntry" flag', async (t) => {
test('passes on "isEntry" flag and original importee', async (t) => {
const resolveOptions = [];
await rollup({
input: 'entry/main.js',
Expand All @@ -561,6 +561,7 @@ test('passes on "isEntry" flag', async (t) => {
}
]
});

t.deepEqual(resolveOptions, [
['other.js', 'main.js', { assertions: {}, custom: {}, isEntry: true }],
['main.js', void 0, { assertions: {}, custom: {}, isEntry: true }],
Expand All @@ -574,7 +575,8 @@ test('passes on "isEntry" flag', async (t) => {
resolved: {
id: join(DIRNAME, 'fixtures', 'entry', 'other.js'),
moduleSideEffects: null
}
},
importee: './other.js'
}
},
isEntry: true
Expand All @@ -590,7 +592,8 @@ test('passes on "isEntry" flag', async (t) => {
resolved: {
id: join(DIRNAME, 'fixtures', 'entry', 'main.js'),
moduleSideEffects: null
}
},
importee: 'entry/main.js'
}
},
isEntry: true
Expand All @@ -607,7 +610,8 @@ test('passes on "isEntry" flag', async (t) => {
resolved: {
id: join(DIRNAME, 'fixtures', 'entry', 'dep.js'),
moduleSideEffects: null
}
},
importee: './dep.js'
}
},
isEntry: false
Expand Down Expand Up @@ -651,7 +655,8 @@ test('passes on custom options', async (t) => {
resolved: {
id: join(DIRNAME, 'fixtures', 'entry', 'main.js'),
moduleSideEffects: null
}
},
importee: 'entry/main.js'
}
},
isEntry: false
Expand All @@ -668,7 +673,8 @@ test('passes on custom options', async (t) => {
resolved: {
id: join(DIRNAME, 'fixtures', 'entry', 'other.js'),
moduleSideEffects: null
}
},
importee: 'entry/other.js'
}
},
isEntry: true
Expand Down
Loading