-
-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathget-babel-options.js
66 lines (56 loc) · 1.91 KB
/
get-babel-options.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
const {
_addDecoratorPlugins,
_addTypeScriptPlugin,
_getAddonProvidedConfig,
_shouldCompileModules,
_shouldIncludeHelpers,
_shouldHandleTypeScript,
_shouldIncludeDecoratorPlugins,
_getHelpersPlugin,
_getDebugMacroPlugins,
_getEmberModulesAPIPolyfill,
_getEmberDataPackagesPolyfill,
_getModulesPlugin,
_getPresetEnv,
} = require("./babel-options-util");
module.exports = function getBabelOptions(config, appInstance) {
let { parent, project } = appInstance;
let addonProvidedConfig = _getAddonProvidedConfig(config);
let shouldIncludeHelpers = _shouldIncludeHelpers(config, appInstance);
let shouldHandleTypeScript = _shouldHandleTypeScript(config, parent, project);
let shouldIncludeDecoratorPlugins = _shouldIncludeDecoratorPlugins(config);
let emberCLIBabelConfig = config["ember-cli-babel"];
let shouldRunPresetEnv = true;
if (emberCLIBabelConfig) {
shouldRunPresetEnv = !emberCLIBabelConfig.disablePresetEnv;
}
let options = {};
let userPlugins = addonProvidedConfig.plugins;
let userPostTransformPlugins = addonProvidedConfig.postTransformPlugins;
if (shouldHandleTypeScript) {
userPlugins = _addTypeScriptPlugin(userPlugins.slice(), parent, project);
}
if (shouldIncludeDecoratorPlugins) {
userPlugins = _addDecoratorPlugins(
userPlugins.slice(),
addonProvidedConfig.options,
config,
parent,
project
);
}
options.plugins = []
.concat(
shouldIncludeHelpers && _getHelpersPlugin(project),
userPlugins,
_getDebugMacroPlugins(config, project),
_getEmberModulesAPIPolyfill(config, parent, project),
_getEmberDataPackagesPolyfill(config, parent),
_shouldCompileModules(config, project) && _getModulesPlugin(),
userPostTransformPlugins
).filter(Boolean);
options.presets = [
shouldRunPresetEnv && _getPresetEnv(addonProvidedConfig, project),
].filter(Boolean);
return options;
};