You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

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