webanvil 0.0.16 → 0.0.18

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
@@ -167,8 +167,10 @@ export default defineConfig({
167
167
  ### Storybook
168
168
 
169
169
  WebAnvil includes Storybook, the supported Vite framework adapters, Vitest's
170
- browser support, and Chromium. Add only a Storybook configuration and your
171
- project's normal framework dependencies.
170
+ browser support, and Chromium. It exposes that exact Storybook release as a
171
+ peer dependency, so package-manager-installed addons resolve against the same
172
+ runtime. Add a Storybook configuration, addons, and your project's normal
173
+ framework dependencies.
172
174
 
173
175
  For a Node design-system project, configure Storybook beside the package build:
174
176
 
@@ -423,9 +425,11 @@ names and source maps.
423
425
 
424
426
  ### Node declarations
425
427
 
426
- `build.declaration: true` uses `rolldown-plugin-dts` with its TypeScript
427
- generator. Pass a native declaration options object to select the `"oxc"` or
428
- `"tsgo"` generator and other plugin settings:
428
+ `build.declaration: true` uses `rolldown-plugin-dts`. TypeScript 5 and 6 use
429
+ the full `tsc` generator. TypeScript 7 uses `tsgo` when the project has a
430
+ `tsconfig.json`; otherwise it uses Oxc's isolated declaration generator. Pass a
431
+ native declaration options object to choose a generator and other plugin
432
+ settings explicitly:
429
433
 
430
434
  ```ts
431
435
  import { defineConfig } from "webanvil"
@@ -440,11 +444,12 @@ export default defineConfig({
440
444
  })
441
445
  ```
442
446
 
443
- The TypeScript generator selects a compatible project/workspace TypeScript
447
+ The `tsc` generator selects a compatible project/workspace TypeScript
444
448
  declaration when present, otherwise WebAnvil's exact TypeScript fallback.
445
449
  Project-local `ts-patch` and TypeScript emit transforms are honored when they
446
- are directly declared and resolve to that same compiler. Emit transforms
447
- require the `tsc` generator; Oxc and `tsgo` are explicit alternatives.
450
+ are directly declared and resolve to that same compiler. They require `tsc`,
451
+ which supports TypeScript 5 and 6; use `tsgo` with a `tsconfig.json` or Oxc for
452
+ TypeScript 7 declarations.
448
453
 
449
454
  `rolldown-plugin-dts` owns declaration paths and imports. ESM-only builds attach
450
455
  one declaration graph; CommonJS-only and dual-format builds use one
@@ -13,8 +13,6 @@ import { resolvePath } from "mlly";
13
13
  import { parse } from "yaml";
14
14
  import { resolvePackageJSON } from "pkg-types";
15
15
  import { execa } from "execa";
16
- import { playwright } from "@vitest/browser-playwright";
17
- import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
18
16
  import { consola } from "consola";
19
17
  import { randomUUID } from "node:crypto";
20
18
  import { tmpdir } from "node:os";
@@ -365,7 +363,6 @@ var Toolchain = class {
365
363
  };
366
364
  const formatResolvedTool = (tool) => `${tool.packageName} ${tool.version} (${tool.source})`;
367
365
  const declarationDefaults = {
368
- generator: "tsc",
369
366
  incremental: false,
370
367
  newContext: true,
371
368
  parallel: false
@@ -469,11 +466,21 @@ const withoutImplicitIncremental = (config) => {
469
466
  }
470
467
  };
471
468
  };
469
+ const usesTypeScriptSeven = (typescript) => typescript.version.startsWith("7.");
470
+ const selectDeclarationGenerator = async (configured, plugins, tsconfigPath, toolchain) => {
471
+ const requested = configured.generator;
472
+ if (plugins.length > 0 && requested !== void 0 && requested !== "tsc") throw new Error(`TypeScript declaration transforms from ${tsconfigPath ?? "compilerOptions"} require build.declaration.generator "tsc"; ${requested} cannot apply TypeScript emit transforms`);
473
+ if (requested === "oxc" || requested === "tsgo") return requested;
474
+ const typescript = await toolchain.resolve("typescript");
475
+ if (!usesTypeScriptSeven(typescript)) return "tsc";
476
+ if (requested === "tsc") throw new Error(`build.declaration.generator "tsc" does not support TypeScript ${typescript.version}; use "tsgo" with a tsconfig.json or "oxc" instead`);
477
+ if (plugins.length > 0) throw new Error(`TypeScript declaration transforms from ${tsconfigPath ?? "compilerOptions"} require the "tsc" generator, which does not support TypeScript ${typescript.version}; use TypeScript 6 or below, or remove the transforms`);
478
+ return tsconfigPath === void 0 ? "oxc" : "tsgo";
479
+ };
472
480
  const createDeclarationPlugins = async (declaration, cwd, toolchain, emitDtsOnly) => serializeSetup(async () => {
473
481
  const configured = withoutImplicitIncremental(declaration === true ? {} : declaration);
474
- const generator = configured.generator ?? declarationDefaults.generator;
475
482
  const { plugins, tsconfigPath } = compilerPlugins(cwd, configured);
476
- if (plugins.length > 0 && generator !== "tsc") throw new Error(`TypeScript declaration transforms from ${tsconfigPath ?? "compilerOptions"} require build.declaration.generator "tsc"; ${generator} cannot apply TypeScript emit transforms`);
483
+ const generator = await selectDeclarationGenerator(configured, plugins, tsconfigPath, toolchain);
477
484
  const options = {
478
485
  ...declarationDefaults,
479
486
  ...configured,
@@ -1208,6 +1215,7 @@ const createStorybookTestProject = async (config = {}, vitestVersion = storybook
1208
1215
  if (vitestVersion !== storybookVitestVersion) throw new Error(`Storybook tests require Vitest ${storybookVitestVersion}; Webanvil bundles @vitest/browser-playwright ${storybookVitestVersion}`);
1209
1216
  const previousVitest = process.env.VITEST;
1210
1217
  process.env.VITEST = "true";
1218
+ const [{ playwright }, { storybookTest }] = await Promise.all([import("@vitest/browser-playwright"), import("@storybook/addon-vitest/vitest-plugin")]);
1211
1219
  let plugins;
1212
1220
  try {
1213
1221
  plugins = await storybookTest({ configDir: config.configDir });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webanvil",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A unified CLI for building, testing, linting, formatting, and type-checking JavaScript and TypeScript projects.",
5
5
  "keywords": [
6
6
  "build-tool",
@@ -161,6 +161,9 @@
161
161
  "obuild": "^0.4.38",
162
162
  "unplugin": "^3.3.0"
163
163
  },
164
+ "peerDependencies": {
165
+ "storybook": "10.5.9"
166
+ },
164
167
  "engines": {
165
168
  "node": "^22.18.0 || >=24.11.0"
166
169
  }