@galadrim/galadmin 0.1.33 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/api.js +5 -1
  2. package/dist/api.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +1 -1
  5. package/src/api.ts +5 -1
  6. package/src/front/node_modules/.cache/.eslintcache +1 -1
  7. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/6c/19/fe86ba5d7c4062f185480ad22dd3b9fae9b30149827224339f9a633a9a94 +1 -1
  8. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/87/08/421190bfe6e50816e059da6c33526c9943732ef856ebd2752d0cbfb4a852 +1 -1
  9. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/c2/e5/5451dd89bb0fd48f988bf27c7ee614c66eb91f7085c5b5c8cb33048d0c32 +1 -1
  10. package/src/front/node_modules/.package-lock.json +115 -74
  11. package/src/front/node_modules/@babel/code-frame/README.md +1 -1
  12. package/src/front/node_modules/@babel/code-frame/lib/index.js +15 -1
  13. package/src/front/node_modules/@babel/code-frame/lib/index.js.map +1 -1
  14. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/index.js +165 -0
  15. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/license +9 -0
  16. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/package.json +56 -0
  17. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/readme.md +147 -0
  18. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/index.js +228 -0
  19. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/index.js.flow +93 -0
  20. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/license +9 -0
  21. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/package.json +71 -0
  22. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/readme.md +314 -0
  23. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/templates.js +128 -0
  24. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/types/index.d.ts +97 -0
  25. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/browser.js +5 -0
  26. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/index.js +131 -0
  27. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/license +9 -0
  28. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/package.json +53 -0
  29. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/readme.md +66 -0
  30. package/src/front/node_modules/@babel/code-frame/package.json +3 -2
  31. package/src/front/node_modules/@babel/compat-data/data/plugin-bugfixes.json +2 -0
  32. package/src/front/node_modules/@babel/compat-data/data/plugins.json +8 -0
  33. package/src/front/node_modules/@babel/compat-data/package.json +1 -1
  34. package/src/front/node_modules/@babel/core/cjs-proxy.cjs +3 -1
  35. package/src/front/node_modules/@babel/core/lib/config/config-chain.js +7 -4
  36. package/src/front/node_modules/@babel/core/lib/config/config-chain.js.map +1 -1
  37. package/src/front/node_modules/@babel/core/lib/config/config-descriptors.js +2 -1
  38. package/src/front/node_modules/@babel/core/lib/config/config-descriptors.js.map +1 -1
  39. package/src/front/node_modules/@babel/core/lib/config/files/module-types.js +5 -5
  40. package/src/front/node_modules/@babel/core/lib/config/files/module-types.js.map +1 -1
  41. package/src/front/node_modules/@babel/core/lib/config/full.js.map +1 -1
  42. package/src/front/node_modules/@babel/core/lib/config/helpers/config-api.js +4 -4
  43. package/src/front/node_modules/@babel/core/lib/config/helpers/config-api.js.map +1 -1
  44. package/src/front/node_modules/@babel/core/lib/config/index.js.map +1 -1
  45. package/src/front/node_modules/@babel/core/lib/config/item.js.map +1 -1
  46. package/src/front/node_modules/@babel/core/lib/config/printer.js.map +1 -1
  47. package/src/front/node_modules/@babel/core/lib/config/validation/options.js.map +1 -1
  48. package/src/front/node_modules/@babel/core/lib/config/validation/plugins.js.map +1 -1
  49. package/src/front/node_modules/@babel/core/lib/index.js +2 -1
  50. package/src/front/node_modules/@babel/core/lib/index.js.map +1 -1
  51. package/src/front/node_modules/@babel/core/lib/transformation/file/file.js +5 -5
  52. package/src/front/node_modules/@babel/core/lib/transformation/file/file.js.map +1 -1
  53. package/src/front/node_modules/@babel/core/lib/transformation/file/generate.js.map +1 -1
  54. package/src/front/node_modules/@babel/core/lib/transformation/index.js +3 -1
  55. package/src/front/node_modules/@babel/core/lib/transformation/index.js.map +1 -1
  56. package/src/front/node_modules/@babel/core/lib/transformation/plugin-pass.js.map +1 -1
  57. package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/README.md +2 -13
  58. package/src/front/node_modules/@babel/core/node_modules/semver/package.json +38 -0
  59. package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/semver.js +54 -20
  60. package/src/front/node_modules/@babel/core/package.json +13 -13
  61. package/src/front/node_modules/@babel/generator/lib/buffer.js.map +1 -1
  62. package/src/front/node_modules/@babel/generator/lib/generators/classes.js +6 -6
  63. package/src/front/node_modules/@babel/generator/lib/generators/classes.js.map +1 -1
  64. package/src/front/node_modules/@babel/generator/lib/generators/methods.js.map +1 -1
  65. package/src/front/node_modules/@babel/generator/lib/generators/types.js.map +1 -1
  66. package/src/front/node_modules/@babel/generator/lib/index.js +2 -1
  67. package/src/front/node_modules/@babel/generator/lib/index.js.map +1 -1
  68. package/src/front/node_modules/@babel/generator/lib/printer.js +2 -2
  69. package/src/front/node_modules/@babel/generator/lib/printer.js.map +1 -1
  70. package/src/front/node_modules/@babel/generator/lib/source-map.js.map +1 -1
  71. package/src/front/node_modules/@babel/generator/package.json +4 -4
  72. package/src/front/node_modules/@babel/helper-compilation-targets/lib/debug.js +2 -2
  73. package/src/front/node_modules/@babel/helper-compilation-targets/lib/debug.js.map +1 -1
  74. package/src/front/node_modules/@babel/helper-compilation-targets/lib/filter-items.js +3 -3
  75. package/src/front/node_modules/@babel/helper-compilation-targets/lib/filter-items.js.map +1 -1
  76. package/src/front/node_modules/@babel/helper-compilation-targets/lib/pretty.js +2 -2
  77. package/src/front/node_modules/@babel/helper-compilation-targets/lib/pretty.js.map +1 -1
  78. package/src/front/node_modules/@babel/helper-compilation-targets/lib/utils.js +3 -3
  79. package/src/front/node_modules/@babel/helper-compilation-targets/lib/utils.js.map +1 -1
  80. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/LICENSE +15 -0
  81. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/README.md +443 -0
  82. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/bin/semver.js +174 -0
  83. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/package.json +38 -0
  84. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/range.bnf +16 -0
  85. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/semver.js +1643 -0
  86. package/src/front/node_modules/@babel/helper-compilation-targets/package.json +4 -8
  87. package/src/front/node_modules/@babel/helper-module-transforms/README.md +1 -1
  88. package/src/front/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js +11 -12
  89. package/src/front/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js.map +1 -1
  90. package/src/front/node_modules/@babel/helper-module-transforms/lib/index.js +15 -16
  91. package/src/front/node_modules/@babel/helper-module-transforms/lib/index.js.map +1 -1
  92. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js +3 -4
  93. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js.map +1 -1
  94. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js +4 -5
  95. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js.map +1 -1
  96. package/src/front/node_modules/@babel/helper-module-transforms/package.json +10 -6
  97. package/src/front/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js +2 -4
  98. package/src/front/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js.map +1 -1
  99. package/src/front/node_modules/@babel/helpers/lib/helpers-generated.js +1 -1
  100. package/src/front/node_modules/@babel/helpers/lib/helpers-generated.js.map +1 -1
  101. package/src/front/node_modules/@babel/helpers/package.json +6 -6
  102. package/src/front/node_modules/@babel/highlight/README.md +1 -1
  103. package/src/front/node_modules/@babel/highlight/lib/index.js +20 -10
  104. package/src/front/node_modules/@babel/highlight/lib/index.js.map +1 -1
  105. package/src/front/node_modules/@babel/highlight/package.json +2 -3
  106. package/src/front/node_modules/@babel/parser/lib/index.js +115 -160
  107. package/src/front/node_modules/@babel/parser/lib/index.js.map +1 -1
  108. package/src/front/node_modules/@babel/parser/lib/options.js +6 -2
  109. package/src/front/node_modules/@babel/parser/lib/options.js.map +1 -1
  110. package/src/front/node_modules/@babel/parser/lib/parser/expression.js +4 -4
  111. package/src/front/node_modules/@babel/parser/lib/parser/expression.js.map +1 -1
  112. package/src/front/node_modules/@babel/parser/lib/parser/lval.js +6 -6
  113. package/src/front/node_modules/@babel/parser/lib/parser/lval.js.map +1 -1
  114. package/src/front/node_modules/@babel/parser/lib/parser/statement.js +20 -19
  115. package/src/front/node_modules/@babel/parser/lib/parser/statement.js.map +1 -1
  116. package/src/front/node_modules/@babel/parser/lib/parser/util.js +1 -1
  117. package/src/front/node_modules/@babel/parser/lib/parser/util.js.map +1 -1
  118. package/src/front/node_modules/@babel/parser/lib/plugins/flow/index.js +7 -7
  119. package/src/front/node_modules/@babel/parser/lib/plugins/flow/index.js.map +1 -1
  120. package/src/front/node_modules/@babel/parser/lib/plugins/flow/scope.js +2 -2
  121. package/src/front/node_modules/@babel/parser/lib/plugins/flow/scope.js.map +1 -1
  122. package/src/front/node_modules/@babel/parser/lib/plugins/placeholders.js +2 -1
  123. package/src/front/node_modules/@babel/parser/lib/plugins/placeholders.js.map +1 -1
  124. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/index.js +16 -16
  125. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/index.js.map +1 -1
  126. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/scope.js +16 -14
  127. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/scope.js.map +1 -1
  128. package/src/front/node_modules/@babel/parser/lib/util/class-scope.js +5 -5
  129. package/src/front/node_modules/@babel/parser/lib/util/class-scope.js.map +1 -1
  130. package/src/front/node_modules/@babel/parser/lib/util/expression-scope.js +7 -12
  131. package/src/front/node_modules/@babel/parser/lib/util/expression-scope.js.map +1 -1
  132. package/src/front/node_modules/@babel/parser/lib/util/scope.js +23 -23
  133. package/src/front/node_modules/@babel/parser/lib/util/scope.js.map +1 -1
  134. package/src/front/node_modules/@babel/parser/lib/util/scopeflags.js +60 -99
  135. package/src/front/node_modules/@babel/parser/lib/util/scopeflags.js.map +1 -1
  136. package/src/front/node_modules/@babel/parser/package.json +3 -3
  137. package/src/front/node_modules/@babel/traverse/lib/cache.js +24 -3
  138. package/src/front/node_modules/@babel/traverse/lib/cache.js.map +1 -1
  139. package/src/front/node_modules/@babel/traverse/lib/index.js +5 -3
  140. package/src/front/node_modules/@babel/traverse/lib/index.js.map +1 -1
  141. package/src/front/node_modules/@babel/traverse/lib/path/context.js.map +1 -1
  142. package/src/front/node_modules/@babel/traverse/lib/path/conversion.js +1 -4
  143. package/src/front/node_modules/@babel/traverse/lib/path/conversion.js.map +1 -1
  144. package/src/front/node_modules/@babel/traverse/lib/path/index.js +2 -6
  145. package/src/front/node_modules/@babel/traverse/lib/path/index.js.map +1 -1
  146. package/src/front/node_modules/@babel/traverse/lib/path/lib/hoister.js.map +1 -1
  147. package/src/front/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js +9 -7
  148. package/src/front/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js.map +1 -1
  149. package/src/front/node_modules/@babel/traverse/lib/path/modification.js +3 -2
  150. package/src/front/node_modules/@babel/traverse/lib/path/modification.js.map +1 -1
  151. package/src/front/node_modules/@babel/traverse/lib/path/removal.js +3 -1
  152. package/src/front/node_modules/@babel/traverse/lib/path/removal.js.map +1 -1
  153. package/src/front/node_modules/@babel/traverse/lib/path/replacement.js +4 -4
  154. package/src/front/node_modules/@babel/traverse/lib/path/replacement.js.map +1 -1
  155. package/src/front/node_modules/@babel/traverse/lib/scope/index.js +2 -1
  156. package/src/front/node_modules/@babel/traverse/lib/scope/index.js.map +1 -1
  157. package/src/front/node_modules/@babel/traverse/lib/traverse-node.js +6 -2
  158. package/src/front/node_modules/@babel/traverse/lib/traverse-node.js.map +1 -1
  159. package/src/front/node_modules/@babel/traverse/lib/visitors.js.map +1 -1
  160. package/src/front/node_modules/@babel/traverse/package.json +6 -5
  161. package/src/front/node_modules/@babel/types/README.md +1 -1
  162. package/src/front/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -1
  163. package/src/front/node_modules/@babel/types/lib/converters/toStatement.js.map +1 -1
  164. package/src/front/node_modules/@babel/types/lib/definitions/core.js +8 -1
  165. package/src/front/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
  166. package/src/front/node_modules/@babel/types/lib/index.d.ts +11 -10
  167. package/src/front/node_modules/@babel/types/lib/validators/generated/index.js.map +1 -1
  168. package/src/front/node_modules/@babel/types/lib/validators/isType.js +1 -0
  169. package/src/front/node_modules/@babel/types/lib/validators/isType.js.map +1 -1
  170. package/src/front/node_modules/@babel/types/package.json +3 -4
  171. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/package.json +19 -9
  172. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/semver.js +68 -26
  173. package/src/front/package-lock.json +216 -142
  174. package/src/front/node_modules/@nicolo-ribaudo/semver-v6/CHANGELOG.md +0 -70
  175. package/src/front/node_modules/@nicolo-ribaudo/semver-v6/package.json +0 -28
  176. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/CHANGELOG.md +0 -39
  177. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/LICENSE +0 -0
  178. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/bin/semver.js +0 -0
  179. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/range.bnf +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/helper-compilation-targets",
3
- "version": "7.22.6",
3
+ "version": "7.22.10",
4
4
  "author": "The Babel Team (https://babel.dev/team)",
5
5
  "license": "MIT",
6
6
  "description": "Helper functions on Babel compilation targets",
@@ -22,17 +22,13 @@
22
22
  "babel-plugin"
23
23
  ],
24
24
  "dependencies": {
25
- "@babel/compat-data": "^7.22.6",
25
+ "@babel/compat-data": "^7.22.9",
26
26
  "@babel/helper-validator-option": "^7.22.5",
27
- "@nicolo-ribaudo/semver-v6": "^6.3.3",
28
27
  "browserslist": "^4.21.9",
29
- "lru-cache": "^5.1.1"
30
- },
31
- "peerDependencies": {
32
- "@babel/core": "^7.0.0"
28
+ "lru-cache": "^5.1.1",
29
+ "semver": "^6.3.1"
33
30
  },
34
31
  "devDependencies": {
35
- "@babel/core": "^7.22.6",
36
32
  "@babel/helper-plugin-test-runner": "^7.22.5",
37
33
  "@types/lru-cache": "^5.1.1",
38
34
  "@types/semver": "^5.5.0"
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Babel helper functions for implementing ES6 module transformations
4
4
 
5
- See our website [@babel/helper-module-transforms](https://babeljs.io/docs/en/babel-helper-module-transforms) for more information.
5
+ See our website [@babel/helper-module-transforms](https://babeljs.io/docs/babel-helper-module-transforms) for more information.
6
6
 
7
7
  ## Install
8
8
 
@@ -4,47 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.buildDynamicImport = buildDynamicImport;
7
- var t = require("@babel/types");
8
- var _template = require("@babel/template");
7
+ var _core = require("@babel/core");
9
8
  {
10
9
  {
11
10
  {
12
11
  exports.getDynamicImportSource = function getDynamicImportSource(node) {
13
12
  const [source] = node.arguments;
14
- return t.isStringLiteral(source) || t.isTemplateLiteral(source) ? source : _template.default.expression.ast`\`\${${source}}\``;
13
+ return _core.types.isStringLiteral(source) || _core.types.isTemplateLiteral(source) ? source : _core.template.expression.ast`\`\${${source}}\``;
15
14
  };
16
15
  }
17
16
  }
18
17
  }
19
18
  function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) {
20
19
  const [specifier] = node.arguments;
21
- if (t.isStringLiteral(specifier) || t.isTemplateLiteral(specifier) && specifier.quasis.length === 0) {
20
+ if (_core.types.isStringLiteral(specifier) || _core.types.isTemplateLiteral(specifier) && specifier.quasis.length === 0) {
22
21
  if (deferToThen) {
23
- return _template.default.expression.ast`
22
+ return _core.template.expression.ast`
24
23
  Promise.resolve().then(() => ${builder(specifier)})
25
24
  `;
26
25
  } else return builder(specifier);
27
26
  }
28
- const specifierToString = t.isTemplateLiteral(specifier) ? t.identifier("specifier") : t.templateLiteral([t.templateElement({
27
+ const specifierToString = _core.types.isTemplateLiteral(specifier) ? _core.types.identifier("specifier") : _core.types.templateLiteral([_core.types.templateElement({
29
28
  raw: ""
30
- }), t.templateElement({
29
+ }), _core.types.templateElement({
31
30
  raw: ""
32
- })], [t.identifier("specifier")]);
31
+ })], [_core.types.identifier("specifier")]);
33
32
  if (deferToThen) {
34
- return _template.default.expression.ast`
33
+ return _core.template.expression.ast`
35
34
  (specifier =>
36
35
  new Promise(r => r(${specifierToString}))
37
- .then(s => ${builder(t.identifier("s"))})
36
+ .then(s => ${builder(_core.types.identifier("s"))})
38
37
  )(${specifier})
39
38
  `;
40
39
  } else if (wrapWithPromise) {
41
- return _template.default.expression.ast`
40
+ return _core.template.expression.ast`
42
41
  (specifier =>
43
42
  new Promise(r => r(${builder(specifierToString)}))
44
43
  )(${specifier})
45
44
  `;
46
45
  } else {
47
- return _template.default.expression.ast`
46
+ return _core.template.expression.ast`
48
47
  (specifier => ${builder(specifierToString)})(${specifier})
49
48
  `;
50
49
  }
@@ -1 +1 @@
1
- {"version":3,"names":["t","require","_template","exports","getDynamicImportSource","node","source","arguments","isStringLiteral","isTemplateLiteral","template","expression","ast","buildDynamicImport","deferToThen","wrapWithPromise","builder","specifier","quasis","length","specifierToString","identifier","templateLiteral","templateElement","raw"],"sources":["../src/dynamic-import.ts"],"sourcesContent":["// Heavily inspired by\n// https://github.com/airbnb/babel-plugin-dynamic-import-node/blob/master/src/utils.js\n\nimport * as t from \"@babel/types\";\nimport template from \"@babel/template\";\n\nif (!process.env.BABEL_8_BREAKING) {\n if (!USE_ESM) {\n if (!IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.getDynamicImportSource = function getDynamicImportSource(\n node: t.CallExpression,\n ): t.StringLiteral | t.TemplateLiteral {\n const [source] = node.arguments;\n\n return t.isStringLiteral(source) || t.isTemplateLiteral(source)\n ? source\n : (template.expression.ast`\\`\\${${source}}\\`` as t.TemplateLiteral);\n };\n }\n }\n}\n\nexport function buildDynamicImport(\n node: t.CallExpression,\n deferToThen: boolean,\n wrapWithPromise: boolean,\n builder: (specifier: t.Expression) => t.Expression,\n): t.Expression {\n const [specifier] = node.arguments;\n\n if (\n t.isStringLiteral(specifier) ||\n (t.isTemplateLiteral(specifier) && specifier.quasis.length === 0)\n ) {\n if (deferToThen) {\n return template.expression.ast`\n Promise.resolve().then(() => ${builder(specifier)})\n `;\n } else return builder(specifier);\n }\n\n const specifierToString = t.isTemplateLiteral(specifier)\n ? t.identifier(\"specifier\")\n : t.templateLiteral(\n [t.templateElement({ raw: \"\" }), t.templateElement({ raw: \"\" })],\n [t.identifier(\"specifier\")],\n );\n\n if (deferToThen) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${specifierToString}))\n .then(s => ${builder(t.identifier(\"s\"))})\n )(${specifier})\n `;\n } else if (wrapWithPromise) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${builder(specifierToString)}))\n )(${specifier})\n `;\n } else {\n return template.expression.ast`\n (specifier => ${builder(specifierToString)})(${specifier})\n `;\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,CAAA,GAAAC,OAAA;AACA,IA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iBAAQ,CAACC,UAAU,CAACC,GAAI;AACnC;AACA,6BAA6BQ,iBAAkB;AAC/C,uBAAuBJ,OAAO,CAAChB,CAAC,CAACqB,UAAU,CAAC,GAAG,CAAC,CAAE;AAClD,UAAUJ,SAAU;AACpB,KAAK;EACH,CAAC,MAAM,IAAIF,eAAe,EAAE;IAC1B,OAAOL,iBAAQ,CAACC,UAAU,CAACC,GAAI;AACnC;AACA,6BAA6BI,OAAO,CAACI,iBAAiB,CAAE;AACxD,UAAUH,SAAU;AACpB,KAAK;EACH,CAAC,MAAM;IACL,OAAOP,iBAAQ,CAACC,UAAU,CAACC,GAAI;AACnC,sBAAsBI,OAAO,CAACI,iBAAiB,CAAE,KAAIH,SAAU;AAC/D,KAAK;EACH;AACF"}
1
+ {"version":3,"names":["_core","require","exports","getDynamicImportSource","node","source","arguments","t","isStringLiteral","isTemplateLiteral","template","expression","ast","buildDynamicImport","deferToThen","wrapWithPromise","builder","specifier","quasis","length","specifierToString","identifier","templateLiteral","templateElement","raw"],"sources":["../src/dynamic-import.ts"],"sourcesContent":["// Heavily inspired by\n// https://github.com/airbnb/babel-plugin-dynamic-import-node/blob/master/src/utils.js\n\nimport { types as t, template } from \"@babel/core\";\n\nif (!process.env.BABEL_8_BREAKING) {\n if (!USE_ESM) {\n if (!IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.getDynamicImportSource = function getDynamicImportSource(\n node: t.CallExpression,\n ): t.StringLiteral | t.TemplateLiteral {\n const [source] = node.arguments;\n\n return t.isStringLiteral(source) || t.isTemplateLiteral(source)\n ? source\n : (template.expression.ast`\\`\\${${source}}\\`` as t.TemplateLiteral);\n };\n }\n }\n}\n\nexport function buildDynamicImport(\n node: t.CallExpression,\n deferToThen: boolean,\n wrapWithPromise: boolean,\n builder: (specifier: t.Expression) => t.Expression,\n): t.Expression {\n const [specifier] = node.arguments;\n\n if (\n t.isStringLiteral(specifier) ||\n (t.isTemplateLiteral(specifier) && specifier.quasis.length === 0)\n ) {\n if (deferToThen) {\n return template.expression.ast`\n Promise.resolve().then(() => ${builder(specifier)})\n `;\n } else return builder(specifier);\n }\n\n const specifierToString = t.isTemplateLiteral(specifier)\n ? t.identifier(\"specifier\")\n : t.templateLiteral(\n [t.templateElement({ raw: \"\" }), t.templateElement({ raw: \"\" })],\n [t.identifier(\"specifier\")],\n );\n\n if (deferToThen) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${specifierToString}))\n .then(s => ${builder(t.identifier(\"s\"))})\n )(${specifier})\n `;\n } else if (wrapWithPromise) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${builder(specifierToString)}))\n )(${specifier})\n `;\n } else {\n return template.expression.ast`\n (specifier => ${builder(specifierToString)})(${specifier})\n `;\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAEmC;EACnB;IACQ;MAElBC,OAAO,CAACC,sBAAsB,GAAG,SAASA,sBAAsBA,CAC9DC,IAAsB,EACe;QACrC,MAAM,CAACC,MAAM,CAAC,GAAGD,IAAI,CAACE,SAAS;QAE/B,OAAOC,WAAC,CAACC,eAAe,CAACH,MAAM,CAAC,IAAIE,WAAC,CAACE,iBAAiB,CAACJ,MAAM,CAAC,GAC3DA,MAAM,GACLK,cAAQ,CAACC,UAAU,CAACC,GAAI,QAAOP,MAAO,KAA0B;MACvE,CAAC;IACH;EACF;AACF;AAEO,SAASQ,kBAAkBA,CAChCT,IAAsB,EACtBU,WAAoB,EACpBC,eAAwB,EACxBC,OAAkD,EACpC;EACd,MAAM,CAACC,SAAS,CAAC,GAAGb,IAAI,CAACE,SAAS;EAElC,IACEC,WAAC,CAACC,eAAe,CAACS,SAAS,CAAC,IAC3BV,WAAC,CAACE,iBAAiB,CAACQ,SAAS,CAAC,IAAIA,SAAS,CAACC,MAAM,CAACC,MAAM,KAAK,CAAE,EACjE;IACA,IAAIL,WAAW,EAAE;MACf,OAAOJ,cAAQ,CAACC,UAAU,CAACC,GAAI;AACrC,uCAAuCI,OAAO,CAACC,SAAS,CAAE;AAC1D,OAAO;IACH,CAAC,MAAM,OAAOD,OAAO,CAACC,SAAS,CAAC;EAClC;EAEA,MAAMG,iBAAiB,GAAGb,WAAC,CAACE,iBAAiB,CAACQ,SAAS,CAAC,GACpDV,WAAC,CAACc,UAAU,CAAC,WAAW,CAAC,GACzBd,WAAC,CAACe,eAAe,CACf,CAACf,WAAC,CAACgB,eAAe,CAAC;IAAEC,GAAG,EAAE;EAAG,CAAC,CAAC,EAAEjB,WAAC,CAACgB,eAAe,CAAC;IAAEC,GAAG,EAAE;EAAG,CAAC,CAAC,CAAC,EAChE,CAACjB,WAAC,CAACc,UAAU,CAAC,WAAW,CAAC,CAC5B,CAAC;EAEL,IAAIP,WAAW,EAAE;IACf,OAAOJ,cAAQ,CAACC,UAAU,CAACC,GAAI;AACnC;AACA,6BAA6BQ,iBAAkB;AAC/C,uBAAuBJ,OAAO,CAACT,WAAC,CAACc,UAAU,CAAC,GAAG,CAAC,CAAE;AAClD,UAAUJ,SAAU;AACpB,KAAK;EACH,CAAC,MAAM,IAAIF,eAAe,EAAE;IAC1B,OAAOL,cAAQ,CAACC,UAAU,CAACC,GAAI;AACnC;AACA,6BAA6BI,OAAO,CAACI,iBAAiB,CAAE;AACxD,UAAUH,SAAU;AACpB,KAAK;EACH,CAAC,MAAM;IACL,OAAOP,cAAQ,CAACC,UAAU,CAACC,GAAI;AACnC,sBAAsBI,OAAO,CAACI,iBAAiB,CAAE,KAAIH,SAAU;AAC/D,KAAK;EACH;AACF"}
@@ -44,8 +44,7 @@ Object.defineProperty(exports, "rewriteThis", {
44
44
  });
45
45
  exports.wrapInterop = wrapInterop;
46
46
  var _assert = require("assert");
47
- var _t = require("@babel/types");
48
- var _template = require("@babel/template");
47
+ var _core = require("@babel/core");
49
48
  var _helperModuleImports = require("@babel/helper-module-imports");
50
49
  var _rewriteThis = require("./rewrite-this");
51
50
  var _rewriteLiveReferences = require("./rewrite-live-references");
@@ -66,7 +65,7 @@ const {
66
65
  valueToNode,
67
66
  variableDeclaration,
68
67
  variableDeclarator
69
- } = _t;
68
+ } = _core.types;
70
69
  {
71
70
  {
72
71
  {
@@ -155,7 +154,7 @@ function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexport
155
154
  if (sourceMetadata.lazy) srcNamespace = callExpression(srcNamespace, []);
156
155
  for (const localName of sourceMetadata.importsNamespace) {
157
156
  if (localName === sourceMetadata.name) continue;
158
- statements.push(_template.default.statement`var NAME = SOURCE;`({
157
+ statements.push(_core.template.statement`var NAME = SOURCE;`({
159
158
  NAME: localName,
160
159
  SOURCE: cloneNode(srcNamespace)
161
160
  }));
@@ -164,14 +163,14 @@ function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexport
164
163
  statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true));
165
164
  }
166
165
  for (const exportName of sourceMetadata.reexportNamespace) {
167
- statements.push((sourceMetadata.lazy ? _template.default.statement`
166
+ statements.push((sourceMetadata.lazy ? _core.template.statement`
168
167
  Object.defineProperty(EXPORTS, "NAME", {
169
168
  enumerable: true,
170
169
  get: function() {
171
170
  return NAMESPACE;
172
171
  }
173
172
  });
174
- ` : _template.default.statement`EXPORTS.NAME = NAMESPACE;`)({
173
+ ` : _core.template.statement`EXPORTS.NAME = NAMESPACE;`)({
175
174
  EXPORTS: metadata.exportName,
176
175
  NAME: exportName,
177
176
  NAMESPACE: cloneNode(srcNamespace)
@@ -185,9 +184,9 @@ function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexport
185
184
  return statements;
186
185
  }
187
186
  const ReexportTemplate = {
188
- constant: _template.default.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`,
189
- constantComputed: _template.default.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`,
190
- spec: _template.default.statement`
187
+ constant: _core.template.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`,
188
+ constantComputed: _core.template.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`,
189
+ spec: _core.template.statement`
191
190
  Object.defineProperty(EXPORTS, "EXPORT_NAME", {
192
191
  enumerable: true,
193
192
  get: function() {
@@ -225,9 +224,9 @@ function buildReexportsFromMeta(meta, metadata, constantReexports) {
225
224
  });
226
225
  }
227
226
  function buildESModuleHeader(metadata, enumerableModuleMeta = false) {
228
- return (enumerableModuleMeta ? _template.default.statement`
227
+ return (enumerableModuleMeta ? _core.template.statement`
229
228
  EXPORTS.__esModule = true;
230
- ` : _template.default.statement`
229
+ ` : _core.template.statement`
231
230
  Object.defineProperty(EXPORTS, "__esModule", {
232
231
  value: true,
233
232
  });
@@ -236,7 +235,7 @@ function buildESModuleHeader(metadata, enumerableModuleMeta = false) {
236
235
  });
237
236
  }
238
237
  function buildNamespaceReexport(metadata, namespace, constantReexports) {
239
- return (constantReexports ? _template.default.statement`
238
+ return (constantReexports ? _core.template.statement`
240
239
  Object.keys(NAMESPACE).forEach(function(key) {
241
240
  if (key === "default" || key === "__esModule") return;
242
241
  VERIFY_NAME_LIST;
@@ -244,7 +243,7 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) {
244
243
 
245
244
  EXPORTS[key] = NAMESPACE[key];
246
245
  });
247
- ` : _template.default.statement`
246
+ ` : _core.template.statement`
248
247
  Object.keys(NAMESPACE).forEach(function(key) {
249
248
  if (key === "default" || key === "__esModule") return;
250
249
  VERIFY_NAME_LIST;
@@ -260,7 +259,7 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) {
260
259
  `)({
261
260
  NAMESPACE: namespace,
262
261
  EXPORTS: metadata.exportName,
263
- VERIFY_NAME_LIST: metadata.exportNameListName ? (0, _template.default)`
262
+ VERIFY_NAME_LIST: metadata.exportNameListName ? (0, _core.template)`
264
263
  if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;
265
264
  `({
266
265
  EXPORTS_LIST: metadata.exportNameListName
@@ -351,8 +350,8 @@ function buildExportInitializationStatements(programPath, metadata, constantReex
351
350
  return results;
352
351
  }
353
352
  const InitTemplate = {
354
- computed: _template.default.expression`EXPORTS["NAME"] = VALUE`,
355
- default: _template.default.expression`EXPORTS.NAME = VALUE`
353
+ computed: _core.template.expression`EXPORTS["NAME"] = VALUE`,
354
+ default: _core.template.expression`EXPORTS.NAME = VALUE`
356
355
  };
357
356
  function buildInitStatement(metadata, exportNames, initExpr) {
358
357
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["_assert","require","_t","_template","_helperModuleImports","_rewriteThis","_rewriteLiveReferences","_normalizeAndLoadMetadata","_dynamicImport","_getModuleName","booleanLiteral","callExpression","cloneNode","directive","directiveLiteral","expressionStatement","identifier","isIdentifier","memberExpression","stringLiteral","valueToNode","variableDeclaration","variableDeclarator","exports","getDynamicImportSource","rewriteModuleStatementsAndPrepareHeader","path","exportName","strict","allowTopLevelThis","strictMode","noInterop","importInterop","lazy","esNamespaceOnly","filename","constantReexports","arguments","loose","enumerableModuleMeta","noIncompleteNsImportDetection","validateImportInteropOption","assert","isModule","node","sourceType","meta","normalizeModuleAndLoadMetadata","initializeReexports","rewriteThis","rewriteLiveReferences","hasStrict","directives","some","value","unshiftContainer","headers","hasExports","push","buildESModuleHeader","nameList","buildExportNameListDeclaration","exportNameListName","name","statement","buildExportInitializationStatements","ensureStatementsHoisted","statements","forEach","header","_blockHoist","wrapInterop","programPath","expr","type","hub","addHelper","helper","Error","buildNamespaceInitStatements","metadata","sourceMetadata","srcNamespace","localName","importsNamespace","template","NAME","SOURCE","buildReexportsFromMeta","reexportNamespace","EXPORTS","NAMESPACE","reexportAll","buildNamespaceReexport","loc","ReexportTemplate","constant","constantComputed","spec","namespace","stringSpecifiers","Array","from","reexports","importName","NAMESPACE_IMPORT","interop","has","astNodes","EXPORT_NAME","VERIFY_NAME_LIST","EXPORTS_LIST","exportedVars","Object","create","data","local","values","names","hasReexport","source","keys","length","scope","generateUidIdentifier","default","initStatements","kind","buildInitStatement","reexportsStatements","i","sort","a","b","results","initStatement","chunkSize","uninitializedExportNames","j","buildUndefinedNode","InitTemplate","computed","expression","exportNames","initExpr","reduce","acc","params","VALUE"],"sources":["../src/index.ts"],"sourcesContent":["import assert from \"assert\";\nimport {\n booleanLiteral,\n callExpression,\n cloneNode,\n directive,\n directiveLiteral,\n expressionStatement,\n identifier,\n isIdentifier,\n memberExpression,\n stringLiteral,\n valueToNode,\n variableDeclaration,\n variableDeclarator,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport template from \"@babel/template\";\n\nimport { isModule } from \"@babel/helper-module-imports\";\n\nimport rewriteThis from \"./rewrite-this\";\nimport rewriteLiveReferences from \"./rewrite-live-references\";\nimport normalizeModuleAndLoadMetadata, {\n hasExports,\n isSideEffectImport,\n validateImportInteropOption,\n} from \"./normalize-and-load-metadata\";\nimport type {\n ImportInterop,\n InteropType,\n Lazy,\n ModuleMetadata,\n SourceModuleMetadata,\n} from \"./normalize-and-load-metadata\";\nimport type { NodePath } from \"@babel/traverse\";\n\nexport { buildDynamicImport } from \"./dynamic-import\";\n\nif (!process.env.BABEL_8_BREAKING) {\n if (!USE_ESM) {\n if (!IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.getDynamicImportSource =\n // eslint-disable-next-line no-restricted-globals\n require(\"./dynamic-import\").getDynamicImportSource;\n }\n }\n}\n\nexport { default as getModuleName } from \"./get-module-name\";\nexport type { PluginOptions } from \"./get-module-name\";\n\nexport { hasExports, isSideEffectImport, isModule, rewriteThis };\n\nexport interface RewriteModuleStatementsAndPrepareHeaderOptions {\n exportName?: string;\n strict: boolean;\n allowTopLevelThis?: boolean;\n strictMode: boolean;\n loose?: boolean;\n importInterop?: ImportInterop;\n noInterop?: boolean;\n lazy?: Lazy;\n esNamespaceOnly?: boolean;\n filename: string | undefined;\n constantReexports?: boolean | void;\n enumerableModuleMeta?: boolean | void;\n noIncompleteNsImportDetection?: boolean | void;\n}\n\n/**\n * Perform all of the generic ES6 module rewriting needed to handle initial\n * module processing. This function will rewrite the majority of the given\n * program to reference the modules described by the returned metadata,\n * and returns a list of statements for use when initializing the module.\n */\nexport function rewriteModuleStatementsAndPrepareHeader(\n path: NodePath<t.Program>,\n {\n exportName,\n strict,\n allowTopLevelThis,\n strictMode,\n noInterop,\n importInterop = noInterop ? \"none\" : \"babel\",\n lazy,\n esNamespaceOnly,\n filename,\n\n constantReexports = process.env.BABEL_8_BREAKING\n ? undefined\n : arguments[1].loose,\n enumerableModuleMeta = process.env.BABEL_8_BREAKING\n ? undefined\n : arguments[1].loose,\n noIncompleteNsImportDetection,\n }: RewriteModuleStatementsAndPrepareHeaderOptions,\n) {\n validateImportInteropOption(importInterop);\n assert(isModule(path), \"Cannot process module statements in a script\");\n path.node.sourceType = \"script\";\n\n const meta = normalizeModuleAndLoadMetadata(path, exportName, {\n importInterop,\n initializeReexports: constantReexports,\n lazy,\n esNamespaceOnly,\n filename,\n });\n\n if (!allowTopLevelThis) {\n rewriteThis(path);\n }\n\n rewriteLiveReferences(path, meta);\n\n if (strictMode !== false) {\n const hasStrict = path.node.directives.some(directive => {\n return directive.value.value === \"use strict\";\n });\n if (!hasStrict) {\n path.unshiftContainer(\n \"directives\",\n directive(directiveLiteral(\"use strict\")),\n );\n }\n }\n\n const headers = [];\n if (hasExports(meta) && !strict) {\n headers.push(buildESModuleHeader(meta, enumerableModuleMeta));\n }\n\n const nameList = buildExportNameListDeclaration(path, meta);\n\n if (nameList) {\n meta.exportNameListName = nameList.name;\n headers.push(nameList.statement);\n }\n\n // Create all of the statically known named exports.\n headers.push(\n ...buildExportInitializationStatements(\n path,\n meta,\n constantReexports,\n noIncompleteNsImportDetection,\n ),\n );\n\n return { meta, headers };\n}\n\n/**\n * Flag a set of statements as hoisted above all else so that module init\n * statements all run before user code.\n */\nexport function ensureStatementsHoisted(statements: t.Statement[]) {\n // Force all of the header fields to be at the top of the file.\n statements.forEach(header => {\n // @ts-expect-error Fixme: handle _blockHoist property\n header._blockHoist = 3;\n });\n}\n\n/**\n * Given an expression for a standard import object, like \"require('foo')\",\n * wrap it in a call to the interop helpers based on the type.\n */\nexport function wrapInterop(\n programPath: NodePath,\n expr: t.Expression,\n type: InteropType,\n): t.CallExpression {\n if (type === \"none\") {\n return null;\n }\n\n if (type === \"node-namespace\") {\n return callExpression(programPath.hub.addHelper(\"interopRequireWildcard\"), [\n expr,\n booleanLiteral(true),\n ]);\n } else if (type === \"node-default\") {\n return null;\n }\n\n let helper;\n if (type === \"default\") {\n helper = \"interopRequireDefault\";\n } else if (type === \"namespace\") {\n helper = \"interopRequireWildcard\";\n } else {\n throw new Error(`Unknown interop: ${type}`);\n }\n\n return callExpression(programPath.hub.addHelper(helper), [expr]);\n}\n\n/**\n * Create the runtime initialization statements for a given requested source.\n * These will initialize all of the runtime import/export logic that\n * can't be handled statically by the statements created by\n * buildExportInitializationStatements().\n */\nexport function buildNamespaceInitStatements(\n metadata: ModuleMetadata,\n sourceMetadata: SourceModuleMetadata,\n constantReexports: boolean | void = false,\n) {\n const statements = [];\n\n let srcNamespace: t.Node = identifier(sourceMetadata.name);\n if (sourceMetadata.lazy) srcNamespace = callExpression(srcNamespace, []);\n\n for (const localName of sourceMetadata.importsNamespace) {\n if (localName === sourceMetadata.name) continue;\n\n // Create and assign binding to namespace object\n statements.push(\n template.statement`var NAME = SOURCE;`({\n NAME: localName,\n SOURCE: cloneNode(srcNamespace),\n }),\n );\n }\n if (constantReexports) {\n statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true));\n }\n for (const exportName of sourceMetadata.reexportNamespace) {\n // Assign export to namespace object.\n statements.push(\n (sourceMetadata.lazy\n ? template.statement`\n Object.defineProperty(EXPORTS, \"NAME\", {\n enumerable: true,\n get: function() {\n return NAMESPACE;\n }\n });\n `\n : template.statement`EXPORTS.NAME = NAMESPACE;`)({\n EXPORTS: metadata.exportName,\n NAME: exportName,\n NAMESPACE: cloneNode(srcNamespace),\n }),\n );\n }\n if (sourceMetadata.reexportAll) {\n const statement = buildNamespaceReexport(\n metadata,\n cloneNode(srcNamespace),\n constantReexports,\n );\n statement.loc = sourceMetadata.reexportAll.loc;\n\n // Iterate props creating getter for each prop.\n statements.push(statement);\n }\n return statements;\n}\n\nconst ReexportTemplate = {\n constant: template.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`,\n constantComputed: template.statement`EXPORTS[\"EXPORT_NAME\"] = NAMESPACE_IMPORT;`,\n spec: template.statement`\n Object.defineProperty(EXPORTS, \"EXPORT_NAME\", {\n enumerable: true,\n get: function() {\n return NAMESPACE_IMPORT;\n },\n });\n `,\n};\n\nfunction buildReexportsFromMeta(\n meta: ModuleMetadata,\n metadata: SourceModuleMetadata,\n constantReexports: boolean,\n) {\n const namespace = metadata.lazy\n ? callExpression(identifier(metadata.name), [])\n : identifier(metadata.name);\n\n const { stringSpecifiers } = meta;\n return Array.from(metadata.reexports, ([exportName, importName]) => {\n let NAMESPACE_IMPORT: t.Expression = cloneNode(namespace);\n if (importName === \"default\" && metadata.interop === \"node-default\") {\n // Nothing, it's ok as-is\n } else if (stringSpecifiers.has(importName)) {\n NAMESPACE_IMPORT = memberExpression(\n NAMESPACE_IMPORT,\n stringLiteral(importName),\n true,\n );\n } else {\n NAMESPACE_IMPORT = memberExpression(\n NAMESPACE_IMPORT,\n identifier(importName),\n );\n }\n const astNodes = {\n EXPORTS: meta.exportName,\n EXPORT_NAME: exportName,\n NAMESPACE_IMPORT,\n };\n if (constantReexports || isIdentifier(NAMESPACE_IMPORT)) {\n if (stringSpecifiers.has(exportName)) {\n return ReexportTemplate.constantComputed(astNodes);\n } else {\n return ReexportTemplate.constant(astNodes);\n }\n } else {\n return ReexportTemplate.spec(astNodes);\n }\n });\n}\n\n/**\n * Build an \"__esModule\" header statement setting the property on a given object.\n */\nfunction buildESModuleHeader(\n metadata: ModuleMetadata,\n enumerableModuleMeta: boolean | void = false,\n) {\n return (\n enumerableModuleMeta\n ? template.statement`\n EXPORTS.__esModule = true;\n `\n : template.statement`\n Object.defineProperty(EXPORTS, \"__esModule\", {\n value: true,\n });\n `\n )({ EXPORTS: metadata.exportName });\n}\n\n/**\n * Create a re-export initialization loop for a specific imported namespace.\n */\nfunction buildNamespaceReexport(\n metadata: ModuleMetadata,\n namespace: t.Identifier | t.CallExpression,\n constantReexports: boolean | void,\n) {\n return (\n constantReexports\n ? template.statement`\n Object.keys(NAMESPACE).forEach(function(key) {\n if (key === \"default\" || key === \"__esModule\") return;\n VERIFY_NAME_LIST;\n if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;\n\n EXPORTS[key] = NAMESPACE[key];\n });\n `\n : // Also skip already assigned bindings if they are strictly equal\n // to be somewhat more spec-compliant when a file has multiple\n // namespace re-exports that would cause a binding to be exported\n // multiple times. However, multiple bindings of the same name that\n // export the same primitive value are silently skipped\n // (the spec requires an \"ambiguous bindings\" early error here).\n template.statement`\n Object.keys(NAMESPACE).forEach(function(key) {\n if (key === \"default\" || key === \"__esModule\") return;\n VERIFY_NAME_LIST;\n if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;\n\n Object.defineProperty(EXPORTS, key, {\n enumerable: true,\n get: function() {\n return NAMESPACE[key];\n },\n });\n });\n `\n )({\n NAMESPACE: namespace,\n EXPORTS: metadata.exportName,\n VERIFY_NAME_LIST: metadata.exportNameListName\n ? template`\n if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;\n `({ EXPORTS_LIST: metadata.exportNameListName })\n : null,\n });\n}\n\n/**\n * Build a statement declaring a variable that contains all of the exported\n * variable names in an object so they can easily be referenced from an\n * export * from statement to check for conflicts.\n */\nfunction buildExportNameListDeclaration(\n programPath: NodePath,\n metadata: ModuleMetadata,\n) {\n const exportedVars = Object.create(null);\n for (const data of metadata.local.values()) {\n for (const name of data.names) {\n exportedVars[name] = true;\n }\n }\n\n let hasReexport = false;\n for (const data of metadata.source.values()) {\n for (const exportName of data.reexports.keys()) {\n exportedVars[exportName] = true;\n }\n for (const exportName of data.reexportNamespace) {\n exportedVars[exportName] = true;\n }\n\n hasReexport = hasReexport || !!data.reexportAll;\n }\n\n if (!hasReexport || Object.keys(exportedVars).length === 0) return null;\n\n const name = programPath.scope.generateUidIdentifier(\"exportNames\");\n\n delete exportedVars.default;\n\n return {\n name: name.name,\n statement: variableDeclaration(\"var\", [\n variableDeclarator(name, valueToNode(exportedVars)),\n ]),\n };\n}\n\n/**\n * Create a set of statements that will initialize all of the statically-known\n * export names with their expected values.\n */\nfunction buildExportInitializationStatements(\n programPath: NodePath,\n metadata: ModuleMetadata,\n constantReexports: boolean | void = false,\n noIncompleteNsImportDetection: boolean | void = false,\n) {\n const initStatements: Array<[string, t.Statement | null]> = [];\n\n for (const [localName, data] of metadata.local) {\n if (data.kind === \"import\") {\n // No-open since these are explicitly set with the \"reexports\" block.\n } else if (data.kind === \"hoisted\") {\n initStatements.push([\n // data.names is always of length 1 because a hoisted export\n // name must be id of a function declaration\n data.names[0],\n buildInitStatement(metadata, data.names, identifier(localName)),\n ]);\n } else if (!noIncompleteNsImportDetection) {\n for (const exportName of data.names) {\n initStatements.push([exportName, null]);\n }\n }\n }\n\n for (const data of metadata.source.values()) {\n if (!constantReexports) {\n const reexportsStatements = buildReexportsFromMeta(metadata, data, false);\n const reexports = [...data.reexports.keys()];\n for (let i = 0; i < reexportsStatements.length; i++) {\n initStatements.push([reexports[i], reexportsStatements[i]]);\n }\n }\n if (!noIncompleteNsImportDetection) {\n for (const exportName of data.reexportNamespace) {\n initStatements.push([exportName, null]);\n }\n }\n }\n\n // https://tc39.es/ecma262/#sec-module-namespace-exotic-objects\n // The [Exports] list is ordered as if an Array of those String values\n // had been sorted using %Array.prototype.sort% using undefined as comparefn\n initStatements.sort(([a], [b]) => {\n if (a < b) return -1;\n if (b < a) return 1;\n return 0;\n });\n\n const results = [];\n if (noIncompleteNsImportDetection) {\n for (const [, initStatement] of initStatements) {\n results.push(initStatement);\n }\n } else {\n // We generate init statements (`exports.a = exports.b = ... = void 0`)\n // for every 100 exported names to avoid deeply-nested AST structures.\n const chunkSize = 100;\n for (let i = 0; i < initStatements.length; i += chunkSize) {\n let uninitializedExportNames = [];\n for (let j = 0; j < chunkSize && i + j < initStatements.length; j++) {\n const [exportName, initStatement] = initStatements[i + j];\n if (initStatement !== null) {\n if (uninitializedExportNames.length > 0) {\n results.push(\n buildInitStatement(\n metadata,\n uninitializedExportNames,\n programPath.scope.buildUndefinedNode(),\n ),\n );\n // reset after uninitializedExportNames has been transformed\n // to init statements\n uninitializedExportNames = [];\n }\n results.push(initStatement);\n } else {\n uninitializedExportNames.push(exportName);\n }\n }\n if (uninitializedExportNames.length > 0) {\n results.push(\n buildInitStatement(\n metadata,\n uninitializedExportNames,\n programPath.scope.buildUndefinedNode(),\n ),\n );\n }\n }\n }\n\n return results;\n}\n\n/**\n * Given a set of export names, create a set of nested assignments to\n * initialize them all to a given expression.\n */\nconst InitTemplate = {\n computed: template.expression`EXPORTS[\"NAME\"] = VALUE`,\n default: template.expression`EXPORTS.NAME = VALUE`,\n};\n\nfunction buildInitStatement(\n metadata: ModuleMetadata,\n exportNames: string[],\n initExpr: t.Expression,\n) {\n const { stringSpecifiers, exportName: EXPORTS } = metadata;\n return expressionStatement(\n exportNames.reduce((acc, exportName) => {\n const params = {\n EXPORTS,\n NAME: exportName,\n VALUE: acc,\n };\n if (stringSpecifiers.has(exportName)) {\n return InitTemplate.computed(params);\n } else {\n return InitTemplate.default(params);\n }\n }, initExpr),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAgBA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,oBAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAN,OAAA;AAcA,IAAAO,cAAA,GAAAP,OAAA;AAaA,IAAAQ,cAAA,GAAAR,OAAA;AAA6D;EAhD3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G;MACbzD,OAAO;MACPJ,IAAI,EAAE3D,UAAU;MAChByH,KAAK,EAAEF;IACT,CAAC;IACD,IAAI9C,gBAAgB,CAACO,GAAG,CAAChF,UAAU,CAAC,EAAE;MACpC,OAAOiH,YAAY,CAACC,QAAQ,CAACM,MAAM,CAAC;IACtC,CAAC,MAAM;MACL,OAAOP,YAAY,CAACf,OAAO,CAACsB,MAAM,CAAC;IACrC;EACF,CAAC,EAAEH,QAAQ,CACb,CAAC;AACH"}
1
+ {"version":3,"names":["_assert","require","_core","_helperModuleImports","_rewriteThis","_rewriteLiveReferences","_normalizeAndLoadMetadata","_dynamicImport","_getModuleName","booleanLiteral","callExpression","cloneNode","directive","directiveLiteral","expressionStatement","identifier","isIdentifier","memberExpression","stringLiteral","valueToNode","variableDeclaration","variableDeclarator","t","exports","getDynamicImportSource","rewriteModuleStatementsAndPrepareHeader","path","exportName","strict","allowTopLevelThis","strictMode","noInterop","importInterop","lazy","esNamespaceOnly","filename","constantReexports","arguments","loose","enumerableModuleMeta","noIncompleteNsImportDetection","validateImportInteropOption","assert","isModule","node","sourceType","meta","normalizeModuleAndLoadMetadata","initializeReexports","rewriteThis","rewriteLiveReferences","hasStrict","directives","some","value","unshiftContainer","headers","hasExports","push","buildESModuleHeader","nameList","buildExportNameListDeclaration","exportNameListName","name","statement","buildExportInitializationStatements","ensureStatementsHoisted","statements","forEach","header","_blockHoist","wrapInterop","programPath","expr","type","hub","addHelper","helper","Error","buildNamespaceInitStatements","metadata","sourceMetadata","srcNamespace","localName","importsNamespace","template","NAME","SOURCE","buildReexportsFromMeta","reexportNamespace","EXPORTS","NAMESPACE","reexportAll","buildNamespaceReexport","loc","ReexportTemplate","constant","constantComputed","spec","namespace","stringSpecifiers","Array","from","reexports","importName","NAMESPACE_IMPORT","interop","has","astNodes","EXPORT_NAME","VERIFY_NAME_LIST","EXPORTS_LIST","exportedVars","Object","create","data","local","values","names","hasReexport","source","keys","length","scope","generateUidIdentifier","default","initStatements","kind","buildInitStatement","reexportsStatements","i","sort","a","b","results","initStatement","chunkSize","uninitializedExportNames","j","buildUndefinedNode","InitTemplate","computed","expression","exportNames","initExpr","reduce","acc","params","VALUE"],"sources":["../src/index.ts"],"sourcesContent":["import assert from \"assert\";\nimport { template, types as t } from \"@babel/core\";\n\nimport { isModule } from \"@babel/helper-module-imports\";\n\nimport rewriteThis from \"./rewrite-this\";\nimport rewriteLiveReferences from \"./rewrite-live-references\";\nimport normalizeModuleAndLoadMetadata, {\n hasExports,\n isSideEffectImport,\n validateImportInteropOption,\n} from \"./normalize-and-load-metadata\";\nimport type {\n ImportInterop,\n InteropType,\n Lazy,\n ModuleMetadata,\n SourceModuleMetadata,\n} from \"./normalize-and-load-metadata\";\nimport type { NodePath } from \"@babel/traverse\";\n\nconst {\n booleanLiteral,\n callExpression,\n cloneNode,\n directive,\n directiveLiteral,\n expressionStatement,\n identifier,\n isIdentifier,\n memberExpression,\n stringLiteral,\n valueToNode,\n variableDeclaration,\n variableDeclarator,\n} = t;\n\nexport { buildDynamicImport } from \"./dynamic-import\";\n\nif (!process.env.BABEL_8_BREAKING) {\n if (!USE_ESM) {\n if (!IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.getDynamicImportSource =\n // eslint-disable-next-line no-restricted-globals\n require(\"./dynamic-import\").getDynamicImportSource;\n }\n }\n}\n\nexport { default as getModuleName } from \"./get-module-name\";\nexport type { PluginOptions } from \"./get-module-name\";\n\nexport { hasExports, isSideEffectImport, isModule, rewriteThis };\n\nexport interface RewriteModuleStatementsAndPrepareHeaderOptions {\n exportName?: string;\n strict: boolean;\n allowTopLevelThis?: boolean;\n strictMode: boolean;\n loose?: boolean;\n importInterop?: ImportInterop;\n noInterop?: boolean;\n lazy?: Lazy;\n esNamespaceOnly?: boolean;\n filename: string | undefined;\n constantReexports?: boolean | void;\n enumerableModuleMeta?: boolean | void;\n noIncompleteNsImportDetection?: boolean | void;\n}\n\n/**\n * Perform all of the generic ES6 module rewriting needed to handle initial\n * module processing. This function will rewrite the majority of the given\n * program to reference the modules described by the returned metadata,\n * and returns a list of statements for use when initializing the module.\n */\nexport function rewriteModuleStatementsAndPrepareHeader(\n path: NodePath<t.Program>,\n {\n exportName,\n strict,\n allowTopLevelThis,\n strictMode,\n noInterop,\n importInterop = noInterop ? \"none\" : \"babel\",\n lazy,\n esNamespaceOnly,\n filename,\n\n constantReexports = process.env.BABEL_8_BREAKING\n ? undefined\n : arguments[1].loose,\n enumerableModuleMeta = process.env.BABEL_8_BREAKING\n ? undefined\n : arguments[1].loose,\n noIncompleteNsImportDetection,\n }: RewriteModuleStatementsAndPrepareHeaderOptions,\n) {\n validateImportInteropOption(importInterop);\n assert(isModule(path), \"Cannot process module statements in a script\");\n path.node.sourceType = \"script\";\n\n const meta = normalizeModuleAndLoadMetadata(path, exportName, {\n importInterop,\n initializeReexports: constantReexports,\n lazy,\n esNamespaceOnly,\n filename,\n });\n\n if (!allowTopLevelThis) {\n rewriteThis(path);\n }\n\n rewriteLiveReferences(path, meta);\n\n if (strictMode !== false) {\n const hasStrict = path.node.directives.some(directive => {\n return directive.value.value === \"use strict\";\n });\n if (!hasStrict) {\n path.unshiftContainer(\n \"directives\",\n directive(directiveLiteral(\"use strict\")),\n );\n }\n }\n\n const headers = [];\n if (hasExports(meta) && !strict) {\n headers.push(buildESModuleHeader(meta, enumerableModuleMeta));\n }\n\n const nameList = buildExportNameListDeclaration(path, meta);\n\n if (nameList) {\n meta.exportNameListName = nameList.name;\n headers.push(nameList.statement);\n }\n\n // Create all of the statically known named exports.\n headers.push(\n ...buildExportInitializationStatements(\n path,\n meta,\n constantReexports,\n noIncompleteNsImportDetection,\n ),\n );\n\n return { meta, headers };\n}\n\n/**\n * Flag a set of statements as hoisted above all else so that module init\n * statements all run before user code.\n */\nexport function ensureStatementsHoisted(statements: t.Statement[]) {\n // Force all of the header fields to be at the top of the file.\n statements.forEach(header => {\n // @ts-expect-error Fixme: handle _blockHoist property\n header._blockHoist = 3;\n });\n}\n\n/**\n * Given an expression for a standard import object, like \"require('foo')\",\n * wrap it in a call to the interop helpers based on the type.\n */\nexport function wrapInterop(\n programPath: NodePath,\n expr: t.Expression,\n type: InteropType,\n): t.CallExpression {\n if (type === \"none\") {\n return null;\n }\n\n if (type === \"node-namespace\") {\n return callExpression(programPath.hub.addHelper(\"interopRequireWildcard\"), [\n expr,\n booleanLiteral(true),\n ]);\n } else if (type === \"node-default\") {\n return null;\n }\n\n let helper;\n if (type === \"default\") {\n helper = \"interopRequireDefault\";\n } else if (type === \"namespace\") {\n helper = \"interopRequireWildcard\";\n } else {\n throw new Error(`Unknown interop: ${type}`);\n }\n\n return callExpression(programPath.hub.addHelper(helper), [expr]);\n}\n\n/**\n * Create the runtime initialization statements for a given requested source.\n * These will initialize all of the runtime import/export logic that\n * can't be handled statically by the statements created by\n * buildExportInitializationStatements().\n */\nexport function buildNamespaceInitStatements(\n metadata: ModuleMetadata,\n sourceMetadata: SourceModuleMetadata,\n constantReexports: boolean | void = false,\n) {\n const statements = [];\n\n let srcNamespace: t.Node = identifier(sourceMetadata.name);\n if (sourceMetadata.lazy) srcNamespace = callExpression(srcNamespace, []);\n\n for (const localName of sourceMetadata.importsNamespace) {\n if (localName === sourceMetadata.name) continue;\n\n // Create and assign binding to namespace object\n statements.push(\n template.statement`var NAME = SOURCE;`({\n NAME: localName,\n SOURCE: cloneNode(srcNamespace),\n }),\n );\n }\n if (constantReexports) {\n statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true));\n }\n for (const exportName of sourceMetadata.reexportNamespace) {\n // Assign export to namespace object.\n statements.push(\n (sourceMetadata.lazy\n ? template.statement`\n Object.defineProperty(EXPORTS, \"NAME\", {\n enumerable: true,\n get: function() {\n return NAMESPACE;\n }\n });\n `\n : template.statement`EXPORTS.NAME = NAMESPACE;`)({\n EXPORTS: metadata.exportName,\n NAME: exportName,\n NAMESPACE: cloneNode(srcNamespace),\n }),\n );\n }\n if (sourceMetadata.reexportAll) {\n const statement = buildNamespaceReexport(\n metadata,\n cloneNode(srcNamespace),\n constantReexports,\n );\n statement.loc = sourceMetadata.reexportAll.loc;\n\n // Iterate props creating getter for each prop.\n statements.push(statement);\n }\n return statements;\n}\n\nconst ReexportTemplate = {\n constant: template.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`,\n constantComputed: template.statement`EXPORTS[\"EXPORT_NAME\"] = NAMESPACE_IMPORT;`,\n spec: template.statement`\n Object.defineProperty(EXPORTS, \"EXPORT_NAME\", {\n enumerable: true,\n get: function() {\n return NAMESPACE_IMPORT;\n },\n });\n `,\n};\n\nfunction buildReexportsFromMeta(\n meta: ModuleMetadata,\n metadata: SourceModuleMetadata,\n constantReexports: boolean,\n) {\n const namespace = metadata.lazy\n ? callExpression(identifier(metadata.name), [])\n : identifier(metadata.name);\n\n const { stringSpecifiers } = meta;\n return Array.from(metadata.reexports, ([exportName, importName]) => {\n let NAMESPACE_IMPORT: t.Expression = cloneNode(namespace);\n if (importName === \"default\" && metadata.interop === \"node-default\") {\n // Nothing, it's ok as-is\n } else if (stringSpecifiers.has(importName)) {\n NAMESPACE_IMPORT = memberExpression(\n NAMESPACE_IMPORT,\n stringLiteral(importName),\n true,\n );\n } else {\n NAMESPACE_IMPORT = memberExpression(\n NAMESPACE_IMPORT,\n identifier(importName),\n );\n }\n const astNodes = {\n EXPORTS: meta.exportName,\n EXPORT_NAME: exportName,\n NAMESPACE_IMPORT,\n };\n if (constantReexports || isIdentifier(NAMESPACE_IMPORT)) {\n if (stringSpecifiers.has(exportName)) {\n return ReexportTemplate.constantComputed(astNodes);\n } else {\n return ReexportTemplate.constant(astNodes);\n }\n } else {\n return ReexportTemplate.spec(astNodes);\n }\n });\n}\n\n/**\n * Build an \"__esModule\" header statement setting the property on a given object.\n */\nfunction buildESModuleHeader(\n metadata: ModuleMetadata,\n enumerableModuleMeta: boolean | void = false,\n) {\n return (\n enumerableModuleMeta\n ? template.statement`\n EXPORTS.__esModule = true;\n `\n : template.statement`\n Object.defineProperty(EXPORTS, \"__esModule\", {\n value: true,\n });\n `\n )({ EXPORTS: metadata.exportName });\n}\n\n/**\n * Create a re-export initialization loop for a specific imported namespace.\n */\nfunction buildNamespaceReexport(\n metadata: ModuleMetadata,\n namespace: t.Identifier | t.CallExpression,\n constantReexports: boolean | void,\n) {\n return (\n constantReexports\n ? template.statement`\n Object.keys(NAMESPACE).forEach(function(key) {\n if (key === \"default\" || key === \"__esModule\") return;\n VERIFY_NAME_LIST;\n if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;\n\n EXPORTS[key] = NAMESPACE[key];\n });\n `\n : // Also skip already assigned bindings if they are strictly equal\n // to be somewhat more spec-compliant when a file has multiple\n // namespace re-exports that would cause a binding to be exported\n // multiple times. However, multiple bindings of the same name that\n // export the same primitive value are silently skipped\n // (the spec requires an \"ambiguous bindings\" early error here).\n template.statement`\n Object.keys(NAMESPACE).forEach(function(key) {\n if (key === \"default\" || key === \"__esModule\") return;\n VERIFY_NAME_LIST;\n if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;\n\n Object.defineProperty(EXPORTS, key, {\n enumerable: true,\n get: function() {\n return NAMESPACE[key];\n },\n });\n });\n `\n )({\n NAMESPACE: namespace,\n EXPORTS: metadata.exportName,\n VERIFY_NAME_LIST: metadata.exportNameListName\n ? template`\n if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;\n `({ EXPORTS_LIST: metadata.exportNameListName })\n : null,\n });\n}\n\n/**\n * Build a statement declaring a variable that contains all of the exported\n * variable names in an object so they can easily be referenced from an\n * export * from statement to check for conflicts.\n */\nfunction buildExportNameListDeclaration(\n programPath: NodePath,\n metadata: ModuleMetadata,\n) {\n const exportedVars = Object.create(null);\n for (const data of metadata.local.values()) {\n for (const name of data.names) {\n exportedVars[name] = true;\n }\n }\n\n let hasReexport = false;\n for (const data of metadata.source.values()) {\n for (const exportName of data.reexports.keys()) {\n exportedVars[exportName] = true;\n }\n for (const exportName of data.reexportNamespace) {\n exportedVars[exportName] = true;\n }\n\n hasReexport = hasReexport || !!data.reexportAll;\n }\n\n if (!hasReexport || Object.keys(exportedVars).length === 0) return null;\n\n const name = programPath.scope.generateUidIdentifier(\"exportNames\");\n\n delete exportedVars.default;\n\n return {\n name: name.name,\n statement: variableDeclaration(\"var\", [\n variableDeclarator(name, valueToNode(exportedVars)),\n ]),\n };\n}\n\n/**\n * Create a set of statements that will initialize all of the statically-known\n * export names with their expected values.\n */\nfunction buildExportInitializationStatements(\n programPath: NodePath,\n metadata: ModuleMetadata,\n constantReexports: boolean | void = false,\n noIncompleteNsImportDetection: boolean | void = false,\n) {\n const initStatements: Array<[string, t.Statement | null]> = [];\n\n for (const [localName, data] of metadata.local) {\n if (data.kind === \"import\") {\n // No-open since these are explicitly set with the \"reexports\" block.\n } else if (data.kind === \"hoisted\") {\n initStatements.push([\n // data.names is always of length 1 because a hoisted export\n // name must be id of a function declaration\n data.names[0],\n buildInitStatement(metadata, data.names, identifier(localName)),\n ]);\n } else if (!noIncompleteNsImportDetection) {\n for (const exportName of data.names) {\n initStatements.push([exportName, null]);\n }\n }\n }\n\n for (const data of metadata.source.values()) {\n if (!constantReexports) {\n const reexportsStatements = buildReexportsFromMeta(metadata, data, false);\n const reexports = [...data.reexports.keys()];\n for (let i = 0; i < reexportsStatements.length; i++) {\n initStatements.push([reexports[i], reexportsStatements[i]]);\n }\n }\n if (!noIncompleteNsImportDetection) {\n for (const exportName of data.reexportNamespace) {\n initStatements.push([exportName, null]);\n }\n }\n }\n\n // https://tc39.es/ecma262/#sec-module-namespace-exotic-objects\n // The [Exports] list is ordered as if an Array of those String values\n // had been sorted using %Array.prototype.sort% using undefined as comparefn\n initStatements.sort(([a], [b]) => {\n if (a < b) return -1;\n if (b < a) return 1;\n return 0;\n });\n\n const results = [];\n if (noIncompleteNsImportDetection) {\n for (const [, initStatement] of initStatements) {\n results.push(initStatement);\n }\n } else {\n // We generate init statements (`exports.a = exports.b = ... = void 0`)\n // for every 100 exported names to avoid deeply-nested AST structures.\n const chunkSize = 100;\n for (let i = 0; i < initStatements.length; i += chunkSize) {\n let uninitializedExportNames = [];\n for (let j = 0; j < chunkSize && i + j < initStatements.length; j++) {\n const [exportName, initStatement] = initStatements[i + j];\n if (initStatement !== null) {\n if (uninitializedExportNames.length > 0) {\n results.push(\n buildInitStatement(\n metadata,\n uninitializedExportNames,\n programPath.scope.buildUndefinedNode(),\n ),\n );\n // reset after uninitializedExportNames has been transformed\n // to init statements\n uninitializedExportNames = [];\n }\n results.push(initStatement);\n } else {\n uninitializedExportNames.push(exportName);\n }\n }\n if (uninitializedExportNames.length > 0) {\n results.push(\n buildInitStatement(\n metadata,\n uninitializedExportNames,\n programPath.scope.buildUndefinedNode(),\n ),\n );\n }\n }\n }\n\n return results;\n}\n\n/**\n * Given a set of export names, create a set of nested assignments to\n * initialize them all to a given expression.\n */\nconst InitTemplate = {\n computed: template.expression`EXPORTS[\"NAME\"] = VALUE`,\n default: template.expression`EXPORTS.NAME = VALUE`,\n};\n\nfunction buildInitStatement(\n metadata: ModuleMetadata,\n exportNames: string[],\n initExpr: t.Expression,\n) {\n const { stringSpecifiers, exportName: EXPORTS } = metadata;\n return expressionStatement(\n exportNames.reduce((acc, exportName) => {\n const params = {\n EXPORTS,\n NAME: exportName,\n VALUE: acc,\n };\n if (stringSpecifiers.has(exportName)) {\n return InitTemplate.computed(params);\n } else {\n return InitTemplate.default(params);\n }\n }, initExpr),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAL,OAAA;AA8BA,IAAAM,cAAA,GAAAN,OAAA;AAaA,IAAAO,cAAA,GAAAP,OAAA;AA7BA,MAAM;EACJQ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O;MACPJ,IAAI,EAAE3D,UAAU;MAChByH,KAAK,EAAEF;IACT,CAAC;IACD,IAAI9C,gBAAgB,CAACO,GAAG,CAAChF,UAAU,CAAC,EAAE;MACpC,OAAOiH,YAAY,CAACC,QAAQ,CAACM,MAAM,CAAC;IACtC,CAAC,MAAM;MACL,OAAOP,YAAY,CAACf,OAAO,CAACsB,MAAM,CAAC;IACrC;EACF,CAAC,EAAEH,QAAQ,CACb,CAAC;AACH"}
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = rewriteLiveReferences;
7
7
  var _assert = require("assert");
8
- var _t = require("@babel/types");
9
- var _template = require("@babel/template");
8
+ var _core = require("@babel/core");
10
9
  var _helperSimpleAccess = require("@babel/helper-simple-access");
11
10
  const {
12
11
  assignmentExpression,
@@ -25,7 +24,7 @@ const {
25
24
  stringLiteral,
26
25
  variableDeclaration,
27
26
  variableDeclarator
28
- } = _t;
27
+ } = _core.types;
29
28
  function isInType(path) {
30
29
  do {
31
30
  switch (path.parent.type) {
@@ -158,7 +157,7 @@ const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr
158
157
  }, localExpr);
159
158
  };
160
159
  const buildImportThrow = localName => {
161
- return _template.default.expression.ast`
160
+ return _core.template.expression.ast`
162
161
  (function() {
163
162
  throw new Error('"' + '${localName}' + '" is read-only.');
164
163
  })()
@@ -1 +1 @@
1
- {"version":3,"names":["_assert","require","_t","_template","_helperSimpleAccess","assignmentExpression","callExpression","cloneNode","expressionStatement","getOuterBindingIdentifiers","identifier","isMemberExpression","isVariableDeclaration","jsxIdentifier","jsxMemberExpression","memberExpression","numericLiteral","sequenceExpression","stringLiteral","variableDeclaration","variableDeclarator","isInType","path","parent","type","parentPath","exportKind","isStatement","isExpression","rewriteLiveReferences","programPath","metadata","imported","Map","exported","requeueInParent","requeue","source","data","localName","importName","imports","set","importsNamespace","local","exportMeta","get","push","names","rewriteBindingInitVisitorState","scope","traverse","rewriteBindingInitVisitor","bindingNames","Set","Array","from","keys","simplifyAccess","rewriteReferencesVisitorState","seen","WeakSet","buildImportReference","identNode","meta","referenced","lazy","namespace","name","interop","computed","stringSpecifiers","has","rewriteReferencesVisitor","Scope","skip","ClassDeclaration","id","node","Error","exportNames","length","statement","buildBindingExportAssignmentExpression","_blockHoist","insertAfter","VariableDeclaration","Object","forEach","localExpr","exportsObjectName","exportName","currentScope","hasOwnBinding","rename","reduce","expr","buildImportThrow","template","expression","ast","ReferencedIdentifier","add","importData","buildCodeFrameError","localBinding","getBinding","rootBinding","ref","loc","isCallExpression","callee","isOptionalCallExpression","isTaggedTemplateExpression","tag","replaceWith","isJSXIdentifier","object","property","UpdateExpression","arg","update","isIdentifier","exportedNames","operator","prefix","generateDeclaredUidIdentifier","AssignmentExpression","exit","left","assert","assignment","right","ids","programScopeIds","filter","find","items","isExpressionStatement","ForOfStatement|ForInStatement","programScope","didTransformExport","importConstViolationName","loopBodyScope","ensureBlock","bodyPath","newLoopId","generateUidIdentifierBasedOnNode","registerDeclaration","unshiftContainer"],"sources":["../src/rewrite-live-references.ts"],"sourcesContent":["import assert from \"assert\";\nimport {\n assignmentExpression,\n callExpression,\n cloneNode,\n expressionStatement,\n getOuterBindingIdentifiers,\n identifier,\n isMemberExpression,\n isVariableDeclaration,\n jsxIdentifier,\n jsxMemberExpression,\n memberExpression,\n numericLiteral,\n sequenceExpression,\n stringLiteral,\n variableDeclaration,\n variableDeclarator,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport template from \"@babel/template\";\nimport type { NodePath, Visitor, Scope } from \"@babel/traverse\";\nimport simplifyAccess from \"@babel/helper-simple-access\";\n\nimport type { ModuleMetadata } from \"./normalize-and-load-metadata\";\n\ninterface RewriteReferencesVisitorState {\n exported: Map<any, any>;\n metadata: ModuleMetadata;\n requeueInParent: (path: NodePath) => void;\n scope: Scope;\n imported: Map<any, any>;\n buildImportReference: (\n [source, importName, localName]: readonly [string, string, string],\n identNode: t.Identifier | t.CallExpression | t.JSXIdentifier,\n ) => any;\n seen: WeakSet<object>;\n}\n\ninterface RewriteBindingInitVisitorState {\n exported: Map<any, any>;\n metadata: ModuleMetadata;\n requeueInParent: (path: NodePath) => void;\n scope: Scope;\n}\n\nfunction isInType(path: NodePath) {\n do {\n switch (path.parent.type) {\n case \"TSTypeAnnotation\":\n case \"TSTypeAliasDeclaration\":\n case \"TSTypeReference\":\n case \"TypeAnnotation\":\n case \"TypeAlias\":\n return true;\n case \"ExportSpecifier\":\n return (\n (\n path.parentPath.parent as\n | t.ExportDefaultDeclaration\n | t.ExportNamedDeclaration\n ).exportKind === \"type\"\n );\n default:\n if (path.parentPath.isStatement() || path.parentPath.isExpression()) {\n return false;\n }\n }\n } while ((path = path.parentPath));\n}\n\nexport default function rewriteLiveReferences(\n programPath: NodePath<t.Program>,\n metadata: ModuleMetadata,\n) {\n const imported = new Map();\n const exported = new Map();\n const requeueInParent = (path: NodePath) => {\n // Manually re-queue `exports.default =` expressions so that the ES3\n // transform has an opportunity to convert them. Ideally this would\n // happen automatically from the replaceWith above. See #4140 for\n // more info.\n programPath.requeue(path);\n };\n\n for (const [source, data] of metadata.source) {\n for (const [localName, importName] of data.imports) {\n imported.set(localName, [source, importName, null]);\n }\n for (const localName of data.importsNamespace) {\n imported.set(localName, [source, null, localName]);\n }\n }\n\n for (const [local, data] of metadata.local) {\n let exportMeta = exported.get(local);\n if (!exportMeta) {\n exportMeta = [];\n exported.set(local, exportMeta);\n }\n\n exportMeta.push(...data.names);\n }\n\n // Rewrite initialization of bindings to update exports.\n const rewriteBindingInitVisitorState: RewriteBindingInitVisitorState = {\n metadata,\n requeueInParent,\n scope: programPath.scope,\n exported, // local name => exported name list\n };\n programPath.traverse(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n rewriteBindingInitVisitor,\n rewriteBindingInitVisitorState,\n );\n\n // NOTE(logan): The 'Array.from' calls are to make this code with in loose mode.\n const bindingNames = new Set([\n ...Array.from(imported.keys()),\n ...Array.from(exported.keys()),\n ]);\n if (process.env.BABEL_8_BREAKING) {\n simplifyAccess(programPath, bindingNames);\n } else {\n // @ts-ignore(Babel 7 vs Babel 8) The third param has been removed in Babel 8.\n simplifyAccess(programPath, bindingNames, false);\n }\n\n // Rewrite reads/writes from imports and exports to have the correct behavior.\n const rewriteReferencesVisitorState: RewriteReferencesVisitorState = {\n seen: new WeakSet(),\n metadata,\n requeueInParent,\n scope: programPath.scope,\n imported, // local / import\n exported, // local name => exported name list\n buildImportReference: ([source, importName, localName], identNode) => {\n const meta = metadata.source.get(source);\n meta.referenced = true;\n\n if (localName) {\n if (meta.lazy) {\n identNode = callExpression(\n // @ts-expect-error Fixme: we should handle the case when identNode is a JSXIdentifier\n identNode,\n [],\n );\n }\n return identNode;\n }\n\n let namespace: t.Expression = identifier(meta.name);\n if (meta.lazy) namespace = callExpression(namespace, []);\n\n if (importName === \"default\" && meta.interop === \"node-default\") {\n return namespace;\n }\n\n const computed = metadata.stringSpecifiers.has(importName);\n\n return memberExpression(\n namespace,\n computed ? stringLiteral(importName) : identifier(importName),\n computed,\n );\n },\n };\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState);\n}\n\n/**\n * A visitor to inject export update statements during binding initialization.\n */\nconst rewriteBindingInitVisitor: Visitor<RewriteBindingInitVisitorState> = {\n Scope(path) {\n path.skip();\n },\n ClassDeclaration(path) {\n const { requeueInParent, exported, metadata } = this;\n\n const { id } = path.node;\n if (!id) throw new Error(\"Expected class to have a name\");\n const localName = id.name;\n\n const exportNames = exported.get(localName) || [];\n if (exportNames.length > 0) {\n const statement = expressionStatement(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n buildBindingExportAssignmentExpression(\n metadata,\n exportNames,\n identifier(localName),\n path.scope,\n ),\n );\n // @ts-expect-error todo(flow->ts): avoid mutations\n statement._blockHoist = path.node._blockHoist;\n\n requeueInParent(path.insertAfter(statement)[0]);\n }\n },\n VariableDeclaration(path) {\n const { requeueInParent, exported, metadata } = this;\n\n Object.keys(path.getOuterBindingIdentifiers()).forEach(localName => {\n const exportNames = exported.get(localName) || [];\n\n if (exportNames.length > 0) {\n const statement = expressionStatement(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n buildBindingExportAssignmentExpression(\n metadata,\n exportNames,\n identifier(localName),\n path.scope,\n ),\n );\n // @ts-expect-error todo(flow->ts): avoid mutations\n statement._blockHoist = path.node._blockHoist;\n\n requeueInParent(path.insertAfter(statement)[0]);\n }\n });\n },\n};\n\nconst buildBindingExportAssignmentExpression = (\n metadata: ModuleMetadata,\n exportNames: string[],\n localExpr: t.Expression,\n scope: Scope,\n) => {\n const exportsObjectName = metadata.exportName;\n for (\n let currentScope = scope;\n currentScope != null;\n currentScope = currentScope.parent\n ) {\n if (currentScope.hasOwnBinding(exportsObjectName)) {\n currentScope.rename(exportsObjectName);\n }\n }\n return (exportNames || []).reduce((expr, exportName) => {\n // class Foo {} export { Foo, Foo as Bar };\n // as\n // class Foo {} exports.Foo = exports.Bar = Foo;\n const { stringSpecifiers } = metadata;\n const computed = stringSpecifiers.has(exportName);\n return assignmentExpression(\n \"=\",\n memberExpression(\n identifier(exportsObjectName),\n computed ? stringLiteral(exportName) : identifier(exportName),\n /* computed */ computed,\n ),\n expr,\n );\n }, localExpr);\n};\n\nconst buildImportThrow = (localName: string) => {\n return template.expression.ast`\n (function() {\n throw new Error('\"' + '${localName}' + '\" is read-only.');\n })()\n `;\n};\n\nconst rewriteReferencesVisitor: Visitor<RewriteReferencesVisitorState> = {\n ReferencedIdentifier(path) {\n const { seen, buildImportReference, scope, imported, requeueInParent } =\n this;\n if (seen.has(path.node)) return;\n seen.add(path.node);\n\n const localName = path.node.name;\n\n const importData = imported.get(localName);\n if (importData) {\n if (isInType(path)) {\n throw path.buildCodeFrameError(\n `Cannot transform the imported binding \"${localName}\" since it's also used in a type annotation. ` +\n `Please strip type annotations using @babel/preset-typescript or @babel/preset-flow.`,\n );\n }\n\n const localBinding = path.scope.getBinding(localName);\n const rootBinding = scope.getBinding(localName);\n\n // redeclared in this scope\n if (rootBinding !== localBinding) return;\n\n const ref = buildImportReference(importData, path.node);\n\n // Preserve the binding location so that sourcemaps are nicer.\n ref.loc = path.node.loc;\n\n if (\n (path.parentPath.isCallExpression({ callee: path.node }) ||\n path.parentPath.isOptionalCallExpression({ callee: path.node }) ||\n path.parentPath.isTaggedTemplateExpression({ tag: path.node })) &&\n isMemberExpression(ref)\n ) {\n path.replaceWith(sequenceExpression([numericLiteral(0), ref]));\n } else if (path.isJSXIdentifier() && isMemberExpression(ref)) {\n const { object, property } = ref;\n path.replaceWith(\n jsxMemberExpression(\n // @ts-expect-error todo(flow->ts): possible bug `object` might not have a name\n jsxIdentifier(object.name),\n // @ts-expect-error todo(flow->ts): possible bug `property` might not have a name\n jsxIdentifier(property.name),\n ),\n );\n } else {\n path.replaceWith(ref);\n }\n\n requeueInParent(path);\n\n // The path could have been replaced with an identifier that would\n // otherwise be re-visited, so we skip processing its children.\n path.skip();\n }\n },\n\n UpdateExpression(path) {\n const {\n scope,\n seen,\n imported,\n exported,\n requeueInParent,\n buildImportReference,\n } = this;\n\n if (seen.has(path.node)) return;\n\n seen.add(path.node);\n\n const arg = path.get(\"argument\");\n\n // No change needed\n if (arg.isMemberExpression()) return;\n\n const update = path.node;\n\n if (arg.isIdentifier()) {\n const localName = arg.node.name;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n const exportedNames = exported.get(localName);\n const importData = imported.get(localName);\n\n if (exportedNames?.length > 0 || importData) {\n if (importData) {\n path.replaceWith(\n assignmentExpression(\n update.operator[0] + \"=\",\n buildImportReference(importData, arg.node),\n buildImportThrow(localName),\n ),\n );\n } else if (update.prefix) {\n // ++foo\n // => exports.foo = ++foo\n path.replaceWith(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n cloneNode(update),\n path.scope,\n ),\n );\n } else {\n // foo++\n // => (ref = i++, exports.i = i, ref)\n const ref = scope.generateDeclaredUidIdentifier(localName);\n\n path.replaceWith(\n sequenceExpression([\n assignmentExpression(\"=\", cloneNode(ref), cloneNode(update)),\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n identifier(localName),\n path.scope,\n ),\n cloneNode(ref),\n ]),\n );\n }\n }\n }\n\n requeueInParent(path);\n path.skip();\n },\n\n AssignmentExpression: {\n exit(path) {\n const {\n scope,\n seen,\n imported,\n exported,\n requeueInParent,\n buildImportReference,\n } = this;\n\n if (seen.has(path.node)) return;\n seen.add(path.node);\n\n const left = path.get(\"left\");\n\n // No change needed\n if (left.isMemberExpression()) return;\n\n if (left.isIdentifier()) {\n // Simple update-assign foo += 1; export { foo };\n // => exports.foo = (foo += 1);\n const localName = left.node.name;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n const exportedNames = exported.get(localName);\n const importData = imported.get(localName);\n if (exportedNames?.length > 0 || importData) {\n assert(path.node.operator === \"=\", \"Path was not simplified\");\n\n const assignment = path.node;\n\n if (importData) {\n assignment.left = buildImportReference(importData, left.node);\n\n assignment.right = sequenceExpression([\n assignment.right,\n buildImportThrow(localName),\n ]);\n }\n\n path.replaceWith(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n assignment,\n path.scope,\n ),\n );\n requeueInParent(path);\n }\n } else {\n const ids = left.getOuterBindingIdentifiers();\n const programScopeIds = Object.keys(ids).filter(\n localName =>\n scope.getBinding(localName) === path.scope.getBinding(localName),\n );\n const id = programScopeIds.find(localName => imported.has(localName));\n\n if (id) {\n path.node.right = sequenceExpression([\n path.node.right,\n buildImportThrow(id),\n ]);\n }\n\n // Complex ({a, b, c} = {}); export { a, c };\n // => ({a, b, c} = {}), (exports.a = a, exports.c = c);\n const items: t.Expression[] = [];\n programScopeIds.forEach(localName => {\n const exportedNames = exported.get(localName) || [];\n if (exportedNames.length > 0) {\n items.push(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n identifier(localName),\n path.scope,\n ),\n );\n }\n });\n\n if (items.length > 0) {\n let node: t.Node = sequenceExpression(items);\n if (path.parentPath.isExpressionStatement()) {\n node = expressionStatement(node);\n // @ts-expect-error todo(flow->ts): avoid mutations\n node._blockHoist = path.parentPath.node._blockHoist;\n }\n\n const statement = path.insertAfter(node)[0];\n requeueInParent(statement);\n }\n }\n },\n },\n \"ForOfStatement|ForInStatement\"(\n path: NodePath<t.ForOfStatement | t.ForInStatement>,\n ) {\n const { scope, node } = path;\n const { left } = node;\n const { exported, imported, scope: programScope } = this;\n\n if (!isVariableDeclaration(left)) {\n let didTransformExport = false,\n importConstViolationName;\n const loopBodyScope = path.get(\"body\").scope;\n for (const name of Object.keys(getOuterBindingIdentifiers(left))) {\n if (programScope.getBinding(name) === scope.getBinding(name)) {\n if (exported.has(name)) {\n didTransformExport = true;\n if (loopBodyScope.hasOwnBinding(name)) {\n loopBodyScope.rename(name);\n }\n }\n if (imported.has(name) && !importConstViolationName) {\n importConstViolationName = name;\n }\n }\n }\n if (!didTransformExport && !importConstViolationName) {\n return;\n }\n\n path.ensureBlock();\n const bodyPath = path.get(\"body\");\n\n const newLoopId = scope.generateUidIdentifierBasedOnNode(left);\n path\n .get(\"left\")\n .replaceWith(\n variableDeclaration(\"let\", [\n variableDeclarator(cloneNode(newLoopId)),\n ]),\n );\n scope.registerDeclaration(path.get(\"left\"));\n\n if (didTransformExport) {\n bodyPath.unshiftContainer(\n \"body\",\n expressionStatement(assignmentExpression(\"=\", left, newLoopId)),\n );\n }\n if (importConstViolationName) {\n bodyPath.unshiftContainer(\n \"body\",\n expressionStatement(buildImportThrow(importConstViolationName)),\n );\n }\n }\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAmBA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAAyD;EApBvDI,o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AACwB,GAAG,CAAC,MAAM,CAAC;MAEjC,MAAMoG,SAAS,GAAGhG,KAAK,CAACiG,gCAAgC,CAAClB,IAAI,CAAC;MAC9D3G,IAAI,CACDwB,GAAG,CAAC,MAAM,CAAC,CACXqE,WAAW,CACVhG,mBAAmB,CAAC,KAAK,EAAE,CACzBC,kBAAkB,CAACb,SAAS,CAAC2I,SAAS,CAAC,CAAC,CACzC,CACH,CAAC;MACHhG,KAAK,CAACkG,mBAAmB,CAAC9H,IAAI,CAACwB,GAAG,CAAC,MAAM,CAAC,CAAC;MAE3C,IAAI+F,kBAAkB,EAAE;QACtBI,QAAQ,CAACI,gBAAgB,CACvB,MAAM,EACN7I,mBAAmB,CAACH,oBAAoB,CAAC,GAAG,EAAE4H,IAAI,EAAEiB,SAAS,CAAC,CAChE,CAAC;MACH;MACA,IAAIJ,wBAAwB,EAAE;QAC5BG,QAAQ,CAACI,gBAAgB,CACvB,MAAM,EACN7I,mBAAmB,CAACyF,gBAAgB,CAAC6C,wBAAwB,CAAC,CAChE,CAAC;MACH;IACF;EACF;AACF,CAAC"}
1
+ {"version":3,"names":["_assert","require","_core","_helperSimpleAccess","assignmentExpression","callExpression","cloneNode","expressionStatement","getOuterBindingIdentifiers","identifier","isMemberExpression","isVariableDeclaration","jsxIdentifier","jsxMemberExpression","memberExpression","numericLiteral","sequenceExpression","stringLiteral","variableDeclaration","variableDeclarator","t","isInType","path","parent","type","parentPath","exportKind","isStatement","isExpression","rewriteLiveReferences","programPath","metadata","imported","Map","exported","requeueInParent","requeue","source","data","localName","importName","imports","set","importsNamespace","local","exportMeta","get","push","names","rewriteBindingInitVisitorState","scope","traverse","rewriteBindingInitVisitor","bindingNames","Set","Array","from","keys","simplifyAccess","rewriteReferencesVisitorState","seen","WeakSet","buildImportReference","identNode","meta","referenced","lazy","namespace","name","interop","computed","stringSpecifiers","has","rewriteReferencesVisitor","Scope","skip","ClassDeclaration","id","node","Error","exportNames","length","statement","buildBindingExportAssignmentExpression","_blockHoist","insertAfter","VariableDeclaration","Object","forEach","localExpr","exportsObjectName","exportName","currentScope","hasOwnBinding","rename","reduce","expr","buildImportThrow","template","expression","ast","ReferencedIdentifier","add","importData","buildCodeFrameError","localBinding","getBinding","rootBinding","ref","loc","isCallExpression","callee","isOptionalCallExpression","isTaggedTemplateExpression","tag","replaceWith","isJSXIdentifier","object","property","UpdateExpression","arg","update","isIdentifier","exportedNames","operator","prefix","generateDeclaredUidIdentifier","AssignmentExpression","exit","left","assert","assignment","right","ids","programScopeIds","filter","find","items","isExpressionStatement","ForOfStatement|ForInStatement","programScope","didTransformExport","importConstViolationName","loopBodyScope","ensureBlock","bodyPath","newLoopId","generateUidIdentifierBasedOnNode","registerDeclaration","unshiftContainer"],"sources":["../src/rewrite-live-references.ts"],"sourcesContent":["import assert from \"assert\";\nimport { template, types as t } from \"@babel/core\";\nimport type { NodePath, Visitor, Scope } from \"@babel/traverse\";\nimport simplifyAccess from \"@babel/helper-simple-access\";\n\nimport type { ModuleMetadata } from \"./normalize-and-load-metadata\";\n\nconst {\n assignmentExpression,\n callExpression,\n cloneNode,\n expressionStatement,\n getOuterBindingIdentifiers,\n identifier,\n isMemberExpression,\n isVariableDeclaration,\n jsxIdentifier,\n jsxMemberExpression,\n memberExpression,\n numericLiteral,\n sequenceExpression,\n stringLiteral,\n variableDeclaration,\n variableDeclarator,\n} = t;\n\ninterface RewriteReferencesVisitorState {\n exported: Map<any, any>;\n metadata: ModuleMetadata;\n requeueInParent: (path: NodePath) => void;\n scope: Scope;\n imported: Map<any, any>;\n buildImportReference: (\n [source, importName, localName]: readonly [string, string, string],\n identNode: t.Identifier | t.CallExpression | t.JSXIdentifier,\n ) => any;\n seen: WeakSet<object>;\n}\n\ninterface RewriteBindingInitVisitorState {\n exported: Map<any, any>;\n metadata: ModuleMetadata;\n requeueInParent: (path: NodePath) => void;\n scope: Scope;\n}\n\nfunction isInType(path: NodePath) {\n do {\n switch (path.parent.type) {\n case \"TSTypeAnnotation\":\n case \"TSTypeAliasDeclaration\":\n case \"TSTypeReference\":\n case \"TypeAnnotation\":\n case \"TypeAlias\":\n return true;\n case \"ExportSpecifier\":\n return (\n (\n path.parentPath.parent as\n | t.ExportDefaultDeclaration\n | t.ExportNamedDeclaration\n ).exportKind === \"type\"\n );\n default:\n if (path.parentPath.isStatement() || path.parentPath.isExpression()) {\n return false;\n }\n }\n } while ((path = path.parentPath));\n}\n\nexport default function rewriteLiveReferences(\n programPath: NodePath<t.Program>,\n metadata: ModuleMetadata,\n) {\n const imported = new Map();\n const exported = new Map();\n const requeueInParent = (path: NodePath) => {\n // Manually re-queue `exports.default =` expressions so that the ES3\n // transform has an opportunity to convert them. Ideally this would\n // happen automatically from the replaceWith above. See #4140 for\n // more info.\n programPath.requeue(path);\n };\n\n for (const [source, data] of metadata.source) {\n for (const [localName, importName] of data.imports) {\n imported.set(localName, [source, importName, null]);\n }\n for (const localName of data.importsNamespace) {\n imported.set(localName, [source, null, localName]);\n }\n }\n\n for (const [local, data] of metadata.local) {\n let exportMeta = exported.get(local);\n if (!exportMeta) {\n exportMeta = [];\n exported.set(local, exportMeta);\n }\n\n exportMeta.push(...data.names);\n }\n\n // Rewrite initialization of bindings to update exports.\n const rewriteBindingInitVisitorState: RewriteBindingInitVisitorState = {\n metadata,\n requeueInParent,\n scope: programPath.scope,\n exported, // local name => exported name list\n };\n programPath.traverse(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n rewriteBindingInitVisitor,\n rewriteBindingInitVisitorState,\n );\n\n // NOTE(logan): The 'Array.from' calls are to make this code with in loose mode.\n const bindingNames = new Set([\n ...Array.from(imported.keys()),\n ...Array.from(exported.keys()),\n ]);\n if (process.env.BABEL_8_BREAKING) {\n simplifyAccess(programPath, bindingNames);\n } else {\n // @ts-ignore(Babel 7 vs Babel 8) The third param has been removed in Babel 8.\n simplifyAccess(programPath, bindingNames, false);\n }\n\n // Rewrite reads/writes from imports and exports to have the correct behavior.\n const rewriteReferencesVisitorState: RewriteReferencesVisitorState = {\n seen: new WeakSet(),\n metadata,\n requeueInParent,\n scope: programPath.scope,\n imported, // local / import\n exported, // local name => exported name list\n buildImportReference: ([source, importName, localName], identNode) => {\n const meta = metadata.source.get(source);\n meta.referenced = true;\n\n if (localName) {\n if (meta.lazy) {\n identNode = callExpression(\n // @ts-expect-error Fixme: we should handle the case when identNode is a JSXIdentifier\n identNode,\n [],\n );\n }\n return identNode;\n }\n\n let namespace: t.Expression = identifier(meta.name);\n if (meta.lazy) namespace = callExpression(namespace, []);\n\n if (importName === \"default\" && meta.interop === \"node-default\") {\n return namespace;\n }\n\n const computed = metadata.stringSpecifiers.has(importName);\n\n return memberExpression(\n namespace,\n computed ? stringLiteral(importName) : identifier(importName),\n computed,\n );\n },\n };\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState);\n}\n\n/**\n * A visitor to inject export update statements during binding initialization.\n */\nconst rewriteBindingInitVisitor: Visitor<RewriteBindingInitVisitorState> = {\n Scope(path) {\n path.skip();\n },\n ClassDeclaration(path) {\n const { requeueInParent, exported, metadata } = this;\n\n const { id } = path.node;\n if (!id) throw new Error(\"Expected class to have a name\");\n const localName = id.name;\n\n const exportNames = exported.get(localName) || [];\n if (exportNames.length > 0) {\n const statement = expressionStatement(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n buildBindingExportAssignmentExpression(\n metadata,\n exportNames,\n identifier(localName),\n path.scope,\n ),\n );\n // @ts-expect-error todo(flow->ts): avoid mutations\n statement._blockHoist = path.node._blockHoist;\n\n requeueInParent(path.insertAfter(statement)[0]);\n }\n },\n VariableDeclaration(path) {\n const { requeueInParent, exported, metadata } = this;\n\n Object.keys(path.getOuterBindingIdentifiers()).forEach(localName => {\n const exportNames = exported.get(localName) || [];\n\n if (exportNames.length > 0) {\n const statement = expressionStatement(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n buildBindingExportAssignmentExpression(\n metadata,\n exportNames,\n identifier(localName),\n path.scope,\n ),\n );\n // @ts-expect-error todo(flow->ts): avoid mutations\n statement._blockHoist = path.node._blockHoist;\n\n requeueInParent(path.insertAfter(statement)[0]);\n }\n });\n },\n};\n\nconst buildBindingExportAssignmentExpression = (\n metadata: ModuleMetadata,\n exportNames: string[],\n localExpr: t.Expression,\n scope: Scope,\n) => {\n const exportsObjectName = metadata.exportName;\n for (\n let currentScope = scope;\n currentScope != null;\n currentScope = currentScope.parent\n ) {\n if (currentScope.hasOwnBinding(exportsObjectName)) {\n currentScope.rename(exportsObjectName);\n }\n }\n return (exportNames || []).reduce((expr, exportName) => {\n // class Foo {} export { Foo, Foo as Bar };\n // as\n // class Foo {} exports.Foo = exports.Bar = Foo;\n const { stringSpecifiers } = metadata;\n const computed = stringSpecifiers.has(exportName);\n return assignmentExpression(\n \"=\",\n memberExpression(\n identifier(exportsObjectName),\n computed ? stringLiteral(exportName) : identifier(exportName),\n /* computed */ computed,\n ),\n expr,\n );\n }, localExpr);\n};\n\nconst buildImportThrow = (localName: string) => {\n return template.expression.ast`\n (function() {\n throw new Error('\"' + '${localName}' + '\" is read-only.');\n })()\n `;\n};\n\nconst rewriteReferencesVisitor: Visitor<RewriteReferencesVisitorState> = {\n ReferencedIdentifier(path) {\n const { seen, buildImportReference, scope, imported, requeueInParent } =\n this;\n if (seen.has(path.node)) return;\n seen.add(path.node);\n\n const localName = path.node.name;\n\n const importData = imported.get(localName);\n if (importData) {\n if (isInType(path)) {\n throw path.buildCodeFrameError(\n `Cannot transform the imported binding \"${localName}\" since it's also used in a type annotation. ` +\n `Please strip type annotations using @babel/preset-typescript or @babel/preset-flow.`,\n );\n }\n\n const localBinding = path.scope.getBinding(localName);\n const rootBinding = scope.getBinding(localName);\n\n // redeclared in this scope\n if (rootBinding !== localBinding) return;\n\n const ref = buildImportReference(importData, path.node);\n\n // Preserve the binding location so that sourcemaps are nicer.\n ref.loc = path.node.loc;\n\n if (\n (path.parentPath.isCallExpression({ callee: path.node }) ||\n path.parentPath.isOptionalCallExpression({ callee: path.node }) ||\n path.parentPath.isTaggedTemplateExpression({ tag: path.node })) &&\n isMemberExpression(ref)\n ) {\n path.replaceWith(sequenceExpression([numericLiteral(0), ref]));\n } else if (path.isJSXIdentifier() && isMemberExpression(ref)) {\n const { object, property } = ref;\n path.replaceWith(\n jsxMemberExpression(\n // @ts-expect-error todo(flow->ts): possible bug `object` might not have a name\n jsxIdentifier(object.name),\n // @ts-expect-error todo(flow->ts): possible bug `property` might not have a name\n jsxIdentifier(property.name),\n ),\n );\n } else {\n path.replaceWith(ref);\n }\n\n requeueInParent(path);\n\n // The path could have been replaced with an identifier that would\n // otherwise be re-visited, so we skip processing its children.\n path.skip();\n }\n },\n\n UpdateExpression(path) {\n const {\n scope,\n seen,\n imported,\n exported,\n requeueInParent,\n buildImportReference,\n } = this;\n\n if (seen.has(path.node)) return;\n\n seen.add(path.node);\n\n const arg = path.get(\"argument\");\n\n // No change needed\n if (arg.isMemberExpression()) return;\n\n const update = path.node;\n\n if (arg.isIdentifier()) {\n const localName = arg.node.name;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n const exportedNames = exported.get(localName);\n const importData = imported.get(localName);\n\n if (exportedNames?.length > 0 || importData) {\n if (importData) {\n path.replaceWith(\n assignmentExpression(\n update.operator[0] + \"=\",\n buildImportReference(importData, arg.node),\n buildImportThrow(localName),\n ),\n );\n } else if (update.prefix) {\n // ++foo\n // => exports.foo = ++foo\n path.replaceWith(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n cloneNode(update),\n path.scope,\n ),\n );\n } else {\n // foo++\n // => (ref = i++, exports.i = i, ref)\n const ref = scope.generateDeclaredUidIdentifier(localName);\n\n path.replaceWith(\n sequenceExpression([\n assignmentExpression(\"=\", cloneNode(ref), cloneNode(update)),\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n identifier(localName),\n path.scope,\n ),\n cloneNode(ref),\n ]),\n );\n }\n }\n }\n\n requeueInParent(path);\n path.skip();\n },\n\n AssignmentExpression: {\n exit(path) {\n const {\n scope,\n seen,\n imported,\n exported,\n requeueInParent,\n buildImportReference,\n } = this;\n\n if (seen.has(path.node)) return;\n seen.add(path.node);\n\n const left = path.get(\"left\");\n\n // No change needed\n if (left.isMemberExpression()) return;\n\n if (left.isIdentifier()) {\n // Simple update-assign foo += 1; export { foo };\n // => exports.foo = (foo += 1);\n const localName = left.node.name;\n\n // redeclared in this scope\n if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {\n return;\n }\n\n const exportedNames = exported.get(localName);\n const importData = imported.get(localName);\n if (exportedNames?.length > 0 || importData) {\n assert(path.node.operator === \"=\", \"Path was not simplified\");\n\n const assignment = path.node;\n\n if (importData) {\n assignment.left = buildImportReference(importData, left.node);\n\n assignment.right = sequenceExpression([\n assignment.right,\n buildImportThrow(localName),\n ]);\n }\n\n path.replaceWith(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n assignment,\n path.scope,\n ),\n );\n requeueInParent(path);\n }\n } else {\n const ids = left.getOuterBindingIdentifiers();\n const programScopeIds = Object.keys(ids).filter(\n localName =>\n scope.getBinding(localName) === path.scope.getBinding(localName),\n );\n const id = programScopeIds.find(localName => imported.has(localName));\n\n if (id) {\n path.node.right = sequenceExpression([\n path.node.right,\n buildImportThrow(id),\n ]);\n }\n\n // Complex ({a, b, c} = {}); export { a, c };\n // => ({a, b, c} = {}), (exports.a = a, exports.c = c);\n const items: t.Expression[] = [];\n programScopeIds.forEach(localName => {\n const exportedNames = exported.get(localName) || [];\n if (exportedNames.length > 0) {\n items.push(\n buildBindingExportAssignmentExpression(\n this.metadata,\n exportedNames,\n identifier(localName),\n path.scope,\n ),\n );\n }\n });\n\n if (items.length > 0) {\n let node: t.Node = sequenceExpression(items);\n if (path.parentPath.isExpressionStatement()) {\n node = expressionStatement(node);\n // @ts-expect-error todo(flow->ts): avoid mutations\n node._blockHoist = path.parentPath.node._blockHoist;\n }\n\n const statement = path.insertAfter(node)[0];\n requeueInParent(statement);\n }\n }\n },\n },\n \"ForOfStatement|ForInStatement\"(\n path: NodePath<t.ForOfStatement | t.ForInStatement>,\n ) {\n const { scope, node } = path;\n const { left } = node;\n const { exported, imported, scope: programScope } = this;\n\n if (!isVariableDeclaration(left)) {\n let didTransformExport = false,\n importConstViolationName;\n const loopBodyScope = path.get(\"body\").scope;\n for (const name of Object.keys(getOuterBindingIdentifiers(left))) {\n if (programScope.getBinding(name) === scope.getBinding(name)) {\n if (exported.has(name)) {\n didTransformExport = true;\n if (loopBodyScope.hasOwnBinding(name)) {\n loopBodyScope.rename(name);\n }\n }\n if (imported.has(name) && !importConstViolationName) {\n importConstViolationName = name;\n }\n }\n }\n if (!didTransformExport && !importConstViolationName) {\n return;\n }\n\n path.ensureBlock();\n const bodyPath = path.get(\"body\");\n\n const newLoopId = scope.generateUidIdentifierBasedOnNode(left);\n path\n .get(\"left\")\n .replaceWith(\n variableDeclaration(\"let\", [\n variableDeclarator(cloneNode(newLoopId)),\n ]),\n );\n scope.registerDeclaration(path.get(\"left\"));\n\n if (didTransformExport) {\n bodyPath.unshiftContainer(\n \"body\",\n expressionStatement(assignmentExpression(\"=\", left, newLoopId)),\n );\n }\n if (importConstViolationName) {\n bodyPath.unshiftContainer(\n \"body\",\n expressionStatement(buildImportThrow(importConstViolationName)),\n );\n }\n }\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AAIA,MAAM;EACJG,oBAAoB;EACpBC,cAAc;EACdC,SAAS;EACTC,mBAAmB;EACnBC,0BAA0B;EAC1BC,UAAU;EACVC,kBAAkB;EAClBC,qBAAqB;EACrBC,aAAa;EACbC,mBAAmB;EACnBC,gBAAgB;EAChBC,cAAc;EACdC,kBAAkB;EAClBC,aAAa;EACbC,mBAAmB;EACnBC;AACF,CAAC,GAAGC,WAAC;AAsBL,SA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C,CACzC,CACH,CAAC;MACHhG,KAAK,CAACkG,mBAAmB,CAAC9H,IAAI,CAACwB,GAAG,CAAC,MAAM,CAAC,CAAC;MAE3C,IAAI+F,kBAAkB,EAAE;QACtBI,QAAQ,CAACI,gBAAgB,CACvB,MAAM,EACN9I,mBAAmB,CAACH,oBAAoB,CAAC,GAAG,EAAE6H,IAAI,EAAEiB,SAAS,CAAC,CAChE,CAAC;MACH;MACA,IAAIJ,wBAAwB,EAAE;QAC5BG,QAAQ,CAACI,gBAAgB,CACvB,MAAM,EACN9I,mBAAmB,CAAC0F,gBAAgB,CAAC6C,wBAAwB,CAAC,CAChE,CAAC;MACH;IACF;EACF;AACF,CAAC"}
@@ -5,19 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = rewriteThis;
7
7
  var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
8
- var _traverse = require("@babel/traverse");
9
- var _t = require("@babel/types");
8
+ var _core = require("@babel/core");
10
9
  const {
11
10
  numericLiteral,
12
11
  unaryExpression
13
- } = _t;
14
- const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, {
12
+ } = _core.types;
13
+ const rewriteThisVisitor = _core.traverse.visitors.merge([_helperEnvironmentVisitor.default, {
15
14
  ThisExpression(path) {
16
15
  path.replaceWith(unaryExpression("void", numericLiteral(0), true));
17
16
  }
18
17
  }]);
19
18
  function rewriteThis(programPath) {
20
- (0, _traverse.default)(programPath.node, Object.assign({}, rewriteThisVisitor, {
19
+ (0, _core.traverse)(programPath.node, Object.assign({}, rewriteThisVisitor, {
21
20
  noScope: true
22
21
  }));
23
22
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_helperEnvironmentVisitor","require","_traverse","_t","numericLiteral","unaryExpression","rewriteThisVisitor","traverse","visitors","merge","environmentVisitor","ThisExpression","path","replaceWith","rewriteThis","programPath","node","Object","assign","noScope"],"sources":["../src/rewrite-this.ts"],"sourcesContent":["import environmentVisitor from \"@babel/helper-environment-visitor\";\nimport traverse from \"@babel/traverse\";\nimport { numericLiteral, unaryExpression } from \"@babel/types\";\n\nimport type { NodePath, Visitor } from \"@babel/traverse\";\n\n/**\n * A visitor to walk the tree, rewriting all `this` references in the top-level scope to be\n * `void 0` (undefined).\n */\nconst rewriteThisVisitor: Visitor = traverse.visitors.merge([\n environmentVisitor,\n {\n ThisExpression(path) {\n path.replaceWith(unaryExpression(\"void\", numericLiteral(0), true));\n },\n },\n]);\n\nexport default function rewriteThis(programPath: NodePath) {\n // Rewrite \"this\" to be \"undefined\".\n traverse(programPath.node, { ...rewriteThisVisitor, noScope: true });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,EAAA,GAAAF,OAAA;AAA+D;EAAtDG,cAAc;EAAEC;AAAe,IAAAF,EAAA;AAQxC,MAAMG,kBAA2B,GAAGC,iBAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,CAC1DC,iCAAkB,EAClB;EACEC,cAAcA,CAACC,IAAI,EAAE;IACnBA,IAAI,CAACC,WAAW,CAACR,eAAe,CAAC,MAAM,EAAED,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;EACpE;AACF,CAAC,CACF,CAAC;AAEa,SAASU,WAAWA,CAACC,WAAqB,EAAE;EAEzD,IAAAR,iBAAQ,EAACQ,WAAW,CAACC,IAAI,EAAAC,MAAA,CAAAC,MAAA,KAAOZ,kBAAkB;IAAEa,OAAO,EAAE;EAAI,EAAE,CAAC;AACtE"}
1
+ {"version":3,"names":["_helperEnvironmentVisitor","require","_core","numericLiteral","unaryExpression","t","rewriteThisVisitor","traverse","visitors","merge","environmentVisitor","ThisExpression","path","replaceWith","rewriteThis","programPath","node","Object","assign","noScope"],"sources":["../src/rewrite-this.ts"],"sourcesContent":["import environmentVisitor from \"@babel/helper-environment-visitor\";\nimport { traverse, types as t } from \"@babel/core\";\nconst { numericLiteral, unaryExpression } = t;\n\nimport type { NodePath, Visitor } from \"@babel/traverse\";\n\n/**\n * A visitor to walk the tree, rewriting all `this` references in the top-level scope to be\n * `void 0` (undefined).\n */\nconst rewriteThisVisitor: Visitor = traverse.visitors.merge([\n environmentVisitor,\n {\n ThisExpression(path) {\n path.replaceWith(unaryExpression(\"void\", numericLiteral(0), true));\n },\n },\n]);\n\nexport default function rewriteThis(programPath: NodePath) {\n // Rewrite \"this\" to be \"undefined\".\n traverse(programPath.node, { ...rewriteThisVisitor, noScope: true });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,MAAM;EAAEE,cAAc;EAAEC;AAAgB,CAAC,GAAGC,WAAC;AAQ7C,MAAMC,kBAA2B,GAAGC,cAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,CAC1DC,iCAAkB,EAClB;EACEC,cAAcA,CAACC,IAAI,EAAE;IACnBA,IAAI,CAACC,WAAW,CAACT,eAAe,CAAC,MAAM,EAAED,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;EACpE;AACF,CAAC,CACF,CAAC;AAEa,SAASW,WAAWA,CAACC,WAAqB,EAAE;EAEzD,IAAAR,cAAQ,EAACQ,WAAW,CAACC,IAAI,EAAAC,MAAA,CAAAC,MAAA,KAAOZ,kBAAkB;IAAEa,OAAO,EAAE;EAAI,EAAE,CAAC;AACtE"}