-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
88 lines (81 loc) · 2.06 KB
/
rollup.config.js
File metadata and controls
88 lines (81 loc) · 2.06 KB
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
import terser from '@rollup/plugin-terser';
import { babel } from '@rollup/plugin-babel';
import { createEs2015LinkerPlugin } from '@angular/compiler-cli/linker/babel';
import {
ConsoleLogger,
NodeJSFileSystem,
LogLevel,
} from '@angular/compiler-cli';
import { angularPackages } from './rollup/angular-packages.js';
/** File system used by the Angular linker plugin. */
const fileSystem = new NodeJSFileSystem();
/** Logger used by the Angular linker plugin. */
const logger = new ConsoleLogger(LogLevel.info);
/**
* The linker plugin is used to make output files AOT compatible, so they don't
* require the `@angular/compiler` at runtime.
*/
const linkerPlugin = createEs2015LinkerPlugin({
fileSystem,
logger,
linkerJitMode: false,
});
const configs = angularPackages.map(
({ name, input, outputFile, packageJson, external }) => {
return [
[false, 'system'],
[true, 'system'],
[false, 'es'],
[true, 'es'],
].map(([prod, format]) =>
createConfig({
name,
input,
outputFile,
packageJson,
external,
prod,
format,
}),
);
},
);
function createConfig({
name,
input,
outputFile,
packageJson,
external,
prod,
format,
}) {
const dir = (format === 'es' ? '.' : format) + `/es2022`;
return {
input,
output: {
file: `${dir}/${outputFile}.${prod ? 'min.' : ''}js`,
format,
sourcemap: true,
banner: `/* esm-bundle - ${name}@${packageJson.version} - ${format} format - Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license */`,
},
plugins: [
babel({ plugins: [linkerPlugin] }),
prod &&
terser({
format: {
ecma: '2022',
comments: /esm-bundle/,
},
compress: {
global_defs: {
ngJitMode: false,
ngDevMode: false,
ngI18nClosureMode: false,
},
},
}),
],
external,
};
}
export default configs.flat();