Skip to content

Commit 6ca73db

Browse files
authored
test: update Node.js range for extensionless files (#6035)
**What's the problem this PR addresses?** Node.js v18.19 has been released and contains nodejs/node#49869 so we need to update tests. **How did you fix it?** Updated the version range. **Checklist** - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). - [x] I have set the packages that need to be released for my changes to be effective. - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent f67dda8 commit 6ca73db

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"eslint.nodePath": ".yarn/sdks",
1616
"editor.codeActionsOnSave": {
17-
"source.fixAll.eslint": true
17+
"source.fixAll.eslint": "explicit"
1818
},
1919
"pasteImage.path": "${projectRoot}/packages/gatsby/static",
2020
"pasteImage.basePath": "${projectRoot}/packages/gatsby/static",

.yarn/versions/0fefb43f.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declined:
2+
- "@yarnpkg/pnp"

packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import {nodeUtils} from '@yarnpkg/core';
2-
import {Filename, npath, ppath, xfs} from '@yarnpkg/fslib';
3-
import {HAS_LOADERS_AFFECTING_LOADERS} from '@yarnpkg/pnp/sources/esm-loader/loaderFlags';
4-
import {pathToFileURL} from 'url';
5-
6-
const ifAtLeastNode21It = nodeUtils.major >= 21 ? it : it.skip;
7-
const ifAtMostNode20It = nodeUtils.major <= 20 ? it : it.skip;
1+
import {Filename, npath, ppath, xfs} from '@yarnpkg/fslib';
2+
import {ALLOWS_EXTENSIONLESS_FILES, HAS_LOADERS_AFFECTING_LOADERS} from '@yarnpkg/pnp/sources/esm-loader/loaderFlags';
3+
import {pathToFileURL} from 'url';
84

95
describe(`Plug'n'Play - ESM`, () => {
106
test(
@@ -404,7 +400,7 @@ describe(`Plug'n'Play - ESM`, () => {
404400
),
405401
);
406402

407-
ifAtMostNode20It(
403+
(ALLOWS_EXTENSIONLESS_FILES ? it.skip : it)(
408404
`it should not allow extensionless commonjs imports`,
409405
makeTemporaryEnv(
410406
{ },
@@ -425,7 +421,7 @@ describe(`Plug'n'Play - ESM`, () => {
425421
),
426422
);
427423

428-
ifAtLeastNode21It(
424+
(ALLOWS_EXTENSIONLESS_FILES ? it : it.skip)(
429425
`it should allow extensionless commonjs imports`,
430426
makeTemporaryEnv(
431427
{ },
@@ -445,7 +441,7 @@ describe(`Plug'n'Play - ESM`, () => {
445441
),
446442
);
447443

448-
ifAtMostNode20It(
444+
(ALLOWS_EXTENSIONLESS_FILES ? it.skip : it)(
449445
`it should not allow extensionless files with {"type": "module"}`,
450446
makeTemporaryEnv(
451447
{
@@ -467,7 +463,7 @@ describe(`Plug'n'Play - ESM`, () => {
467463
),
468464
);
469465

470-
ifAtLeastNode21It(
466+
(ALLOWS_EXTENSIONLESS_FILES ? it : it.skip)(
471467
`it should allow extensionless files with {"type": "module"}`,
472468
makeTemporaryEnv(
473469
{

packages/yarnpkg-pnp/sources/esm-loader/loaderFlags.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export const HAS_LAZY_LOADED_TRANSLATORS = (major === 20 && minor < 6) || (major
1111
// https://github.com/nodejs/node/pull/43772
1212
// TODO: Update the version range if it gets backported to v18.
1313
export const HAS_LOADERS_AFFECTING_LOADERS = major > 19 || (major === 19 && minor >= 6);
14+
15+
// https://github.com/nodejs/node/pull/49869
16+
export const ALLOWS_EXTENSIONLESS_FILES = major >= 21 || (major === 20 && minor >= 10) || (major === 18 && minor >= 19);

0 commit comments

Comments
 (0)