Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a shallow copy when returning meta from resolveId (#4347)
- Loading branch information
1 parent
1d2ea22
commit 9e947fc
Showing
3 changed files
with
31 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,29 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const meta = { plugin: { initial: true } }; | ||
|
||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
module.exports = { | ||
description: 'does not modify meta objects passed in resolveId', | ||
options: { | ||
plugins: [ | ||
{ | ||
async resolveId(source, importer) { | ||
const { id } = await this.resolve(source, importer, { skipSelf: true }); | ||
return { id, meta }; | ||
}, | ||
transform(code) { | ||
return { code, meta: { otherPlugin: { ignored: true }, plugin: { replaced: true } } }; | ||
}, | ||
buildEnd() { | ||
assert.deepStrictEqual(meta, { plugin: { initial: true } }); | ||
assert.deepStrictEqual(this.getModuleInfo(ID_MAIN).meta, { | ||
otherPlugin: { ignored: true }, | ||
plugin: { replaced: true } | ||
}); | ||
} | ||
} | ||
] | ||
} | ||
}; |
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 @@ | ||
assert.ok(true); |