-
-
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(commonjs): pass on isEntry and custom resolve options (#1018)
Co-authored-by: shellscape <[email protected]>
- Loading branch information
1 parent
dbfb996
commit d59088e
Showing
11 changed files
with
692 additions
and
616 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
37 changes: 37 additions & 0 deletions
37
packages/commonjs/test/fixtures/function/custom-options/_config.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
|
||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
const getLastPathFragment = (pathString) => pathString && pathString.split(/[\\/]/).slice(-1)[0]; | ||
|
||
const resolveIdArgs = []; | ||
|
||
module.exports = { | ||
description: 'passes on isEntry and custom options when resolving via other plugins', | ||
options: { | ||
plugins: [ | ||
{ | ||
async buildStart() { | ||
await this.resolve('./other.js', ID_MAIN, { isEntry: true, custom: { test: 42 } }); | ||
}, | ||
buildEnd() { | ||
assert.deepStrictEqual(resolveIdArgs, [ | ||
['other.js', 'main.js', { custom: { test: 42 }, isEntry: true }], | ||
[ | ||
'other.js', | ||
'main.js', | ||
// This is the important one | ||
{ custom: { test: 42, 'node-resolve': { isRequire: false } }, isEntry: true } | ||
], | ||
['main.js', void 0, { custom: {}, isEntry: true }], | ||
['main.js', void 0, { custom: { 'node-resolve': { isRequire: false } }, isEntry: true }] | ||
]); | ||
}, | ||
resolveId(source, importer, options) { | ||
resolveIdArgs.push([getLastPathFragment(source), getLastPathFragment(importer), options]); | ||
} | ||
} | ||
] | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/custom-options/main.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('main'); |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/custom-options/other.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('other'); |
Oops, something went wrong.