Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
const _ = process;

// @ts-expect-error we need to put this inside jest.config.js,
// since it's being read before the process object is replaced by the jest runner.
// More info:
// https://johann.pardanaud.com/blog/how-to-assert-unhandled-rejection-and-uncaught-exception-with-jest/
// https://github.com/jestjs/jest/issues/5620
// https://github.com/jestjs/jest/issues/11165
// https://codesandbox.io/p/devbox/z9qdp4?migrateFrom=zzjfzz
global._onUnhandledRejection = handler => {
_.on('unhandledRejection', handler);
};

import { createDefaultEsmPreset } from 'ts-jest/dist/presets/create-jest-preset.js';

const tsJestTransformCfg = createDefaultEsmPreset().transform;
Expand Down
18 changes: 3 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"url": "https://github.com/graphql/dataloader.git"
},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Copy link

@productdevbook productdevbook Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"main": "dist/index.js",
"module": "dist/index.mjs",

Can we extract this as mjs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @productdevbook

Unfortunately, TypeScript doesn’t provide a built-in way to enforce specific file extensions, so implemented a custom postbuild script to handle that.

This is one of the advantages of using a tool like tsdown, as it abstracts these details and simplifies the build process.

"typings": "dist/esm/index.d.ts",
"scripts": {
"test": "npm run lint && npm run check && npm run testonly",
"test:ci": "npm run lint && npm run check && npm run testonly -- --coverage",
Expand Down Expand Up @@ -69,17 +69,5 @@
"files": "src/**/*.ts"
}
]
},
"tsdown": {
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"dts": true,
"sourcemap": true,
"clean": true
}
}