vize 0.345.0 → 0.350.2

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.
package/README.md CHANGED
@@ -71,7 +71,7 @@ Add scripts to your project and run Vize through your package manager:
71
71
  "vize:build": "vize build src",
72
72
  "vize:fmt": "vize fmt --write src",
73
73
  "vize:lint": "vize lint --preset happy-path src",
74
- "vize:check": "vize check src",
74
+ "vize:check": "vize check",
75
75
  "vize:ready": "vize ready src",
76
76
  "vize:upgrade": "vize upgrade"
77
77
  }
@@ -195,9 +195,11 @@ Use the Rust CLI when you need Corsa project diagnostics across Vue, TS, TSX, an
195
195
 
196
196
  ## Experimental TypeScript Content Mapper
197
197
 
198
- Vize publishes the package metadata and protocol server proposed by
199
- [microsoft/typescript-go#4712](https://github.com/microsoft/typescript-go/pull/4712). This lets a
200
- compatible `tsgo` build ask Vize to transform `.vue` files directly instead of materializing a
198
+ The TypeScript 7.1
199
+ [API roadmap](https://github.com/microsoft/typescript-go/issues/4830) identifies Content Mappers as
200
+ the TS Server plugin replacement needed by Vue. Vize publishes the package metadata and protocol
201
+ server proposed by [microsoft/typescript-go#4712](https://github.com/microsoft/typescript-go/pull/4712),
202
+ letting a compatible `tsgo` build transform `.vue` files directly instead of materializing a
201
203
  parallel `.vue.ts` project.
202
204
 
203
205
  ```json
@@ -217,13 +219,15 @@ parallel `.vue.ts` project.
217
219
  ```
218
220
 
219
221
  ```bash
220
- tsgo --loadExternalPlugins --noEmit -p tsconfig.json
222
+ tsgo --runExternalCode --noEmit -p tsconfig.json
221
223
  ```
222
224
 
223
225
  The content-mapper API is not in a released TypeScript native preview yet. Use the exact PR build
224
- while evaluating it, keep `--loadExternalPlugins` explicit, and keep `vize check` as the supported
226
+ while evaluating it, keep `--runExternalCode` explicit, and keep `vize check` as the supported
225
227
  typecheck path until TypeScript ships the protocol. Vize currently negotiates protocol v1 with
226
- UTF-8 mappings and does not declare compiler-option dependencies.
228
+ UTF-8 mappings, declares its `noUnusedLocals` compiler-option dependency under the
229
+ `typescript.contentMapper` manifest key, and tags every transform response with the `.tsx` virtual
230
+ extension so both TypeScript and embedded JSX parse correctly.
227
231
 
228
232
  ## Compiler and Tool Options
229
233
 
package/dist/cli.mjs CHANGED
@@ -94,7 +94,7 @@ const DEFAULT_SCRIPTS = {
94
94
  "vize:fmt": "vize fmt --check src",
95
95
  "vize:fmt:fix": "vize fmt --write src",
96
96
  "vize:lint": "vize lint --preset happy-path --max-warnings 0 src",
97
- "vize:check": "vize check src",
97
+ "vize:check": "vize check",
98
98
  "vize:musea": "vize musea",
99
99
  "vize:ready": "vize ready src"
100
100
  };
@@ -110,6 +110,7 @@ export default defineConfig({
110
110
  typeChecker: {
111
111
  enabled: true,
112
112
  strict: true,
113
+ jsxTypecheck: true,
113
114
  },
114
115
  vite: {
115
116
  scanPatterns: ["src/**/*.vue"],
@@ -249,6 +250,7 @@ function renderVizeConfig(features) {
249
250
  if (features.typecheck) blocks.push(` typeChecker: {
250
251
  enabled: true,
251
252
  strict: true,
253
+ jsxTypecheck: true,
252
254
  },`);
253
255
  if (features.vite) blocks.push(` vite: {
254
256
  scanPatterns: ["src/**/*.vue"],
@@ -260,6 +262,26 @@ ${blocks.join("\n")}
260
262
  });
261
263
  `;
262
264
  }
265
+ /** Minimum project config written only when typechecking is selected and no config exists. */
266
+ function renderTypecheckTsconfig(typescript) {
267
+ const compilerOptions = {
268
+ strict: true,
269
+ target: "ES2022",
270
+ module: "ESNext",
271
+ moduleResolution: "Bundler",
272
+ jsx: "preserve"
273
+ };
274
+ if (!typescript) {
275
+ compilerOptions.allowJs = true;
276
+ compilerOptions.checkJs = true;
277
+ }
278
+ compilerOptions.noEmit = true;
279
+ compilerOptions.skipLibCheck = true;
280
+ return `${JSON.stringify({
281
+ compilerOptions,
282
+ include: ["src/**/*"]
283
+ }, null, 2)}\n`;
284
+ }
263
285
  /**
264
286
  * Config for the `oxlint` binary.
265
287
  *
@@ -768,14 +790,14 @@ function fmtOffer(detection) {
768
790
  };
769
791
  }
770
792
  function typecheckOffer(detection) {
771
- const configured = detection.vizeConfig !== null && "vize:check" in detection.scripts;
793
+ const configured = detection.tsconfig !== null && detection.vizeConfig !== null && "vize:check" in detection.scripts;
772
794
  return {
773
795
  id: "typecheck",
774
796
  label: "typecheck (vize check)",
775
- available: detection.tsconfig !== null,
797
+ available: true,
776
798
  configured,
777
- note: configured ? "already configured" : detection.tsconfig === null ? "needs a tsconfig.json" : "",
778
- defaultSelected: detection.tsconfig !== null
799
+ note: configured ? "already configured" : detection.tsconfig === null ? "creates tsconfig.json" : "",
800
+ defaultSelected: true
779
801
  };
780
802
  }
781
803
  function editorOffer(detection) {
@@ -898,7 +920,7 @@ Options:
898
920
  --nuxt nuxt module (forces the Nuxt target)
899
921
  --bundler/--no-bundler vite plugin or nuxt module, auto-detected
900
922
  --fmt / --no-fmt vize fmt
901
- --typecheck vize check (needs a tsconfig.json)
923
+ --typecheck vize check (creates tsconfig.json when missing)
902
924
  --no-typecheck
903
925
  --editor / --no-editor .vscode/extensions.json recommendation
904
926
  --dry-run Print the plan without writing anything
@@ -1153,7 +1175,7 @@ function planNuxtModule(detection, draft) {
1153
1175
  }
1154
1176
  //#endregion
1155
1177
  //#region src/init/plan-editor.ts
1156
- const EXTENSIONS_FILE = path.join(".vscode", "extensions.json");
1178
+ const EXTENSIONS_FILE = ".vscode/extensions.json";
1157
1179
  /**
1158
1180
  * Plans the editor recommendation.
1159
1181
  *
@@ -1301,24 +1323,23 @@ const FEATURE_SCRIPTS = {
1301
1323
  * guess that loses their settings.
1302
1324
  */
1303
1325
  function planVizeConfig(detection, selection, draft) {
1326
+ if (selection.typecheck && detection.tsconfig === null) {
1327
+ draft.files.push({
1328
+ filename: path.join(detection.root, "tsconfig.json"),
1329
+ source: renderTypecheckTsconfig(detection.typescript)
1330
+ });
1331
+ draft.createdFiles.push("tsconfig.json");
1332
+ }
1304
1333
  for (const id of ["fmt", "typecheck"]) {
1305
1334
  if (!selection[id]) {
1306
- draft.features.push(id === "typecheck" && detection.tsconfig === null ? skipped(id, "no tsconfig.json, so vize check has nothing to check") : skipped(id));
1307
- continue;
1308
- }
1309
- if (id === "typecheck" && detection.tsconfig === null) {
1310
- draft.features.push({
1311
- id,
1312
- outcome: "blocked",
1313
- detail: "vize check needs a tsconfig.json; none was found",
1314
- snippet: null
1315
- });
1335
+ draft.features.push(skipped(id));
1316
1336
  continue;
1317
1337
  }
1338
+ const scaffoldsTsconfig = id === "typecheck" && detection.tsconfig === null;
1318
1339
  draft.features.push({
1319
1340
  id,
1320
- outcome: detection.vizeConfig === null ? "configured" : "unchanged",
1321
- detail: detection.vizeConfig === null ? "writes vize.config.ts" : `${detection.vizeConfig} already exists and was left unchanged`,
1341
+ outcome: scaffoldsTsconfig || detection.vizeConfig === null ? "configured" : "unchanged",
1342
+ detail: scaffoldsTsconfig ? detection.vizeConfig === null ? "writes tsconfig.json and vize.config.ts" : `writes tsconfig.json; ${detection.vizeConfig} already exists and was left unchanged` : detection.vizeConfig === null ? "writes vize.config.ts" : `${detection.vizeConfig} already exists and was left unchanged`,
1322
1343
  snippet: null
1323
1344
  });
1324
1345
  }
@@ -1328,7 +1349,7 @@ function planVizeConfig(detection, selection, draft) {
1328
1349
  source: renderVizeConfig({
1329
1350
  lint: selection.lint,
1330
1351
  fmt: selection.fmt,
1331
- typecheck: selection.typecheck && detection.tsconfig !== null,
1352
+ typecheck: selection.typecheck,
1332
1353
  vite: detection.framework === "vite"
1333
1354
  })
1334
1355
  });
@@ -1348,7 +1369,7 @@ function planScripts(detection, selection, draft) {
1348
1369
  "fmt",
1349
1370
  "typecheck"
1350
1371
  ]) {
1351
- if (!selection[id] || id === "typecheck" && detection.tsconfig === null) continue;
1372
+ if (!selection[id]) continue;
1352
1373
  wanted.push(...FEATURE_SCRIPTS[id]);
1353
1374
  }
1354
1375
  const missing = wanted.filter((name) => !(name in detection.scripts));