Skip to content

Commit cab28b5

Browse files
committedJan 29, 2019
fix: passing parentId to externals
1 parent 448f921 commit cab28b5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
 

‎src/plugins/node-resolve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default (options: Options) => {
6161
}
6262
}
6363

64-
if (isExternal(options.externals, id)) {
64+
if (isExternal(options.externals, id, importer)) {
6565
return false
6666
}
6767

‎src/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export type Env = {
1515
[k: string]: string | number | boolean
1616
}
1717

18-
type External = string | RegExp | ((id: string) => boolean)
18+
export type External =
19+
| string
20+
| RegExp
21+
| ((id: string, parentId?: string) => boolean)
1922

2023
export type Externals = Array<External>
2124

‎src/utils/is-external.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import slash from 'slash'
22
import { NormalizedConfig } from '../'
33

4-
export default function(externals: NormalizedConfig['externals'], id: string) {
4+
export default function(
5+
externals: NormalizedConfig['externals'],
6+
id: string,
7+
parentId?: string
8+
) {
59
id = slash(id)
610

711
if (!Array.isArray(externals)) {
@@ -21,7 +25,7 @@ export default function(externals: NormalizedConfig['externals'], id: string) {
2125
}
2226
}
2327
if (typeof external === 'function') {
24-
if (external(id)) {
28+
if (external(id, parentId)) {
2529
return true
2630
}
2731
}

0 commit comments

Comments
 (0)
Please sign in to comment.