Skip to content

Commit

Permalink
👷(vitest) Move build chain to ESM
Browse files Browse the repository at this point in the history
The build chain of `@fast-check/vitest` has been CommonJS-based since day 1. With ESM moving forward in the ecosystem, it's time to move ourselves to the new standard and adapt our build chains to ESM.

Unfortunately it may have some subtle impacts on our users as our package will not be a CJS one offering a ESM fallback anymore. I will rather be the opposite: an ESM package with a fallback to CJS. It implies that we moved ESM related files closer to the root of the package (we could have kept them in esm/) and moved the CJS ones further in the file structure (we had to move them).

Another subtle impact is that it would impose our users to run at least Node ≥12.17.0. But it was already a requirement for this package.

As such we consider it as a breaking change.
  • Loading branch information
dubzzz authored Jan 2, 2024
1 parent 4787474 commit d848576
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
3 changes: 3 additions & 0 deletions packages/vitest/package.cjs-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
3 changes: 0 additions & 3 deletions packages/vitest/package.esm-template.json

This file was deleted.

20 changes: 10 additions & 10 deletions packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
"name": "@fast-check/vitest",
"description": "Property based testing for Vitest based on fast-check",
"version": "0.0.9",
"type": "commonjs",
"type": "module",
"main": "lib/vitest-fast-check.js",
"exports": {
"./package.json": "./package.json",
".": {
"require": {
"types": "./lib/vitest-fast-check.d.ts",
"default": "./lib/vitest-fast-check.js"
"types": "./lib/cjs/vitest-fast-check.d.ts",
"default": "./lib/cjs/vitest-fast-check.js"
},
"import": {
"types": "./lib/esm/vitest-fast-check.d.ts",
"default": "./lib/esm/vitest-fast-check.js"
"types": "./lib/vitest-fast-check.d.ts",
"default": "./lib/vitest-fast-check.js"
}
}
},
"module": "lib/esm/vitest-fast-check.js",
"module": "lib/vitest-fast-check.js",
"types": "lib/vitest-fast-check.d.ts",
"files": [
"lib"
],
"scripts": {
"build": "yarn build:publish-cjs && yarn build:publish-esm && yarn build:publish-types",
"build-ci": "yarn build",
"build:publish-types": "tsc -p tsconfig.publish.types.json && tsc -p tsconfig.publish.types.json --outDir lib/esm",
"build:publish-cjs": "tsc -p tsconfig.publish.json",
"build:publish-esm": "tsc -p tsconfig.publish.json --module es2015 --moduleResolution node --outDir lib/esm && cp package.esm-template.json lib/esm/package.json",
"test": "jest",
"build:publish-types": "tsc -p tsconfig.publish.types.json && tsc -p tsconfig.publish.types.json --outDir lib/cjs",
"build:publish-cjs": "tsc -p tsconfig.publish.json --outDir lib/cjs && cp package.cjs-template.json lib/cjs/package.json",
"build:publish-esm": "tsc -p tsconfig.publish.json --module es2015 --moduleResolution node",
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
"test-bundle": "node test-bundle/basic.mjs && vitest --config test-bundle/vitest.config.mjs",
"typecheck": "tsc --noEmit"
},
Expand Down

0 comments on commit d848576

Please sign in to comment.