Skip to content

Commit

Permalink
👷 Move build chain to ESM
Browse files Browse the repository at this point in the history
Superseed #4592
  • Loading branch information
dubzzz authored Feb 6, 2025
1 parent e129bb3 commit 86e90ce
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/fast-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Here are the minimal requirements to use fast-check properly without any polyfil

| fast-check | node | ECMAScript version | _TypeScript (optional)_ |
| ---------- | ------------------- | ------------------ | ----------------------- |
| **4.x** |10.5.0 | ES2020 | ≥5.0 |
| **4.x** |12.17.0 | ES2020 | ≥5.0 |
| **3.x** | ≥8<sup>(1)</sup> | ES2017 | ≥4.1<sup>(2)</sup> |
| **2.x** | ≥8<sup>(1)</sup> | ES2017 | ≥3.2<sup>(3)</sup> |
| **1.x** | ≥0.12<sup>(1)</sup> | ES3 | ≥3.0<sup>(3)</sup> |
Expand Down
3 changes: 3 additions & 0 deletions packages/fast-check/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/fast-check/package.esm-template.json

This file was deleted.

20 changes: 10 additions & 10 deletions packages/fast-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"name": "fast-check",
"version": "3.23.2",
"description": "Property based testing framework for JavaScript (like QuickCheck)",
"type": "commonjs",
"type": "module",
"main": "lib/fast-check.js",
"exports": {
"./package.json": "./package.json",
".": {
"require": {
"types": "./lib/types/fast-check.d.ts",
"default": "./lib/fast-check.js"
"types": "./lib/cjs/types/fast-check.d.ts",
"default": "./lib/cjs/fast-check.js"
},
"import": {
"types": "./lib/esm/types/fast-check.d.ts",
"default": "./lib/esm/fast-check.js"
"types": "./lib/types/fast-check.d.ts",
"default": "./lib/fast-check.js"
}
}
},
"module": "lib/esm/fast-check.js",
"module": "lib/fast-check.js",
"types": "lib/types/fast-check.d.ts",
"files": [
"lib",
Expand All @@ -28,15 +28,15 @@
"scripts": {
"build": "yarn build:publish-cjs && yarn build:publish-esm && yarn build:publish-types && node postbuild/main.mjs",
"build-ci": "cross-env EXPECT_GITHUB_SHA=true yarn build",
"build:publish-types": "tsc -p tsconfig.publish.types.json && tsc -p tsconfig.publish.types.json --outDir lib/esm/types",
"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",
"build:publish-types": "tsc -p tsconfig.publish.types.json && tsc -p tsconfig.publish.types.json --outDir lib/cjs/types",
"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",
"typecheck": "tsc --noEmit",
"test": "vitest --config vitest.unit.config.mjs",
"e2e": "vitest --config vitest.e2e.config.mjs",
"update:documentation": "cross-env UPDATE_CODE_SNIPPETS=true vitest --config vitest.documentation.config.mjs",
"test-bundle": "node test-bundle/run.cjs && node test-bundle/run.mjs && node test-bundle/run-advanced.cjs",
"test-legacy-bundle": "nvs add 10.5 && $(nvs which 10.5) test-bundle/run.cjs && $(nvs which 10.5) test-bundle/run-advanced.cjs",
"test-legacy-bundle": "nvs add 12.17 && $(nvs which 12.17) test-bundle/run.cjs && $(nvs which 12.17) test-bundle/run-advanced.cjs",
"docs": "api-extractor run --local && rm docs/fast-check.api.json && typedoc --out docs src/fast-check-default.ts && node postbuild/main.mjs",
"docs-ci": "cross-env EXPECT_GITHUB_SHA=true yarn docs",
"docs:serve": "yarn dlx serve docs/"
Expand Down
8 changes: 4 additions & 4 deletions packages/fast-check/postbuild/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fs.readFile(path.join(__dirname, '../package.json'), (err, data) => {
const packageVersion = JSON.parse(data.toString()).version;

const commonJsReplacement = replaceInFileSync({
files: 'lib/fast-check-default.js',
files: 'lib/cjs/fast-check-default.js',
from: [/__PACKAGE_TYPE__/g, /__PACKAGE_VERSION__/g, /__COMMIT_HASH__/g],
to: ['commonjs', packageVersion, commitHash],
});
Expand All @@ -45,7 +45,7 @@ fs.readFile(path.join(__dirname, '../package.json'), (err, data) => {
}

const moduleReplacement = replaceInFileSync({
files: 'lib/esm/fast-check-default.js',
files: 'lib/fast-check-default.js',
from: [/__PACKAGE_TYPE__/g, /__PACKAGE_VERSION__/g, /__COMMIT_HASH__/g],
to: ['module', packageVersion, commitHash],
});
Expand All @@ -54,7 +54,7 @@ fs.readFile(path.join(__dirname, '../package.json'), (err, data) => {
}

const dTsReplacement = replaceInFileSync({
files: 'lib/types/fast-check-default.d.ts',
files: 'lib/cjs/types/fast-check-default.d.ts',
from: [/__PACKAGE_VERSION__/g, /__COMMIT_HASH__/g],
to: [packageVersion, commitHash],
});
Expand All @@ -63,7 +63,7 @@ fs.readFile(path.join(__dirname, '../package.json'), (err, data) => {
}

const dTsReplacement2 = replaceInFileSync({
files: 'lib/esm/types/fast-check-default.d.ts',
files: 'lib/types/fast-check-default.d.ts',
from: [/__PACKAGE_VERSION__/g, /__COMMIT_HASH__/g],
to: [packageVersion, commitHash],
});
Expand Down
2 changes: 1 addition & 1 deletion website/docs/migration/from-3.x-to-4.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Simple migration guide to fast-check v4 starting from fast-check v3

| Name | New requirement | Previous requirement |
| ------------------------ | --------------- | -------------------- |
| Node |10.5.0 | ≥8 |
| Node |12.17.0 | ≥8 |
| ECMAScript specification | ES2020 | ES2017 |
| TypeScript _(optional)_ | ≥5.0 | ≥4.1 |

Expand Down

0 comments on commit 86e90ce

Please sign in to comment.