forked from handsontable/handsontable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
109 lines (107 loc) · 3 KB
/
babel.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
const allowedE2EModules = [
'window',
'jasmine-co',
'jest-matcher-utils',
'html-parse-stringify',
'core-js/*',
'regenerator-runtime/runtime*',
'@babel/runtime/*',
'./htmlNormalize',
'./common',
'./mouseEvents',
'./../bootstrap',
'./helpers/custom-matchers',
'./asciiTable',
'./MemoryLeakTest',
'../MemoryLeakTest',
];
const babelPresetConfig = () => ({
targets: {
chrome: '41',
firefox: '34',
ie: '9',
safari: '9'
},
modules: false,
debug: false,
useBuiltIns: 'usage',
corejs: 3,
});
module.exports = {
presets: [
['@babel/preset-env', babelPresetConfig()]
],
plugins: [
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
['transform-inline-environment-variables'],
['@babel/plugin-proposal-class-properties']
],
env: {
// Environment for unit testing, source code and languages building via webpack (UMD).
commonjs: {
plugins: [
['@babel/plugin-transform-runtime', {
corejs: false,
helpers: true,
regenerator: true,
useESModules: false,
}],
['@babel/plugin-transform-modules-commonjs', { loose: true }]
]
},
// Environment for transpiling files to be compatible with CommonJS.
commonjs_dist: {
plugins: [
['@babel/plugin-transform-modules-commonjs', { loose: true }],
['babel-plugin-transform-require-ignore', { extensions: ['.css'] }]
],
ignore: [
'**/__tests__/**',
'**/test/**',
'**/dist/**',
]
},
// Environment for transpiling files to be compatible with ES Modules.
es: {
plugins: [
['babel-plugin-transform-require-ignore', { extensions: ['.css'] }],
['./.config/plugin/babel/add-import-extension.js', { extension: 'mjs' }]
],
ignore: [
'**/__tests__/**',
'**/test/**',
'**/dist/**',
],
},
// Environment for transpiling only legacy language files (e.q. import `languages/pl-PL`)
// which need to be compatible with ES Modules. That format, by default, automatically
// registers the language pack. It's not suitable to use with the modularized version of
// the Handsontable.
es_languages: {
plugins: [
['babel-plugin-transform-require-ignore', { extensions: ['.css'] }],
['./.config/plugin/babel/add-import-extension.js', { extension: 'mjs' }],
['./.config/plugin/babel/add-language-registration.js'],
],
},
// Environment for building E2E tests (UMD).
commonjs_e2e: {
plugins: [
['@babel/plugin-transform-runtime', {
corejs: false,
helpers: true,
regenerator: true,
useESModules: false,
}],
['@babel/plugin-transform-modules-commonjs', { loose: true }],
['babel-plugin-forbidden-imports', {
allowedModules: allowedE2EModules
}]
],
},
},
ignore: [
'src/3rdparty/walkontable/dist/',
'src/3rdparty/walkontable/test/dist/',
],
};