-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also pass resolved ids to external if they use the object form (#3753)
- Loading branch information
1 parent
7e2cbc5
commit 21fcec3
Showing
3 changed files
with
56 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const assert = require('assert'); | ||
|
||
const testedIds = []; | ||
|
||
module.exports = { | ||
description: 'passes both unresolved and resolved ids to the external option', | ||
context: { | ||
require() { | ||
return true; | ||
} | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
resolvedExternal: true, | ||
resolvedObject: true, | ||
resolvedObjectExternal: true, | ||
resolvedString: true | ||
}); | ||
assert.deepStrictEqual(testedIds, [ | ||
'resolve-string', | ||
'resolve-external', | ||
'resolve-object', | ||
'resolve-object-external', | ||
'resolved-string', | ||
'resolved-object' | ||
]); | ||
}, | ||
options: { | ||
external(id) { | ||
testedIds.push(id); | ||
return id.startsWith('resolved'); | ||
}, | ||
plugins: { | ||
name: 'test-plugin', | ||
resolveId(source) { | ||
switch (source) { | ||
case 'resolve-string': | ||
return 'resolved-string'; | ||
case 'resolve-external': | ||
return false; | ||
case 'resolve-object': | ||
return { id: 'resolved-object', external: false }; | ||
case 'resolve-object-external': | ||
return { id: 'resolved-object-external', external: true }; | ||
default: | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
}; |
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,4 @@ | ||
export {default as resolvedString} from 'resolve-string'; | ||
export {default as resolvedExternal} from 'resolve-external'; | ||
export {default as resolvedObject} from 'resolve-object'; | ||
export {default as resolvedObjectExternal} from 'resolve-object-external'; |