Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
825 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.getImportSource = getImportSource;
|
---|
7 | exports.getRequireSource = getRequireSource;
|
---|
8 | exports.isPolyfillSource = isPolyfillSource;
|
---|
9 |
|
---|
10 | var t = require("@babel/types");
|
---|
11 |
|
---|
12 | function getImportSource({
|
---|
13 | node
|
---|
14 | }) {
|
---|
15 | if (node.specifiers.length === 0) return node.source.value;
|
---|
16 | }
|
---|
17 |
|
---|
18 | function getRequireSource({
|
---|
19 | node
|
---|
20 | }) {
|
---|
21 | if (!t.isExpressionStatement(node)) return;
|
---|
22 | const {
|
---|
23 | expression
|
---|
24 | } = node;
|
---|
25 |
|
---|
26 | if (t.isCallExpression(expression) && t.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t.isStringLiteral(expression.arguments[0])) {
|
---|
27 | return expression.arguments[0].value;
|
---|
28 | }
|
---|
29 | }
|
---|
30 |
|
---|
31 | function isPolyfillSource(source) {
|
---|
32 | return source === "@babel/polyfill" || source === "core-js";
|
---|
33 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.