Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add @babel/plugin-proposal-dynamic-import to @babel/preset-env (#10109)
* Add proposal-dynamic-import to preset-env * Use proper capitalization
- Loading branch information
1 parent
ab64e93
commit b12fc5f
Showing
30 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...bel-preset-env/test/fixtures/dynamic-import/auto-esm-supported-import-supported/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
8 changes: 8 additions & 0 deletions
8
...-preset-env/test/fixtures/dynamic-import/auto-esm-supported-import-supported/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"caller": { | ||
"name": "test-fixture", | ||
"supportsStaticESM": true, | ||
"supportsDynamicImport": true | ||
}, | ||
"presets": ["env"] | ||
} |
1 change: 1 addition & 0 deletions
1
...el-preset-env/test/fixtures/dynamic-import/auto-esm-supported-import-supported/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
1 change: 1 addition & 0 deletions
1
...l-preset-env/test/fixtures/dynamic-import/auto-esm-supported-import-unsupported/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); // warns |
8 changes: 8 additions & 0 deletions
8
...reset-env/test/fixtures/dynamic-import/auto-esm-supported-import-unsupported/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"caller": { | ||
"name": "test-fixture", | ||
"supportsStaticESM": true, | ||
"supportsDynamicImport": false | ||
}, | ||
"presets": ["env"] | ||
} |
1 change: 1 addition & 0 deletions
1
...-preset-env/test/fixtures/dynamic-import/auto-esm-supported-import-unsupported/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); // warns |
1 change: 1 addition & 0 deletions
1
...preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
8 changes: 8 additions & 0 deletions
8
...set-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"caller": { | ||
"name": "test-fixture", | ||
"supportsStaticESM": false, | ||
"supportsSynamicImport": false | ||
}, | ||
"presets": ["env"] | ||
} |
7 changes: 7 additions & 0 deletions
7
...preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
|
||
Promise.resolve().then(function () { | ||
return _interopRequireWildcard(require("foo")); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["env", { "modules": "amd" }]] | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
define(["require"], function (_require) { | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
|
||
new Promise(function (_resolve, _reject) { | ||
return _require(["foo"], function (imported) { | ||
return _resolve(_interopRequireWildcard(imported)); | ||
}, _reject); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["env", { "modules": "cjs" }]] | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
|
||
Promise.resolve().then(function () { | ||
return _interopRequireWildcard(require("foo")); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-false/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/dynamic-import/modules-false/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["env", { "modules": false }]] | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-false/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-systemjs/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/dynamic-import/modules-systemjs/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["env", { "modules": "systemjs" }]] | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/babel-preset-env/test/fixtures/dynamic-import/modules-systemjs/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], function (_export, _context) { | ||
"use strict"; | ||
|
||
return { | ||
setters: [], | ||
execute: function () { | ||
_context["import"]("foo"); | ||
} | ||
}; | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/input.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo"); // warns |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["env", { "modules": "umd" }]] | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define([], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(); | ||
global.input = mod.exports; | ||
} | ||
})(this, function () { | ||
"use strict"; | ||
|
||
import("foo"); // warns | ||
}); |