1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = isModule;
|
5 |
|
6 | function isModule(path, requireUnambiguous) {
|
7 | if (requireUnambiguous === void 0) {
|
8 | requireUnambiguous = false;
|
9 | }
|
10 |
|
11 | var sourceType = path.node.sourceType;
|
12 |
|
13 | if (sourceType !== "module" && sourceType !== "script") {
|
14 | throw path.buildCodeFrameError("Unknown sourceType \"" + sourceType + "\", cannot transform.");
|
15 | }
|
16 |
|
17 | var filename = path.hub.file.opts.filename;
|
18 |
|
19 | if (/\.mjs$/.test(filename)) {
|
20 | requireUnambiguous = false;
|
21 | }
|
22 |
|
23 | return path.node.sourceType === "module" && (!requireUnambiguous || isUnambiguousModule(path));
|
24 | }
|
25 |
|
26 | function isUnambiguousModule(path) {
|
27 | return path.get("body").some(function (p) {
|
28 | return p.isModuleDeclaration();
|
29 | });
|
30 | } |
\ | No newline at end of file |