Skip to content

Commit

Permalink
test: add case for unrecognised fields within pjson "exports"
Browse files Browse the repository at this point in the history
PR-URL: #57026
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
JakobJingleheimer authored and targos committed Feb 17, 2025
1 parent 6cdee54 commit a588066
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Empty file.
10 changes: 10 additions & 0 deletions test/fixtures/packages/unrecognised-export-keys/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "pkg-with-unrecognised-export-keys",
"exports": {
".": {
"default": "./index.js",
"FtLcAG": "./whatever.ext",
"types": "./index.d.ts"
}
}
}
15 changes: 15 additions & 0 deletions test/parallel/test-find-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,19 @@ describe('findPackageJSON', () => { // Throws when no arguments are provided
assert.ok(stdout.includes(foundPjsonPath), stdout);
assert.strictEqual(code, 0);
});

it('should work when unrecognised keys are specified within the export', async () => {
const specifierBase = './packages/unrecognised-export-keys';
const target = fixtures.fileURL(specifierBase, 'index.js');
const foundPjsonPath = path.toNamespacedPath(fixtures.path(specifierBase, 'package.json'));

const { code, stderr, stdout } = await common.spawnPromisified(process.execPath, [
'--print',
`require("node:module").findPackageJSON(${JSON.stringify(target)})`,
]);

assert.strictEqual(stderr, '');
assert.ok(stdout.includes(foundPjsonPath), stdout);
assert.strictEqual(code, 0);
});
});

0 comments on commit a588066

Please sign in to comment.