-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (36 loc) · 1.03 KB
/
index.js
File metadata and controls
43 lines (36 loc) · 1.03 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
'use strict';
exports.default = function(babel) {
var rootPath = process.cwd();
var modulesBase = rootPath + '/node_modules';
var pushGlobalAssign = function(nodePath, globalName, localName) {
if (localName == null) localName = globalName;
nodePath.pushContainer('body', t.expressionStatement(
t.assignmentExpression('=',
t.memberExpression(
t.identifier('global'),
t.identifier(globalName)
),
t.identifier(localName)
)
));
}
var moduleJsPath = function(moduleJs) {
return modulesBase + moduleJs;
}
var t = babel.types;
return {
visitor: {
Program: function Program(path, state) {
switch (state.file.opts.filename) {
case moduleJsPath('/buffer/index.js'):
pushGlobalAssign(path, 'Buffer');
break;
case moduleJsPath('/process/browser.js'):
pushGlobalAssign(path, 'process');
break;
}
}
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });