Skip to content

Commit a588066

Browse files
JakobJingleheimertargos
authored andcommitted
test: add case for unrecognised fields within pjson "exports"
PR-URL: #57026 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6cdee54 commit a588066

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

test/fixtures/packages/unrecognised-export-keys/index.js

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "pkg-with-unrecognised-export-keys",
3+
"exports": {
4+
".": {
5+
"default": "./index.js",
6+
"FtLcAG": "./whatever.ext",
7+
"types": "./index.d.ts"
8+
}
9+
}
10+
}

test/parallel/test-find-package-json.js

+15
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,19 @@ describe('findPackageJSON', () => { // Throws when no arguments are provided
189189
assert.ok(stdout.includes(foundPjsonPath), stdout);
190190
assert.strictEqual(code, 0);
191191
});
192+
193+
it('should work when unrecognised keys are specified within the export', async () => {
194+
const specifierBase = './packages/unrecognised-export-keys';
195+
const target = fixtures.fileURL(specifierBase, 'index.js');
196+
const foundPjsonPath = path.toNamespacedPath(fixtures.path(specifierBase, 'package.json'));
197+
198+
const { code, stderr, stdout } = await common.spawnPromisified(process.execPath, [
199+
'--print',
200+
`require("node:module").findPackageJSON(${JSON.stringify(target)})`,
201+
]);
202+
203+
assert.strictEqual(stderr, '');
204+
assert.ok(stdout.includes(foundPjsonPath), stdout);
205+
assert.strictEqual(code, 0);
206+
});
192207
});

0 commit comments

Comments
 (0)