forked from rollup/rollup
/
_config.js
113 lines (110 loc) · 2.66 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const assert = require('assert');
const path = require('path');
const parsedModules = [];
const ID_MAIN = path.join(__dirname, 'main.js');
const ID_DEP = path.join(__dirname, 'dep.js');
module.exports = {
description: 'calls the moduleParsedHook once a module is parsed',
options: {
plugins: {
name: 'test-plugin',
moduleParsed(moduleInfo) {
parsedModules.push(moduleInfo);
},
buildEnd() {
assert.deepStrictEqual(JSON.parse(JSON.stringify(parsedModules)), [
{
ast: {
type: 'Program',
start: 0,
end: 34,
body: [
{
type: 'ExportNamedDeclaration',
start: 0,
end: 33,
declaration: null,
specifiers: [
{
type: 'ExportSpecifier',
start: 9,
end: 14,
local: { type: 'Identifier', start: 9, end: 14, name: 'value' },
exported: { type: 'Identifier', start: 9, end: 14, name: 'value' }
}
],
source: {
type: 'Literal',
start: 22,
end: 32,
value: './dep.js',
raw: "'./dep.js'"
}
}
],
sourceType: 'module'
},
code: "export { value } from './dep.js';\n",
dynamicallyImportedIds: [],
dynamicImporters: [],
hasModuleSideEffects: true,
id: ID_MAIN,
implicitlyLoadedAfterOneOf: [],
implicitlyLoadedBefore: [],
importedIds: [ID_DEP],
importers: [],
isEntry: true,
isExternal: false,
meta: {},
syntheticNamedExports: false
},
{
ast: {
type: 'Program',
start: 0,
end: 25,
body: [
{
type: 'ExportNamedDeclaration',
start: 0,
end: 24,
declaration: {
type: 'VariableDeclaration',
start: 7,
end: 24,
declarations: [
{
type: 'VariableDeclarator',
start: 13,
end: 23,
id: { type: 'Identifier', start: 13, end: 18, name: 'value' },
init: { type: 'Literal', start: 21, end: 23, value: 42, raw: '42' }
}
],
kind: 'const'
},
specifiers: [],
source: null
}
],
sourceType: 'module'
},
code: 'export const value = 42;\n',
dynamicallyImportedIds: [],
dynamicImporters: [],
hasModuleSideEffects: true,
id: ID_DEP,
implicitlyLoadedAfterOneOf: [],
implicitlyLoadedBefore: [],
importedIds: [],
importers: [ID_MAIN],
isEntry: false,
isExternal: false,
meta: {},
syntheticNamedExports: false
}
]);
}
}
}
};