index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. var _pluginSyntaxDynamicImport = require("@babel/plugin-syntax-dynamic-import");
  8. const SUPPORTED_MODULES = ["commonjs", "amd", "systemjs"];
  9. const MODULES_NOT_FOUND = `\
  10. @babel/plugin-proposal-dynamic-import depends on a modules
  11. transform plugin. Supported plugins are:
  12. - @babel/plugin-transform-modules-commonjs ^7.4.0
  13. - @babel/plugin-transform-modules-amd ^7.4.0
  14. - @babel/plugin-transform-modules-systemjs ^7.4.0
  15. If you are using Webpack or Rollup and thus don't want
  16. Babel to transpile your imports and exports, you can use
  17. the @babel/plugin-syntax-dynamic-import plugin and let your
  18. bundler handle dynamic imports.
  19. `;
  20. var _default = (0, _helperPluginUtils.declare)(api => {
  21. api.assertVersion(7);
  22. return {
  23. name: "proposal-dynamic-import",
  24. inherits: _pluginSyntaxDynamicImport.default,
  25. pre() {
  26. this.file.set("@babel/plugin-proposal-dynamic-import", "7.18.6");
  27. },
  28. visitor: {
  29. Program() {
  30. const modules = this.file.get("@babel/plugin-transform-modules-*");
  31. if (!SUPPORTED_MODULES.includes(modules)) {
  32. throw new Error(MODULES_NOT_FOUND);
  33. }
  34. }
  35. }
  36. };
  37. });
  38. exports.default = _default;