index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  7. const SUPPORTED_MODULES = new Set(["commonjs", "amd", "systemjs"]);
  8. const MODULES_NOT_FOUND = `\
  9. @babel/plugin-transform-dynamic-import depends on a modules
  10. transform plugin. Supported plugins are:
  11. - @babel/plugin-transform-modules-commonjs ^7.4.0
  12. - @babel/plugin-transform-modules-amd ^7.4.0
  13. - @babel/plugin-transform-modules-systemjs ^7.4.0
  14. If you are using Webpack or Rollup and thus don't want
  15. Babel to transpile your imports and exports, you can use
  16. the @babel/plugin-syntax-dynamic-import plugin and let your
  17. bundler handle dynamic imports.
  18. `;
  19. var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
  20. api.assertVersion(7);
  21. return {
  22. name: "transform-dynamic-import",
  23. manipulateOptions: (_, parser) => parser.plugins.push("dynamicImport"),
  24. pre() {
  25. this.file.set("@babel/plugin-proposal-dynamic-import", "7.25.9");
  26. },
  27. visitor: {
  28. Program() {
  29. const modules = this.file.get("@babel/plugin-transform-modules-*");
  30. if (!SUPPORTED_MODULES.has(modules)) {
  31. throw new Error(MODULES_NOT_FOUND);
  32. }
  33. }
  34. }
  35. };
  36. });
  37. //# sourceMappingURL=index.js.map