Skip to content

Commit cc9a025

Browse files
committed
wip
1 parent 3496356 commit cc9a025

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

test/unit/node2020/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# unit test drafts for node targets
2+
3+
playground to get going on the https://github.com/vercel/ncc/issues/1247 while i get a hang of ncc test infra and how to fix node gyp issues.
4+
5+
currently, i dont understand why webpack with node16 target compile into v into u regexp flag and why usage of Set.prototype.difference doesnt bring in core-js imports if
6+
7+
```
8+
cd test/unit/node2020
9+
npx webpack
10+
```

test/unit/node2020/input.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// added in es2025
2+
// https://babeljs.io/docs/babel-plugin-transform-regexp-modifiers
3+
// const regex = /(?i:a)a/
4+
// output for es2024
5+
// const regex = /(?:[Aa])a/
6+
// but throws an error:
7+
// Module parse failed: Invalid regular expression: /(?i:a)a/: Invalid group (3:15) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
8+
9+
// added in node22
10+
// https://nodejs.org/en/blog/announcements/v22-release-announce
11+
new Set([1, 2]).intersection(new Set([2, 3])); // Set(1) { 2 }
12+
// output for node20
13+
// import "core-js/modules/es.set.js";
14+
// new Set([1, 2]).intersection(new Set([2, 3])); // Set(1) { 2 }
15+
// but remains unchanged with target: node16 and doesnt add core-js imports
16+
17+
// added in es2024 + node20
18+
// https://babeljs.io/docs/babel-plugin-transform-unicode-sets-regex
19+
// https://nodejs.org/en/blog/announcements/v20-release-announce
20+
/[\p{ASCII}&&\p{Decimal_Number}]/v;
21+
// output es2023 node20
22+
// /[0-9]/u;
23+
// but remains unchanged with target: node16

test/unit/node2020/output.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/******/ (() => { // webpackBootstrap
2+
// added in es2025
3+
// https://babeljs.io/docs/babel-plugin-transform-regexp-modifiers
4+
// const regex = /(?i:a)a/
5+
// output for es2024
6+
// const regex = /(?:[Aa])a/
7+
// but throws an error:
8+
// Module parse failed: Invalid regular expression: /(?i:a)a/: Invalid group (3:15) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
9+
10+
// added in node22
11+
// https://nodejs.org/en/blog/announcements/v22-release-announce
12+
new Set([1, 2]).intersection(new Set([2, 3])); // Set(1) { 2 }
13+
// output for node20
14+
// import "core-js/modules/es.set.js";
15+
// new Set([1, 2]).intersection(new Set([2, 3])); // Set(1) { 2 }
16+
// but remains unchanged with target: node16 and doesnt add core-js imports
17+
18+
// added in es2024 + node20
19+
// https://babeljs.io/docs/babel-plugin-transform-unicode-sets-regex
20+
// https://nodejs.org/en/blog/announcements/v20-release-announce
21+
/[\p{ASCII}&&\p{Decimal_Number}]/v;
22+
// output es2023 node20
23+
// /[0-9]/u;
24+
// but remains unchanged with target: node16
25+
26+
/******/ })()
27+
;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// npx webpack-cli
2+
// --output-path=./test/unit/node2020/
3+
// --output-filename=output.js
4+
// --target=es2022
5+
6+
// ./test/unit/node2020/input.js
7+
8+
module.exports = {
9+
entry: './input.js',
10+
mode: 'none',
11+
output: {
12+
path: __dirname,
13+
filename: 'output.js',
14+
chunkFormat: 'commonjs',
15+
clean: {
16+
keep(asset) {
17+
return !asset.includes('output.js');
18+
}
19+
},
20+
},
21+
// target: 'es2023',
22+
// target: 'browserslist: node 16',
23+
target: 'node16',
24+
};

0 commit comments

Comments
 (0)