From 32ad266eabd74c53e12e5d60ace448d75c4246c6 Mon Sep 17 00:00:00 2001 From: waldronmatt Date: Sun, 1 Oct 2023 13:10:36 -0400 Subject: [PATCH] feat(package.json): remove cjs support, update jest config BREAKING CHANGE: esm support only --- packages/basic-math/jest.config.cjs | 7 +++++++ packages/basic-math/package.json | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/basic-math/jest.config.cjs b/packages/basic-math/jest.config.cjs index de861ab8..70481025 100644 --- a/packages/basic-math/jest.config.cjs +++ b/packages/basic-math/jest.config.cjs @@ -1,3 +1,10 @@ +const mappedModule = process.env.TEST_ENV === 'prod' ? '/dist/$1' : '/src/$1'; + module.exports = { preset: 'jest-config', + testMatch: ['/src/**?(*.)+(spec|test).+(ts|tsx)'], + moduleNameMapper: { + '^@/(.*)\\.js$': mappedModule, + }, + testEnvironment: 'jsdom', }; diff --git a/packages/basic-math/package.json b/packages/basic-math/package.json index 8aca7d3f..3611a59e 100644 --- a/packages/basic-math/package.json +++ b/packages/basic-math/package.json @@ -1,14 +1,13 @@ { "name": "@waldronmatt/basic-math", "version": "1.0.5", - "main": "./dist/index.cjs", + "main": "./dist/index.js", "module": "./dist/index.js", "types": "./dist/index.d.ts", "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" }, "./*": "./dist/*" @@ -25,7 +24,7 @@ "test:watch": "jest --watch", "test:prod": "cross-env TEST_ENV=prod NODE_OPTIONS=--experimental-vm-modules jest", "build:dtsmaps": "tsc --project tsconfig.build.json", - "build:src": "tsup src/*[!.spec].ts --format cjs,esm --sourcemap --onSuccess \"pnpm build:dtsmaps\"", + "build:src": "tsup src/*[!.spec].ts --format esm --sourcemap --onSuccess \"pnpm build:dtsmaps\"", "clean": "rimraf dist coverage tsconfig.build.tsbuildinfo", "build": "pnpm build:src", "stub": "npx unbuild --stub"