Skip to content

Commit a8857df

Browse files
committed
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. (cherry picked from commit 6ca73db)
1 parent db3cd21 commit a8857df

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
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: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe(`Plug'n'Play - ESM`, () => {
423423
),
424424
);
425425

426-
test(
426+
(loaderFlags.ALLOWS_EXTENSIONLESS_FILES ? it.skip : it)(
427427
`it should not allow extensionless commonjs imports`,
428428
makeTemporaryEnv(
429429
{ },
@@ -444,7 +444,27 @@ describe(`Plug'n'Play - ESM`, () => {
444444
),
445445
);
446446

447-
test(
447+
(loaderFlags.ALLOWS_EXTENSIONLESS_FILES ? it : it.skip)(
448+
`it should allow extensionless commonjs imports`,
449+
makeTemporaryEnv(
450+
{ },
451+
{
452+
pnpEnableEsmLoader: true,
453+
},
454+
async ({path, run, source}) => {
455+
await xfs.writeFilePromise(ppath.join(path, `index.mjs` as Filename), `import bin from './cjs-bin';\nconsole.log(bin)`);
456+
await xfs.writeFilePromise(ppath.join(path, `cjs-bin` as Filename), `module.exports = 42`);
457+
458+
await expect(run(`install`)).resolves.toMatchObject({code: 0});
459+
460+
await expect(run(`node`, `./index.mjs`)).resolves.toMatchObject({
461+
stdout: `42\n`,
462+
});
463+
},
464+
),
465+
);
466+
467+
(loaderFlags.ALLOWS_EXTENSIONLESS_FILES ? it.skip : it)(
448468
`it should not allow extensionless files with {"type": "module"}`,
449469
makeTemporaryEnv(
450470
{
@@ -466,6 +486,27 @@ describe(`Plug'n'Play - ESM`, () => {
466486
),
467487
);
468488

489+
(loaderFlags.ALLOWS_EXTENSIONLESS_FILES ? it : it.skip)(
490+
`it should allow extensionless files with {"type": "module"}`,
491+
makeTemporaryEnv(
492+
{
493+
type: `module`,
494+
},
495+
{
496+
pnpEnableEsmLoader: true,
497+
},
498+
async ({path, run, source}) => {
499+
await xfs.writeFilePromise(ppath.join(path, `index` as Filename), `console.log(42)`);
500+
501+
await expect(run(`install`)).resolves.toMatchObject({code: 0});
502+
503+
await expect(run(`node`, `./index`)).resolves.toMatchObject({
504+
stdout: `42\n`,
505+
});
506+
},
507+
),
508+
);
509+
469510
test(
470511
`it should support ESM binaries`,
471512
makeTemporaryEnv(

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ export const HAS_LOADERS_AFFECTING_LOADERS = major > 19 || (major === 19 && mino
2323

2424
// https://github.com/nodejs/node/pull/42881
2525
export const ALLOWS_NON_FILE_PARENT = major > 18 || (major === 18 && minor >= 1) || (major === 16 && minor >= 17);
26+
27+
// https://github.com/nodejs/node/pull/49869
28+
export const ALLOWS_EXTENSIONLESS_FILES = major >= 21 || (major === 20 && minor >= 10) || (major === 18 && minor >= 19);

0 commit comments

Comments
 (0)