-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
35 lines (35 loc) · 1010 Bytes
/
index.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
module.exports = function({ types: t }) {
return {
visitor: {
ImportDeclaration(path) {
if (t.isLiteral(path.node.source)) {
if (path.node.source.value === 'zep-script') {
// Removes `import 'zep-script'`
path.remove();
}
}
},
MemberExpression(path) {
if (t.isIdentifier(path.node.object)) {
if (path.node.object.name === 'ScriptApp') {
// Replaces `ScriptApp` with `Script`
path.replaceWith(
t.memberExpression(
t.identifier('App'),
t.identifier(path.node.property.name)
)
)
} else if (path.node.object.name === 'ScriptMap') {
// Replaces `ScriptMap` with `Map`
path.replaceWith(
t.memberExpression(
t.identifier('Map'),
t.identifier(path.node.property.name)
)
)
}
}
}
}
}
}