-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
to-named-amd.js
31 lines (27 loc) · 949 Bytes
/
to-named-amd.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
const Babel = require('broccoli-babel-transpiler');
const resolveModuleSource = require('amd-name-resolver').moduleResolve;
const enifed = require('./transforms/transform-define');
const injectNodeGlobals = require('./transforms/inject-node-globals');
module.exports = function processModulesOnly(tree, strict = false) {
let transformOptions = { noInterop: true };
// These options need to be exclusive for some reason, even the key existing
// on the options hash causes issues.
if (strict) {
transformOptions.strict = true;
} else {
transformOptions.loose = true;
}
let options = {
sourceMap: true,
plugins: [
// ensures `@glimmer/compiler` requiring `crypto` works properly
// in both browser and node-land
injectNodeGlobals,
['transform-es2015-modules-amd', transformOptions],
enifed,
],
moduleIds: true,
resolveModuleSource,
};
return new Babel(tree, options);
};