/
_config.js
45 lines (43 loc) · 1.27 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
const assert = require('assert');
const path = require('path');
module.exports = {
description: 'reports if a module has a default export',
options: {
plugins: [
{
async buildStart() {
const ID_MAIN = path.join(__dirname, 'main.js');
const loadMain = this.load({ id: ID_MAIN });
assert.strictEqual(this.getModuleInfo(ID_MAIN).hasDefaultExport, null);
assert.strictEqual((await loadMain).hasDefaultExport, false);
assert.strictEqual(
(await this.load({ id: path.join(__dirname, 'direct.js') })).hasDefaultExport,
true,
'direct'
);
assert.strictEqual(
(await this.load({ id: path.join(__dirname, 'indirect.js') })).hasDefaultExport,
true,
'indirect'
);
assert.strictEqual(
(await this.load({ id: path.join(__dirname, 'reexport1.js') })).hasDefaultExport,
true,
'reexport'
);
assert.strictEqual(
(await this.load({ id: path.join(__dirname, 'reexport2.js') })).hasDefaultExport,
true,
'renamed reexport'
);
},
load(id) {
assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `load ${id}`);
},
transform(code, id) {
assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `transform ${id}`);
}
}
]
}
};