From d058c1805da22e7443e3415a00b29f7630955bfc Mon Sep 17 00:00:00 2001 From: rtritto Date: Tue, 20 Jan 2026 22:20:39 +0100 Subject: [PATCH] build(query-parser): replace gen-esm-wrapper with rollup COMPASS-10271 --- packages/query-parser/package.json | 31 ++++++++++++-------- packages/query-parser/rollup.config.mjs | 39 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 packages/query-parser/rollup.config.mjs diff --git a/packages/query-parser/package.json b/packages/query-parser/package.json index 0e083f13..78e3d98f 100644 --- a/packages/query-parser/package.json +++ b/packages/query-parser/package.json @@ -22,22 +22,25 @@ "dist" ], "license": "Apache-2.0", - "main": "dist/index.js", - "types": "./dist/index.d.ts", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "types": "./dist/types/index.d.ts", "exports": { - "require": { - "default": "./dist/index.js", - "types": "./dist/index.d.ts" - }, - "import": { - "default": "./dist/.esm-wrapper.mjs", - "types": "./dist/index.d.ts" + ".": { + "import": { + "types": "./dist/types/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/types/index.d.ts", + "default": "./dist/cjs/index.js" + } } }, "scripts": { "bootstrap": "npm run compile", "prepublishOnly": "npm run compile", - "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", + "compile": "tsc -p tsconfig.json && rollup -c", "typecheck": "tsc --noEmit", "eslint": "eslint", "prettier": "prettier", @@ -52,8 +55,8 @@ "reformat": "npm run prettier -- --write ." }, "dependencies": { - "debug": "^4.4.0", "@mongodb-js/shell-bson-parser": "^1.5.5", + "debug": "^4.4.0", "javascript-stringify": "^2.1.0", "lodash": "^4.17.21" }, @@ -62,18 +65,22 @@ "@mongodb-js/mocha-config-devtools": "^1.1.0", "@mongodb-js/prettier-config-devtools": "^1.0.2", "@mongodb-js/tsconfig-devtools": "^1.1.0", + "@rollup/plugin-typescript": "^12.3.0", "@types/chai": "^4.2.21", + "@types/debug": "^4.1.12", + "@types/lodash": "^4.17.23", "@types/mocha": "^9.1.1", "@types/node": "^22.15.30", "@types/sinon-chai": "^3.2.5", "bson": "^4.6.3 || ^5 || ^6.10.3 || ^7.0.0", "depcheck": "^1.4.7", "eslint": "^7.25.0 || ^8.0.0", - "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", "nyc": "^15.1.0", "prettier": "^3.5.3", + "rollup": "^4.55.2", "sinon": "^9.2.3", + "tslib": "^2.8.1", "typescript": "^5.8.2" }, "peerDependencies": { diff --git a/packages/query-parser/rollup.config.mjs b/packages/query-parser/rollup.config.mjs new file mode 100644 index 00000000..219a96e9 --- /dev/null +++ b/packages/query-parser/rollup.config.mjs @@ -0,0 +1,39 @@ +import typescript from '@rollup/plugin-typescript'; + +export default [ + { + input: 'src/index.ts', + output: { + dir: 'dist', + entryFileNames: 'cjs/index.js', + format: 'cjs', + exports: 'named', + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: './tsconfig.json', + declaration: true, + declarationDir: 'dist/types', + }), + ], + }, + { + input: 'src/index.ts', + output: { + dir: 'dist/esm', + format: 'esm', + preserveModules: true, + preserveModulesRoot: 'src', + sourcemap: true, + }, + plugins: [ + typescript({ + tsconfig: './tsconfig.json', + outDir: 'dist/esm', + declaration: false, + declarationMap: false, + }), + ], + }, +]; \ No newline at end of file