-
-
Notifications
You must be signed in to change notification settings - Fork 556
/
_config.js
37 lines (33 loc) 路 1.22 KB
/
_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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]);
}
}
]
}
};