@rtorcato/js-tooling 2.19.0 → 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,19 +57,15 @@ npx --no -- commitlint --edit $1
57
57
  // lint-staged configuration in package.json
58
58
  const packageJsonPath = path.join(targetDir, 'package.json');
59
59
  const packageJson = await fs.readJson(packageJsonPath);
60
+ // No explicit `git add` — lint-staged stages tool output itself, and the
61
+ // extra add races its index lock. `--no-errors-on-unmatched` keeps biome
62
+ // from failing a commit when every matched file is biome-ignored.
63
+ const useBiome = config.linting.tool === 'biome' || config.linting.tool === 'both';
60
64
  packageJson['lint-staged'] = {
61
- '*.{js,ts,jsx,tsx}': [
62
- config.linting.tool === 'biome' || config.linting.tool === 'both'
63
- ? 'biome check --fix'
64
- : 'eslint --fix',
65
- 'git add',
66
- ],
67
- '*.{json,md,yml,yaml}': [
68
- config.linting.tool === 'biome' || config.linting.tool === 'both'
69
- ? 'biome format --write'
70
- : 'prettier --write',
71
- 'git add',
72
- ],
65
+ '*.{js,ts,jsx,tsx}': useBiome ? 'biome check --fix --no-errors-on-unmatched' : 'eslint --fix',
66
+ '*.{json,md,yml,yaml}': useBiome
67
+ ? 'biome format --write --no-errors-on-unmatched'
68
+ : 'prettier --write',
73
69
  };
74
70
  await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
75
71
  }
@@ -53,7 +53,7 @@ jobs:
53
53
  - name: 📦 Setup Node.js
54
54
  uses: actions/setup-node@v4
55
55
  with:
56
- node-version: '20'
56
+ node-version-file: .nvmrc
57
57
 
58
58
  - name: 📦 Setup pnpm
59
59
  uses: pnpm/action-setup@v4
@@ -88,7 +88,7 @@ jobs:
88
88
  - name: 📦 Setup Node.js
89
89
  uses: actions/setup-node@v4
90
90
  with:
91
- node-version: '20'
91
+ node-version-file: .nvmrc
92
92
 
93
93
  - name: 📦 Setup pnpm
94
94
  uses: pnpm/action-setup@v4
@@ -118,7 +118,7 @@ ${hasTypeScript
118
118
  - name: 📦 Setup Node.js
119
119
  uses: actions/setup-node@v4
120
120
  with:
121
- node-version: '20'
121
+ node-version-file: .nvmrc
122
122
 
123
123
  - name: 📦 Setup pnpm
124
124
  uses: pnpm/action-setup@v4
@@ -149,7 +149,7 @@ ${hasTests
149
149
  - name: 📦 Setup Node.js
150
150
  uses: actions/setup-node@v4
151
151
  with:
152
- node-version: '20'
152
+ node-version-file: .nvmrc
153
153
 
154
154
  - name: 📦 Setup pnpm
155
155
  uses: pnpm/action-setup@v4
@@ -180,7 +180,7 @@ ${hasBuild
180
180
  - name: 📦 Setup Node.js
181
181
  uses: actions/setup-node@v4
182
182
  with:
183
- node-version: '20'
183
+ node-version-file: .nvmrc
184
184
 
185
185
  - name: 📦 Setup pnpm
186
186
  uses: pnpm/action-setup@v4
@@ -229,7 +229,7 @@ ${isLibrary && config.semanticRelease
229
229
  - name: 📦 Setup Node.js
230
230
  uses: actions/setup-node@v4
231
231
  with:
232
- node-version: '20'
232
+ node-version-file: .nvmrc
233
233
  registry-url: 'https://registry.npmjs.org'
234
234
 
235
235
  - name: 📦 Setup pnpm
@@ -27,13 +27,13 @@ export async function generateOxlintConfig(targetDir) {
27
27
  }
28
28
  export async function generateBiomeConfig(targetDir) {
29
29
  const biomeConfigPath = path.join(targetDir, 'biome.jsonc');
30
+ // Biome 2.x schema + shape. The base preset (extends) already defines the
31
+ // file globs via `files.includes`; emitting the old 1.x `include`/`ignore`
32
+ // keys here forced consumers to run `biome migrate` before `biome check`
33
+ // would run at all.
30
34
  const biomeConfig = {
31
- $schema: 'https://biomejs.dev/schemas/1.9.4/schema.json',
35
+ $schema: 'https://biomejs.dev/schemas/2.3.0/schema.json',
32
36
  extends: ['@rtorcato/js-tooling/biome'],
33
- files: {
34
- include: ['src/**/*', '*.ts', '*.js', '*.tsx', '*.jsx'],
35
- ignore: ['node_modules', 'dist', 'build', '.next'],
36
- },
37
37
  };
38
38
  await fs.writeJson(biomeConfigPath, biomeConfig, { spaces: 2 });
39
39
  }
@@ -26,16 +26,22 @@ export async function generatePackageJson(config, targetDir) {
26
26
  ...existingPackageJson?.devDependencies,
27
27
  },
28
28
  };
29
- // Add additional package.json fields based on project type
29
+ // Add additional package.json fields based on project type.
30
+ // Exports must match tsup's output for a "type": "module" package with
31
+ // format: ['cjs','esm']: ESM → index.js, CJS → index.cjs, types →
32
+ // index.d.ts (ESM) / index.d.cts (CJS).
30
33
  if (config.projectType === 'library') {
31
- packageJson.main = './dist/index.js';
32
- packageJson.module = './dist/index.mjs';
34
+ packageJson.main = './dist/index.cjs';
35
+ packageJson.module = './dist/index.js';
33
36
  packageJson.types = './dist/index.d.ts';
34
37
  packageJson.exports = {
35
38
  '.': {
36
- import: './dist/index.mjs',
37
- require: './dist/index.js',
38
- types: './dist/index.d.ts',
39
+ types: {
40
+ import: './dist/index.d.ts',
41
+ require: './dist/index.d.cts',
42
+ },
43
+ import: './dist/index.js',
44
+ require: './dist/index.cjs',
39
45
  },
40
46
  };
41
47
  packageJson.files = ['dist'];
@@ -43,6 +49,15 @@ export async function generatePackageJson(config, targetDir) {
43
49
  access: 'public',
44
50
  };
45
51
  }
52
+ // pnpm 11 refuses to run a dependency's build script unless it's approved.
53
+ // esbuild (pulled in by tsup/esbuild/vite) has one, so `pnpm install` exits
54
+ // 1 with ERR_PNPM_IGNORED_BUILDS until it's whitelisted here.
55
+ if (config.bundler === 'tsup' || config.bundler === 'esbuild' || config.bundler === 'vite') {
56
+ packageJson.pnpm = {
57
+ ...packageJson.pnpm,
58
+ onlyBuiltDependencies: ['esbuild'],
59
+ };
60
+ }
46
61
  await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
47
62
  }
48
63
  function getScripts(config, opts = {}) {
@@ -213,10 +228,14 @@ function getDependencies(config) {
213
228
  deps['@commitlint/cli'] = '^20.0.0';
214
229
  deps['@commitlint/config-conventional'] = '^20.0.0';
215
230
  }
216
- // Semantic release
231
+ // Semantic release. The shipped github preset activates the changelog and
232
+ // git plugins (and @semantic-release/github), so they must be installed too
233
+ // or `semantic-release` crashes with "Cannot find module".
217
234
  if (config.semanticRelease) {
218
235
  deps['semantic-release'] = '^25.0.0';
219
236
  deps['@semantic-release/github'] = '^12.0.0';
237
+ deps['@semantic-release/changelog'] = '^6.0.0';
238
+ deps['@semantic-release/git'] = '^10.0.0';
220
239
  }
221
240
  return deps;
222
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtorcato/js-tooling",
3
- "version": "2.19.0",
3
+ "version": "2.19.1",
4
4
  "description": "JavaScript and TypeScript tooling for Node.js, React, Next.js, and Vitest.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -71,7 +71,8 @@
71
71
  "tooling/tests/exports-resolution.d.mts",
72
72
  "tooling/tests/ssr-safety.mjs",
73
73
  "tooling/tests/ssr-safety.d.mts",
74
- "tooling/tsup/index.ts",
74
+ "tooling/tsup/index.mjs",
75
+ "tooling/tsup/index.d.mts",
75
76
  "tooling/biome/biome.json",
76
77
  "tooling/changesets/config.json",
77
78
  "tooling/oxlint/oxlintrc.json",
@@ -147,7 +148,10 @@
147
148
  "types": "./tooling/vitest/jsdom-shims.d.mts",
148
149
  "import": "./tooling/vitest/jsdom-shims.mjs"
149
150
  },
150
- "./tsup": "./tooling/tsup/index.ts",
151
+ "./tsup": {
152
+ "types": "./tooling/tsup/index.d.mts",
153
+ "import": "./tooling/tsup/index.mjs"
154
+ },
151
155
  "./biome": "./tooling/biome/biome.json",
152
156
  "./changesets": "./tooling/changesets/config.json",
153
157
  "./oxlint": "./tooling/oxlint/oxlintrc.json",
@@ -0,0 +1,8 @@
1
+ import type { Options } from 'tsup'
2
+ import type { defineConfig } from 'tsup'
3
+
4
+ export type DefineConfig = ReturnType<typeof defineConfig>
5
+
6
+ export declare const getConfig: (customOptions: Options, env: string) => DefineConfig
7
+
8
+ export declare const baseOptions: (options: Options, env: string) => Options
@@ -0,0 +1,23 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export const getConfig = (customOptions, env) => {
4
+ return defineConfig((options = customOptions) => {
5
+ return baseOptions(options, env)
6
+ })
7
+ }
8
+
9
+ export const baseOptions = (options, env) => {
10
+ const opts = {
11
+ treeshake: true,
12
+ splitting: true,
13
+ format: ['cjs', 'esm'], // generate cjs and esm files
14
+ entry: ['src/**/*.ts'],
15
+ skipNodeModulesBundle: true, // Skips building dependencies for node modules
16
+ minify: !options.watch && env === 'production',
17
+ bundle: false,
18
+ clean: true, // clean up the dist folder
19
+ dts: true, // generate dts file for main module
20
+ ...options,
21
+ }
22
+ return opts
23
+ }
@@ -27,6 +27,10 @@
27
27
  // 📈 Performance
28
28
  "skipLibCheck": true, // Skip type checking of declaration files
29
29
  "incremental": true, // Enable incremental compilation
30
+ // Pin the build-info location so downstream emit tools (e.g. tsup's `dts`
31
+ // build) don't hit TS5074 from inheriting `incremental` without a file.
32
+ // ${configDir} resolves to the consuming project's dir (TS 5.5+).
33
+ "tsBuildInfoFile": "${configDir}/node_modules/.cache/tsconfig.tsbuildinfo",
30
34
  "disableSourceOfProjectReferenceRedirect": true, // Disable source of project reference redirect
31
35
 
32
36
  // 🚨 Strict Type Checking
@@ -1,50 +0,0 @@
1
- import type { Options } from 'tsup'
2
- import { defineConfig } from 'tsup'
3
-
4
- export type DefineConfig = ReturnType<typeof defineConfig>
5
-
6
- export const getConfig: (customOptions: Options, env: string) => DefineConfig = (
7
- customOptions: Options,
8
- env: string
9
- ): DefineConfig => {
10
- return defineConfig((options: Options = customOptions) => {
11
- return baseOptions(options, env)
12
- })
13
- }
14
-
15
- export const baseOptions = (options: Options, env: string): Options => {
16
- const opts: Options = {
17
- treeshake: true,
18
- splitting: true,
19
- // target: 'es2020',
20
- // target: 'nodeNext',
21
- format: ['cjs', 'esm'], // generate cjs and esm files
22
- entry: [
23
- // './src/index.ts',
24
- 'src/**/*.ts',
25
- // './src/**/*!(index).ts?(x)',
26
- // '!./src/**/*.spec.*',
27
- // '!./src/**/*.stories.*',
28
- ],
29
- skipNodeModulesBundle: true, // Skips building dependencies for node modules
30
- minify: !options.watch && env === 'production',
31
- bundle: false, //env === 'production',
32
- clean: true, // clean up the dist folder
33
- dts: true, // generate dts file for main module
34
- // sourcemap: env === 'production', // source map is only available in prod
35
- // sourcemap: true,
36
- // outDir: env === 'production' ? 'dist' : 'lib',
37
- // outDir: 'dist',
38
- // tsconfig: path.resolve(__dirname, './tsconfig.build.json'),
39
- // esbuildOptions(options, context) {
40
- // options.outbase = './'
41
- // },
42
- // external: ['react'],
43
- ...options,
44
- // banner: {js: '"use client";'},
45
- // dts: {
46
- // footer: "declare module 'knex/types/tables';"
47
- // },
48
- }
49
- return opts
50
- }