diff --git a/packages/pv-scripts/README.md b/packages/pv-scripts/README.md index 3e158d3..873d226 100644 --- a/packages/pv-scripts/README.md +++ b/packages/pv-scripts/README.md @@ -55,6 +55,7 @@ Basic Configuration can be done in a `pv.config.js` file in the npm project root | jsEntry | string | "src/index.ts" | defines path of your (JS\|TS\|JSX\|TSX) entry file | | cssEntry | string | "src/index.scss" | defines path of your SCSS entry file. If `src/index.scss` does not exist, no error is thrown but the css generation is simply skipped| | useTS | boolean | true | defines whether you want to use Typescript | +| enableTypeCheck | boolean | true | defines whether the TypeScript type-check (`fork-ts-checker-webpack-plugin`) runs during the build. Only applies when `useTS` is `true`. Set to `false` to skip type-checking (see [Troubleshooting](#troubleshooting)) | | useReact | boolean | false | defines whether you want to use React | | hbsEntry | string | | defines path of your handlebars entry file | | hbsTarget | string | | defines path to your handlebars target file | @@ -120,6 +121,54 @@ Per default the new (dart-)`sass` package will be installed and used. You can al A default browser query is used for compiling javascript and css. i.e. latest 2 versions of evergreen browsers (chrome, firefox, safari, edge). You can define your own [browserslist](https://github.com/browserslist/browserslist). See default [.browserslistrc](https://github.com/pro-vision/fe-tools/tree/master/packages/pv-scripts/config/.browserslistrc) file for an example. +## Troubleshooting + +### `EMFILE: too many open files, watch` in `dev` mode (macOS) + +If `pv-scripts dev` crashes on macOS with an error like: + +``` +Error: EMFILE: too many open files, watch + at FSWatcher._handle.onchange (node:internal/fs/watchers) + ... + at NodeFsHandler._boundHandleError (node_modules/chokidar/handler.js) +``` + +this is caused by the TypeScript type-check watcher opening one file descriptor +per watched directory. `fork-ts-checker-webpack-plugin@9.1.0` bumped its `chokidar` +dependency from 3 to 4, and `chokidar@4` dropped `fsevents` support. Without +`fsevents`, macOS falls back to native `fs.watch` (one descriptor per directory) +instead of a single `fsevents` stream, so a large watch tree (e.g. a `tsconfig.json` +without an `include`, which makes TypeScript watch the whole project root incl. +`node_modules`) can exhaust the per-process descriptor limit. + +**pv-scripts pins `fork-ts-checker-webpack-plugin` to `9.0.3`** (which still uses +`chokidar@3` + `fsevents`), so upgrading pv-scripts fixes this. Additional +mitigations: + +- Give your `tsconfig.json` an explicit `"include": ["src"]` so the type-check + watches only your sources instead of the whole project root. +- If you are stuck on an affected version, force `chokidar@3` in your project's + `package.json`: + + ```json + "overrides": { + "fork-ts-checker-webpack-plugin": { "chokidar": "^3.6.0" } + } + ``` + +- As a last resort, disable the type-check watcher in dev via `pv.config.js`: + + ```js + // pv.config.js + module.exports = { + enableTypeCheck: false, + }; + ``` + + (This turns off the type-check for both `dev` and `prod`; run `tsc --noEmit` + separately if you still want type-checking in CI.) + ## Examples You can find example projects in the `examples` folder: diff --git a/packages/pv-scripts/package-lock.json b/packages/pv-scripts/package-lock.json index f7e58d3..44c7d86 100644 --- a/packages/pv-scripts/package-lock.json +++ b/packages/pv-scripts/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@pro-vision/pv-scripts", - "version": "5.1.0", + "version": "6.0.0", "license": "ISC", "dependencies": { "@babel/core": "7.29.7", @@ -28,7 +28,7 @@ "cross-spawn": "7.0.6", "css-loader": "7.1.4", "cssnano": "8.0.2", - "fork-ts-checker-webpack-plugin": "9.1.0", + "fork-ts-checker-webpack-plugin": "9.0.3", "handlebars": "4.7.9", "handlebars-loader": "1.7.3", "html-webpack-plugin": "5.6.7", @@ -6190,14 +6190,14 @@ } }, "node_modules/fork-ts-checker-webpack-plugin": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.1.0.tgz", - "integrity": "sha512-mpafl89VFPJmhnJ1ssH+8wmM2b50n+Rew5x42NeI2U78aRWgtkEtGmctp7iT16UjquJTjorEmIfESj3DxdW84Q==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.0.3.tgz", + "integrity": "sha512-zUE6ABwfybBbSH5TIsdAFiR2kfy0nm2yT0DEtujNM4vHbKhbrIsfoC5cPfJa4vqlmcSBPxqIED+EWVPWEw1hTw==", "license": "MIT", "dependencies": { "@babel/code-frame": "^7.16.7", "chalk": "^4.1.2", - "chokidar": "^4.0.1", + "chokidar": "^3.5.3", "cosmiconfig": "^8.2.0", "deepmerge": "^4.2.2", "fs-extra": "^10.0.0", @@ -6209,7 +6209,7 @@ "tapable": "^2.2.1" }, "engines": { - "node": ">=14.21.3" + "node": ">=12.13.0" }, "peerDependencies": { "typescript": ">3.6.0", @@ -6239,21 +6239,6 @@ "ajv": "^6.9.1" } }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "license": "MIT", - "dependencies": { - "readdirp": "^4.0.1" - }, - "engines": { - "node": ">= 14.16.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/fork-ts-checker-webpack-plugin/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -6270,19 +6255,6 @@ "node": ">=10" } }, - "node_modules/fork-ts-checker-webpack-plugin/node_modules/readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", - "license": "MIT", - "engines": { - "node": ">= 14.18.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/fork-ts-checker-webpack-plugin/node_modules/schema-utils": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.2.0.tgz", @@ -15493,13 +15465,13 @@ "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==" }, "fork-ts-checker-webpack-plugin": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.1.0.tgz", - "integrity": "sha512-mpafl89VFPJmhnJ1ssH+8wmM2b50n+Rew5x42NeI2U78aRWgtkEtGmctp7iT16UjquJTjorEmIfESj3DxdW84Q==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.0.3.tgz", + "integrity": "sha512-zUE6ABwfybBbSH5TIsdAFiR2kfy0nm2yT0DEtujNM4vHbKhbrIsfoC5cPfJa4vqlmcSBPxqIED+EWVPWEw1hTw==", "requires": { "@babel/code-frame": "^7.16.7", "chalk": "^4.1.2", - "chokidar": "^4.0.1", + "chokidar": "^3.5.3", "cosmiconfig": "^8.2.0", "deepmerge": "^4.2.2", "fs-extra": "^10.0.0", @@ -15528,14 +15500,6 @@ "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", "requires": {} }, - "chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "requires": { - "readdirp": "^4.0.1" - } - }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -15549,11 +15513,6 @@ "yallist": "^4.0.0" } }, - "readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==" - }, "schema-utils": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.2.0.tgz", diff --git a/packages/pv-scripts/package.json b/packages/pv-scripts/package.json index 6600cf5..bf8f2f9 100644 --- a/packages/pv-scripts/package.json +++ b/packages/pv-scripts/package.json @@ -47,7 +47,7 @@ "cross-spawn": "7.0.6", "css-loader": "7.1.4", "cssnano": "8.0.2", - "fork-ts-checker-webpack-plugin": "9.1.0", + "fork-ts-checker-webpack-plugin": "9.0.3", "handlebars": "4.7.9", "handlebars-loader": "1.7.3", "html-webpack-plugin": "5.6.7",