-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
rollup.config.js
109 lines (107 loc) · 3.29 KB
/
rollup.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
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
const replace = require('./rollup-plugin/replace');
module.exports = {
input: 'src/linter/linter.js',
output: {
format: 'amd',
interop: 'auto',
freeze: false,
sourcemap: true,
file: 'dist/index.js',
},
external: ['vs/language/typescript/tsWorker'],
plugins: [
terser({
keep_classnames: true,
}),
replace({
// verbose: true,
alias: [
{
// those files should be omitted, we do not want them to be exposed to web
match: [
/eslint\/lib\/(rule-tester|eslint|cli-engine|init)\//u,
/eslint\/lib\/cli\.js$/,
/utils\/dist\/eslint-utils\/RuleTester\.js$/,
/utils\/dist\/ts-eslint\/CLIEngine\.js$/,
/utils\/dist\/ts-eslint\/RuleTester\.js$/,
/typescript-estree\/dist\/create-program\/createWatchProgram\.js/,
/typescript-estree\/dist\/create-program\/createProjectProgram\.js/,
/typescript-estree\/dist\/create-program\/createIsolatedProgram\.js/,
/utils\/dist\/ts-eslint\/ESLint\.js/,
// 'eslint/lib/shared/ajv.js',
// 'eslint/lib/shared/runtime-info.js',
],
target: './src/mock/empty.js',
},
{
// use window.ts instead of bundling typescript
match: /typescript$/u,
target: './src/mock/typescript.js',
},
{
// assert for web
match: /^assert$/u,
target: './src/mock/assert.js',
},
{
// path for web
match: /^path$/u,
target: './src/mock/path.js',
},
{
// util for web
match: /^util$/u,
target: './src/mock/util.js',
},
{
// semver simplified, solve issue with circular dependencies
match: /semver$/u,
target: './src/mock/semver.js',
},
],
replace: [
{
// we do not want dynamic imports
match: /eslint\/lib\/linter\/rules\.js$/u,
test: /require\(this\._rules\[ruleId\]\)/u,
replace: 'null',
},
{
// esquery has both browser and node versions, we are bundling browser version that has different export
test: /esquery\.parse\(/u,
replace: 'esquery.default.parse(',
},
{
// esquery has both browser and node versions, we are bundling browser version that has different export
test: /esquery\.matches\(/u,
replace: 'esquery.default.matches(',
},
{
// replace all process.env.NODE_DEBUG with false
test: /process\.env\.NODE_DEBUG/u,
replace: 'false',
},
{
// replace all process.env.TIMING with false
test: /process\.env\.TIMING/u,
replace: 'false',
},
{
// replace all process.env.IGNORE_TEST_WIN32 with true
test: /process\.env\.IGNORE_TEST_WIN32/u,
replace: 'true',
},
],
}),
resolve({
browser: true,
preferBuiltins: false,
}),
commonjs(),
json({ preferConst: true }),
],
};