@smoothbricks/nx-plugin 0.4.9 → 0.4.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAKL,yBAAyB,EAW1B,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAmDrC,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAwHD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+KD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAKL,yBAAyB,EAW1B,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAmDrC,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AA8HD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+KD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
package/dist/index.js CHANGED
@@ -132,8 +132,14 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
132
132
  '{workspaceRoot}/scripts/*.sh',
133
133
  '!{workspaceRoot}/**/target/**',
134
134
  ];
135
+ // The environment half of a cargo task's identity. Beyond cargo/rustc's own
136
+ // variables, every build script that compiles C/C++ reads the Apple SDK
137
+ // (SDKROOT, DEVELOPER_DIR, the deployment targets), bindgen reads its libclang
138
+ // and extra clang args, cmake-rs forwards CMAKE_*, and zig-based cross links
139
+ // read ZIG*. An output linked against one sysroot must never hash equal to
140
+ // the same sources linked against another.
135
141
  const CARGO_ENVIRONMENT_INPUT = {
136
- runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
142
+ runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_|SDKROOT$|DEVELOPER_DIR$|MACOSX_DEPLOYMENT_TARGET$|IPHONEOS_DEPLOYMENT_TARGET$|LIBCLANG_PATH$|BINDGEN_EXTRA_CLANG_ARGS|CMAKE_|ZIG)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
137
143
  };
138
144
  function cargoRuntimeInput(projectRoot, command) {
139
145
  const quotedRoot = `'${projectRoot.replaceAll("'", "'\"'\"'")}'`;
@@ -1 +1 @@
1
- {"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,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AAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAYjB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAsDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAO7F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAyDhE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAiEtE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAyD9D"}
@@ -1,6 +1,5 @@
1
1
  import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
- import { isDeepStrictEqual } from 'node:util';
4
3
  import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
5
4
  const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
6
5
  /**
@@ -130,11 +129,15 @@ export function applyTypecheckTestDefaults(tsconfigTest, options) {
130
129
  const extendsValue = options.tsconfigLibExtends ?? '../../tsconfig.base.json';
131
130
  let changed = setMissingStringProperty(tsconfigTest, 'extends', extendsValue);
132
131
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
133
- // Copy relevant compiler options from lib tsconfig
132
+ // Fill from the lib tsconfig only what the test program has NOT declared. A
133
+ // test program that names its own `lib` is stating a fact the lib program
134
+ // cannot know: it runs on one runtime (Bun's JSC understands
135
+ // change-array-by-copy) while the library's output has to run on the shipping
136
+ // floor. Overwriting it turned `toSorted` into a type error in a suite that
137
+ // calls it every day, and it came back on every `smoo monorepo update`.
134
138
  if (options.libCompilerOptions) {
135
139
  for (const key of ['baseUrl', 'module', 'moduleResolution', 'jsx', 'lib']) {
136
- if (Object.hasOwn(options.libCompilerOptions, key) &&
137
- !isDeepStrictEqual(compilerOptions[key], options.libCompilerOptions[key])) {
140
+ if (Object.hasOwn(options.libCompilerOptions, key) && !Object.hasOwn(compilerOptions, key)) {
138
141
  compilerOptions[key] = options.libCompilerOptions[key];
139
142
  changed = true;
140
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
package/src/index.ts CHANGED
@@ -179,8 +179,14 @@ const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
179
179
  '{workspaceRoot}/scripts/*.sh',
180
180
  '!{workspaceRoot}/**/target/**',
181
181
  ];
182
+ // The environment half of a cargo task's identity. Beyond cargo/rustc's own
183
+ // variables, every build script that compiles C/C++ reads the Apple SDK
184
+ // (SDKROOT, DEVELOPER_DIR, the deployment targets), bindgen reads its libclang
185
+ // and extra clang args, cmake-rs forwards CMAKE_*, and zig-based cross links
186
+ // read ZIG*. An output linked against one sysroot must never hash equal to
187
+ // the same sources linked against another.
182
188
  const CARGO_ENVIRONMENT_INPUT = {
183
- runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
189
+ runtime: `bun -e 'const fs = require("node:fs"); const path = require("node:path"); const home = process.env.CARGO_HOME || path.join(require("node:os").homedir(), ".cargo"); console.log(JSON.stringify({env: Object.entries(process.env).filter(([name]) => /^(?:CARGO_|RUST|NEXTEST_|CLIPPY_|CC(?:_|$)|CXX(?:_|$)|AR(?:_|$)|CFLAGS|CXXFLAGS|CPPFLAGS|LDFLAGS|PKG_CONFIG|TARGET_|HOST_|SDKROOT$|DEVELOPER_DIR$|MACOSX_DEPLOYMENT_TARGET$|IPHONEOS_DEPLOYMENT_TARGET$|LIBCLANG_PATH$|BINDGEN_EXTRA_CLANG_ARGS|CMAKE_|ZIG)/.test(name)).sort(([a], [b]) => a.localeCompare(b)), config: ["config", "config.toml"].map(name => { const file = path.join(home, name); return fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null; })}));'`,
184
190
  };
185
191
 
186
192
  function cargoRuntimeInput(projectRoot: string, command: string): { runtime: string } {
@@ -199,6 +199,33 @@ describe('applyTypecheckTestDefaults', () => {
199
199
  expect(references).toContainEqual({ path: './tsconfig.lib.json' });
200
200
  });
201
201
 
202
+ it('fills compiler options the test program left out and keeps the ones it declared', () => {
203
+ // A Bun-only test program declaring es2023 says something the library cannot
204
+ // know: its runtime has change-array-by-copy while the library's output ships
205
+ // to node, workerd and browsers. Overwriting it made `toSorted` a type error
206
+ // in a suite that calls it, and every `smoo monorepo update` reintroduced it.
207
+ const declared: Record<string, unknown> = {
208
+ compilerOptions: { lib: ['es2023'], types: ['bun'], noEmit: true },
209
+ };
210
+ applyTypecheckTestDefaults(declared, {
211
+ testRunners: new Set(['bun'] as const),
212
+ referencePaths: [],
213
+ libCompilerOptions: { lib: ['es2022'], module: 'preserve' },
214
+ });
215
+
216
+ const declaredOptions = expectRecord(declared.compilerOptions);
217
+ expect(declaredOptions.lib).toEqual(['es2023']);
218
+ expect(declaredOptions.module).toBe('preserve');
219
+
220
+ const silent: Record<string, unknown> = { compilerOptions: {} };
221
+ applyTypecheckTestDefaults(silent, {
222
+ testRunners: new Set(['bun'] as const),
223
+ referencePaths: [],
224
+ libCompilerOptions: { lib: ['es2022'] },
225
+ });
226
+ expect(expectRecord(silent.compilerOptions).lib).toEqual(['es2022']);
227
+ });
228
+
202
229
  it('uses custom extends from lib tsconfig', () => {
203
230
  const tsconfigTest: Record<string, unknown> = {};
204
231
  applyTypecheckTestDefaults(tsconfigTest, {
@@ -1,6 +1,5 @@
1
1
  import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
- import { isDeepStrictEqual } from 'node:util';
4
3
  import type { Tree } from 'nx/src/devkit-exports.js';
5
4
  import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
6
5
 
@@ -167,13 +166,15 @@ export function applyTypecheckTestDefaults(
167
166
 
168
167
  const compilerOptions = getOrCreateRecord(tsconfigTest, 'compilerOptions');
169
168
 
170
- // Copy relevant compiler options from lib tsconfig
169
+ // Fill from the lib tsconfig only what the test program has NOT declared. A
170
+ // test program that names its own `lib` is stating a fact the lib program
171
+ // cannot know: it runs on one runtime (Bun's JSC understands
172
+ // change-array-by-copy) while the library's output has to run on the shipping
173
+ // floor. Overwriting it turned `toSorted` into a type error in a suite that
174
+ // calls it every day, and it came back on every `smoo monorepo update`.
171
175
  if (options.libCompilerOptions) {
172
176
  for (const key of ['baseUrl', 'module', 'moduleResolution', 'jsx', 'lib']) {
173
- if (
174
- Object.hasOwn(options.libCompilerOptions, key) &&
175
- !isDeepStrictEqual(compilerOptions[key], options.libCompilerOptions[key])
176
- ) {
177
+ if (Object.hasOwn(options.libCompilerOptions, key) && !Object.hasOwn(compilerOptions, key)) {
177
178
  compilerOptions[key] = options.libCompilerOptions[key];
178
179
  changed = true;
179
180
  }