Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test
@babel/runtime
behavior with Webpack and old Node.js
- Loading branch information
1 parent
0dffed9
commit 5a6c1d8
Showing
17 changed files
with
1,752 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,3 +79,5 @@ packages/babel-standalone/babel.min.js | |
|
||
tsconfig.json | ||
tsconfig.tsbuildinfo | ||
|
||
/test/runtime-integration/*/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
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,43 @@ | ||
const cp = require("child_process"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
const expectedPath = path.join(__dirname, "expected.txt"); | ||
const expected = fs.readFileSync(expectedPath, "utf8"); | ||
|
||
{ | ||
console.log("Building with webpack 4"); | ||
cp.execSync("yarn webpack", { | ||
cwd: path.join(__dirname, "webpack-4"), | ||
encoding: "utf8", | ||
}); | ||
console.log("Testing the webpack 4 bundle"); | ||
const out = cp.execSync("node ./webpack-4/output.js", { encoding: "utf8" }); | ||
|
||
if (expected === out) { | ||
console.log("OK"); | ||
} else if (process.env.OVERWRITE) { | ||
fs.writeFileSync(expectedPath, out); | ||
console.log("UPDATED"); | ||
} else { | ||
console.error("FAILED\n"); | ||
console.error(out); | ||
} | ||
} | ||
|
||
{ | ||
console.log("Building with webpack 5"); | ||
cp.execSync("yarn webpack", { | ||
cwd: path.join(__dirname, "webpack-5"), | ||
encoding: "utf8", | ||
}); | ||
console.log("Testing the webpack 5 bundle"); | ||
const out = cp.execSync("node ./webpack-5/output.js", { encoding: "utf8" }); | ||
|
||
if (expected === out) { | ||
console.log("OK"); | ||
} 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,10 @@ | ||
================== import - auto ==================== | ||
typeof inheritsLoose: function | ||
A.__proto__ === B true | ||
================= import - esm ====================== | ||
typeof toArray: function | ||
arr: 1,2,3 | ||
================= require - auto ==================== | ||
typeof objectWithoutProperties: function | ||
typeof objectWithoutProperties.default: function | ||
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 } |
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,24 @@ | ||
const cp = require("child_process"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
const expectedPath = path.join(__dirname, "expected.txt"); | ||
const expected = fs.readFileSync(expectedPath, "utf8"); | ||
|
||
{ | ||
console.log(`Testing with Node.js ${process.version}`); | ||
const out = cp.execSync("node --experimental-modules ./src/main.mjs", { | ||
encoding: "utf8", | ||
}); | ||
|
||
if (expected === out) { | ||
console.log("OK"); | ||
} else if (process.env.OVERWRITE) { | ||
fs.writeFileSync(expectedPath, out); | ||
console.log("UPDATED"); | ||
} else { | ||
console.error("FAILED\n\n"); | ||
console.error(out); | ||
} | ||
console.log("\n"); | ||
} |
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 @@ | ||
import inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; | ||
|
||
console.log("================== import - auto ===================="); | ||
console.log("typeof inheritsLoose:", typeof inheritsLoose); | ||
|
||
function A() {} | ||
function B() {} | ||
inheritsLoose(A, B); | ||
|
||
console.log("A.__proto__ === B", A.__proto__ === B); |
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 @@ | ||
import toArray from "@babel/runtime/helpers/esm/toArray"; | ||
|
||
console.log("================= import - esm ======================"); | ||
console.log("typeof toArray:", typeof toArray); | ||
|
||
const arr = toArray(new Set([1, 2, 3])); | ||
|
||
console.log("arr:", arr.toString()); |
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 @@ | ||
import "./import-auto.mjs"; | ||
import "./import-esm.mjs"; | ||
import "./require-auto.cjs"; |
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 @@ | ||
{ | ||
"name": "@babel-internal/runtime-integration-src", | ||
"private": true, | ||
"devDependencies": { | ||
"@babel/runtime": "workspace:*" | ||
} | ||
} |
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,14 @@ | ||
const objectWithoutProperties = require("@babel/runtime/helpers/objectWithoutProperties"); | ||
|
||
console.log("================= require - auto ===================="); | ||
console.log("typeof objectWithoutProperties:", typeof objectWithoutProperties); | ||
console.log( | ||
"typeof objectWithoutProperties.default:", | ||
typeof objectWithoutProperties.default | ||
); | ||
|
||
const obj = objectWithoutProperties( | ||
{ a: 1, b: 2, c: 3, [Symbol.iterator]: 4, [Symbol.toStringTag]: 5 }, | ||
["a", "c", Symbol.iterator] | ||
); | ||
console.log("obj:", obj); |
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 @@ | ||
{ | ||
"name": "@babel-internal/runtime-integration-webpack-4", | ||
"private": true, | ||
"devDependencies": { | ||
"@babel/runtime": "workspace:*", | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^4.5.0" | ||
} | ||
} |
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 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
mode: "development", | ||
|
||
entry: path.join(__dirname, "../src/main.mjs"), | ||
output: { | ||
path: __dirname, | ||
filename: "output.js", | ||
}, | ||
|
||
devtool: false, | ||
}; |
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 @@ | ||
{ | ||
"name": "@babel-internal/runtime-integration-webpack-5", | ||
"private": true, | ||
"exports": "./index.js", | ||
"devDependencies": { | ||
"@babel/runtime": "workspace:*", | ||
"webpack": "^5.24.1", | ||
"webpack-cli": "^4.5.0" | ||
} | ||
} |
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 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
mode: "development", | ||
|
||
entry: path.join(__dirname, "../src/main.mjs"), | ||
output: { | ||
path: __dirname, | ||
filename: "output.js", | ||
}, | ||
|
||
devtool: false, | ||
}; |
Oops, something went wrong.