-
-
Notifications
You must be signed in to change notification settings - Fork 556
/
_config.js
33 lines (31 loc) 路 849 Bytes
/
_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
const path = require('path');
const ID_MAIN = path.join(__dirname, 'main.js');
const ID_OTHER = path.join(__dirname, 'other.js');
module.exports = {
description: 'exposes cjs file type detection to other plugins',
options: {
input: [ID_MAIN, ID_OTHER],
plugins: [
{
moduleParsed({
id,
meta: {
commonjs: { isCommonJS }
}
}) {
if (id === ID_MAIN) {
if (isCommonJS !== false) {
throw new Error(
`Main file wrongly detected: isCommonJS === ${JSON.stringify(isCommonJS)}`
);
}
} else if (isCommonJS !== true) {
throw new Error(
`Other file wrongly detected: isCommonJS === ${JSON.stringify(isCommonJS)}`
);
}
}
}
]
}
};