1 | "use strict";
|
2 |
|
3 | const AV = require("./assignment-visitor.js");
|
4 | const FastPath = require("./fast-path.js");
|
5 | const IEV = require("./import-export-visitor.js");
|
6 |
|
7 | const assignmentVisitor = new AV;
|
8 | const importExportVisitor = new IEV;
|
9 |
|
10 | module.exports = function (ast, options) {
|
11 | const importExportOptions = Object.assign(Object.create(null), options);
|
12 | const rootPath = new FastPath(ast);
|
13 |
|
14 |
|
15 | importExportOptions.ast = true;
|
16 |
|
17 | importExportVisitor.visit(
|
18 | rootPath,
|
19 | null,
|
20 | importExportOptions
|
21 | );
|
22 |
|
23 | const result = { ast, identical: false };
|
24 |
|
25 | if (importExportVisitor.madeChanges) {
|
26 | assignmentVisitor.visit(rootPath, {
|
27 | exportedLocalNames: importExportVisitor.exportedLocalNames,
|
28 | moduleAlias: importExportOptions.moduleAlias,
|
29 | modifyAST: true
|
30 | });
|
31 | } else {
|
32 |
|
33 | result.identical = true;
|
34 | }
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | importExportVisitor.finalizeHoisting();
|
40 |
|
41 | return result;
|
42 | };
|