-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
_config.js
72 lines (70 loc) · 2.6 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const assert = require('assert');
const path = require('path');
const ID_MAIN = path.join(__dirname, 'main.js');
module.exports = {
description: 'sends correct isEntry information to resolveId hooks',
options: {
plugins: [
{
async buildStart() {
return Promise.all([
this.emitFile({ type: 'chunk', id: 'chunkWithoutImporter.js' }),
this.emitFile({ type: 'chunk', id: './chunkWithImporter.js', importer: ID_MAIN }),
this.resolve('./resolutionWithoutImporter'),
this.resolve('./resolutionWithoutImporterEntry', undefined, { isEntry: true }),
this.resolve('./resolutionWithoutImporterNonEntry', undefined, { isEntry: false }),
this.resolve('./resolutionWithImporter', ID_MAIN),
this.resolve('./resolutionWithImporterEntry', ID_MAIN, { isEntry: true }),
this.resolve('./resolutionWithImporterNonEntry', ID_MAIN, { isEntry: false })
]);
},
resolveId(source, importer, { isEntry }) {
switch (source) {
case ID_MAIN:
assert.strictEqual(importer, undefined, source);
assert.strictEqual(isEntry, true, source);
break;
case './dep.js':
assert.strictEqual(importer, ID_MAIN, source);
assert.strictEqual(isEntry, false, source);
break;
case 'chunkWithoutImporter.js':
assert.strictEqual(importer, undefined, source);
assert.strictEqual(isEntry, true, source);
break;
case './chunkWithImporter.js':
assert.strictEqual(importer, ID_MAIN, source);
assert.strictEqual(isEntry, true, source);
break;
case './resolutionWithoutImporter':
assert.strictEqual(importer, undefined, source);
assert.strictEqual(isEntry, true, source);
break;
case './resolutionWithoutImporterEntry':
assert.strictEqual(importer, undefined, source);
assert.strictEqual(isEntry, true, source);
break;
case './resolutionWithoutImporterNonEntry':
assert.strictEqual(importer, undefined, source);
assert.strictEqual(isEntry, false, source);
break;
case './resolutionWithImporter':
assert.strictEqual(importer, ID_MAIN, source);
assert.strictEqual(isEntry, false, source);
break;
case './resolutionWithImporterEntry':
assert.strictEqual(importer, ID_MAIN, source);
assert.strictEqual(isEntry, true, source);
break;
case './resolutionWithImporterNonEntry':
assert.strictEqual(importer, ID_MAIN, source);
assert.strictEqual(isEntry, false, source);
break;
default:
throw new Error(`Unexpected resolution of ${source}`);
}
}
}
]
}
};