-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node-resolve): pass on isEntry flag (#1016)
- Loading branch information
1 parent
cfb4555
commit 12e1fee
Showing
14 changed files
with
192 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ export function nodeResolve(opts = {}) { | |
const browserMapCache = new Map(); | ||
let preserveSymlinks; | ||
|
||
const doResolveId = async (context, importee, importer, opts) => { | ||
const doResolveId = async (context, importee, importer, custom) => { | ||
// strip query params from import | ||
const [importPath, params] = importee.split('?'); | ||
const importSuffix = `${params ? `?${params}` : ''}`; | ||
|
@@ -142,8 +142,7 @@ export function nodeResolve(opts = {}) { | |
} | ||
|
||
const warn = (...args) => context.warn(...args); | ||
const isRequire = | ||
opts && opts.custom && opts.custom['node-resolve'] && opts.custom['node-resolve'].isRequire; | ||
const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire; | ||
const exportConditions = isRequire ? conditionsCjs : conditionsEsm; | ||
|
||
if (useBrowserOverrides && !exportConditions.includes('browser')) | ||
|
@@ -250,7 +249,7 @@ export function nodeResolve(opts = {}) { | |
isDirCached.clear(); | ||
}, | ||
|
||
async resolveId(importee, importer, opts) { | ||
async resolveId(importee, importer, resolveOptions) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return importee; | ||
} | ||
|
@@ -261,9 +260,13 @@ export function nodeResolve(opts = {}) { | |
importer = undefined; | ||
} | ||
|
||
const resolved = await doResolveId(this, importee, importer, opts); | ||
const resolved = await doResolveId(this, importee, importer, resolveOptions.custom); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lukastaegert
Author
Member
|
||
if (resolved) { | ||
const resolvedResolved = await this.resolve(resolved.id, importer, { skipSelf: true }); | ||
const resolvedResolved = await this.resolve( | ||
resolved.id, | ||
importer, | ||
Object.assign({ skipSelf: true }, resolveOptions) | ||
); | ||
const isExternal = !!(resolvedResolved && resolvedResolved.external); | ||
if (isExternal) { | ||
return false; | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './dep.js'; | ||
|
||
console.log('main'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('other'); |
2 changes: 2 additions & 0 deletions
2
packages/node-resolve/test/fixtures/root-package-side-effect/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
import './side-effect.js'; | ||
|
||
console.log('main'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.
What if
resolveOptions
isundefined
? Won'tresolveOptions.custom
be anundefined
property access?