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