From e14addab8024bc68fe5561045eb6cb34763444b1 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Tue, 27 Oct 2026 18:44:11 +0100 Subject: [PATCH] named stringify export --- packages/shell-bson-parser/package.json | 23 +++++++++++++++---- .../shell-bson-parser/src/stringify.spec.ts | 9 +++++++- .../shell-bson-parser/webpack.cjs.config.cjs | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/shell-bson-parser/package.json b/packages/shell-bson-parser/package.json index 265e1b1f..ce7500f8 100644 --- a/packages/shell-bson-parser/package.json +++ b/packages/shell-bson-parser/package.json @@ -26,10 +26,25 @@ "main": "dist/index.js", "types": "./dist/index.d.ts", "exports": { - "types": "./dist/index.d.ts", - "require": "./dist/cjs/index.js", - "import": "./dist/index.js", - "default": "./dist/index.js" + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/cjs/index.js", + "import": "./dist/index.js", + "default": "./dist/index.js" + }, + "./stringify": { + "types": "./dist/stringify.d.ts", + "require": "./dist/cjs/stringify.js", + "import": "./dist/stringify.js", + "default": "./dist/stringify.js" + } + }, + "typesVersions": { + "*": { + "stringify": [ + "./dist/stringify.d.ts" + ] + } }, "scripts": { "bootstrap": "npm run compile", diff --git a/packages/shell-bson-parser/src/stringify.spec.ts b/packages/shell-bson-parser/src/stringify.spec.ts index 240670d1..72486f99 100644 --- a/packages/shell-bson-parser/src/stringify.spec.ts +++ b/packages/shell-bson-parser/src/stringify.spec.ts @@ -1,8 +1,10 @@ import assert from 'assert'; import * as bson from 'bson'; -import { toJSString } from './stringify.js'; +import * as stringifyModule from './stringify.js'; import { parse } from './parse.js'; +const { toJSString } = stringifyModule; + describe('stringify', function () { describe('toJSString', function () { it('should default to two spaces', function () { @@ -474,4 +476,9 @@ e s`, }); }); }); + + it('only exports toJSString', function () { + const exported = Object.keys(stringifyModule); + assert.deepEqual(exported, ['toJSString']); + }); }); diff --git a/packages/shell-bson-parser/webpack.cjs.config.cjs b/packages/shell-bson-parser/webpack.cjs.config.cjs index 821719c2..2bab1647 100644 --- a/packages/shell-bson-parser/webpack.cjs.config.cjs +++ b/packages/shell-bson-parser/webpack.cjs.config.cjs @@ -10,6 +10,7 @@ module.exports = { target: 'node', entry: { index: path.join(distDir, 'index.js'), + stringify: path.join(distDir, 'stringify.js'), 'web-worker': { import: 'web-worker', library: { type: 'commonjs2', export: 'default' },