Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
@babel/runtime
esm stability (#12883)
- Loading branch information
1 parent
c9da965
commit 6a471de
Showing
47 changed files
with
2,713 additions
and
337 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
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: 0 additions & 1 deletion
1
...transform-runtime/test/fixtures/dual-babel-runtime/useESModules-modern-runtime/stderr.txt
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
packages/babel-runtime-corejs2/helpers/temporalRef/_index.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import undef from "@babel/runtime-corejs2/helpers/temporalUndefined"; | ||
import err from "@babel/runtime-corejs2/helpers/tdz"; | ||
import undef from "../temporalUndefined/_index.mjs"; | ||
import err from "../tdz/_index.mjs"; | ||
export default function _temporalRef(val, name) { | ||
return val === undef ? err(name) : val; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import arrayWithHoles from "@babel/runtime-corejs2/helpers/arrayWithHoles"; | ||
import iterableToArray from "@babel/runtime-corejs2/helpers/iterableToArray"; | ||
import unsupportedIterableToArray from "@babel/runtime-corejs2/helpers/unsupportedIterableToArray"; | ||
import nonIterableRest from "@babel/runtime-corejs2/helpers/nonIterableRest"; | ||
import arrayWithHoles from "../arrayWithHoles/_index.mjs"; | ||
import iterableToArray from "../iterableToArray/_index.mjs"; | ||
import unsupportedIterableToArray from "../unsupportedIterableToArray/_index.mjs"; | ||
import nonIterableRest from "../nonIterableRest/_index.mjs"; | ||
export default function _toArray(arr) { | ||
return arrayWithHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableRest(); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import undef from "@babel/runtime/helpers/temporalUndefined"; | ||
import err from "@babel/runtime/helpers/tdz"; | ||
import undef from "../temporalUndefined/_index.mjs"; | ||
import err from "../tdz/_index.mjs"; | ||
export default function _temporalRef(val, name) { | ||
return val === undef ? err(name) : val; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import arrayWithHoles from "@babel/runtime/helpers/arrayWithHoles"; | ||
import iterableToArray from "@babel/runtime/helpers/iterableToArray"; | ||
import unsupportedIterableToArray from "@babel/runtime/helpers/unsupportedIterableToArray"; | ||
import nonIterableRest from "@babel/runtime/helpers/nonIterableRest"; | ||
import arrayWithHoles from "../arrayWithHoles/_index.mjs"; | ||
import iterableToArray from "../iterableToArray/_index.mjs"; | ||
import unsupportedIterableToArray from "../unsupportedIterableToArray/_index.mjs"; | ||
import nonIterableRest from "../nonIterableRest/_index.mjs"; | ||
export default function _toArray(arr) { | ||
return arrayWithHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableRest(); | ||
} |
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,48 @@ | ||
const cp = require("child_process"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
for (const absolute of [false, true]) { | ||
const output = absolute ? "output-absolute.js" : "output.js"; | ||
const title = absolute ? "(absolute runtime)" : ""; | ||
|
||
const webpack = absolute | ||
? "webpack --config webpack.absolute.config.js" | ||
: "webpack"; | ||
const rollup = absolute ? "rollup -c rollup.absolute.config.js" : "rollup -c"; | ||
|
||
// TODO: This never worked in any Babel version | ||
if (!absolute) { | ||
test(`Webpack 5 ${title}`, webpack, "webpack-5", output, true); | ||
} | ||
test(`Webpack 4 ${title}`, webpack, "webpack-4", output); | ||
test(`Webpack 3 ${title}`, webpack, "webpack-3", output); | ||
test(`Rollup ${title}`, rollup, "rollup", output); | ||
} | ||
|
||
function test(name, command, directory, output, first) { | ||
console.log(`Building with ${name}`); | ||
cp.execSync(`yarn ${command}`, { | ||
cwd: path.join(__dirname, directory), | ||
encoding: "utf8", | ||
}); | ||
console.log(`Testing the ${name} bundle`); | ||
const out = cp.execSync(`node ${output}`, { | ||
cwd: path.join(__dirname, directory), | ||
encoding: "utf8", | ||
}); | ||
|
||
const expectedPath = path.join(__dirname, "expected-bundler.txt"); | ||
let expected = fs.readFileSync(expectedPath, "utf8"); | ||
|
||
if (expected === out) { | ||
console.log("OK"); | ||
} else if (first && process.env.OVERWRITE) { | ||
fs.writeFileSync(expectedPath, out); | ||
expected = out; | ||
console.log("UPDATED"); | ||
} else { | ||
console.error("FAILED\n"); | ||
console.error(out); | ||
} | ||
} |
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,20 @@ | ||
================== import - auto ==================== | ||
typeof inheritsLoose: function | ||
A.__proto__ === B true | ||
================= import - esm ====================== | ||
typeof toArray: function | ||
arr: 1,2,3 | ||
=============== import - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
typeof toPrimitive: object | ||
typeof toPrimitive.default: function | ||
Value: 2 | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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,20 @@ | ||
================== import - auto ==================== | ||
typeof inheritsLoose: function | ||
A.__proto__ === B true | ||
================= import - esm ====================== | ||
typeof toArray: function | ||
arr: 1,2,3 | ||
=============== import - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
typeof toPrimitive: object | ||
typeof toPrimitive.default: function | ||
Value: 2 | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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 @@ | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Unexpected token export | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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 @@ | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Unexpected token export | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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 @@ | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Unexpected token 'export' | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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,13 @@ | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js | ||
require() of ES modules is not supported. | ||
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/absolute/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. | ||
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json. | ||
|
||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
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 @@ | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/toPrimitive/_index.mjs | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
Empty file.
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,18 @@ | ||
================== import - auto ==================== | ||
typeof inheritsLoose: function | ||
A.__proto__ === B true | ||
================= import - esm ====================== | ||
typeof toArray: function | ||
arr: 1,2,3 | ||
=============== import - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } | ||
================= require - esm ===================== | ||
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/toPrimitive/_index.mjs | ||
=============== require - corejs ==================== | ||
typeof Set: function | ||
arr: 1,2,3 |
Oops, something went wrong.