@ttsc/unplugin 0.16.2 → 0.16.4

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
@@ -122,7 +122,7 @@ export default withTtsc(nextConfig);
122
122
 
123
123
  ### Turbopack
124
124
 
125
- Turbopack has no JS plugin API, but it runs webpack loaders through `turbopack.rules` and a ttsc transform is exactly loader-shaped (TypeScript source in, transformed source out). `@ttsc/unplugin/turbopack` is that standalone loader:
125
+ Turbopack has no JS plugin API, but it runs webpack loaders through `turbopack.rules`, and a ttsc transform is exactly loader-shaped (TypeScript source in, transformed source out). `@ttsc/unplugin/turbopack` is that standalone loader:
126
126
 
127
127
  ```js
128
128
  // next.config.mjs
@@ -280,7 +280,7 @@ Supported entrypoints are:
280
280
  - `@ttsc/unplugin/next`
281
281
  - `@ttsc/unplugin/bun`
282
282
 
283
- Each entrypoint supports ESM import and CJS require. In CommonJS configs, read the default export from `require("@ttsc/unplugin/vite").default`. `@ttsc/unplugin/turbopack` is not an unplugin factory but a standalone webpack loader reference it by module name inside `turbopack.rules` instead of calling it.
283
+ Each entrypoint supports ESM import and CJS require. In CommonJS configs, read the default export from `require("@ttsc/unplugin/vite").default`. `@ttsc/unplugin/turbopack` is not an unplugin factory but a standalone webpack loader; reference it by module name inside `turbopack.rules` instead of calling it.
284
284
 
285
285
  ### Options
286
286
 
@@ -302,7 +302,7 @@ const options: TtscUnpluginOptions = {
302
302
 
303
303
  ### Watch Mode and HMR
304
304
 
305
- Transform plugins may report, per file, the source files they consulted (the transform envelope's `dependencies` field see the [plugin protocol](https://ttsc.dev/docs/development/concepts/protocol#transform)). The adapter registers each reported path with the bundler via `addWatchFile`, so editing a type that only a generated validator depends on invalidates the module in watch mode even though the bundler erased the type-only import from its graph.
305
+ Transform plugins may report, per file, the source files they consulted (the transform envelope's `dependencies` field, see the [plugin protocol](https://ttsc.dev/docs/development/concepts/protocol#transform)). The adapter registers each reported path with the bundler via `addWatchFile`, so editing a type that only a generated validator depends on invalidates the module in watch mode even though the bundler erased the type-only import from its graph.
306
306
 
307
307
  ## Sponsors
308
308
 
package/lib/core/index.js CHANGED
@@ -16,7 +16,7 @@ const sourceFilePattern = /\.[cm]?tsx?$/;
16
16
  /** Matches any path segment that is a `node_modules` directory (cross-platform). */
17
17
  const nodeModulesPattern = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
18
18
  /**
19
- * Matches virtual module ids Rollup/Vite use a leading NUL byte (`\0`) as
19
+ * Matches virtual module ids: Rollup/Vite use a leading NUL byte (`\0`) as
20
20
  * convention.
21
21
  */
22
22
  const virtualModulePattern = /\0/;
@@ -12,7 +12,7 @@ const sourceFilePattern = /\.[cm]?tsx?$/;
12
12
  /** Matches any path segment that is a `node_modules` directory (cross-platform). */
13
13
  const nodeModulesPattern = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
14
14
  /**
15
- * Matches virtual module ids Rollup/Vite use a leading NUL byte (`\0`) as
15
+ * Matches virtual module ids: Rollup/Vite use a leading NUL byte (`\0`) as
16
16
  * convention.
17
17
  */
18
18
  const virtualModulePattern = /\0/;
@@ -30,8 +30,8 @@ export interface TtscUnpluginOptions {
30
30
  * Fully-resolved plugin options with all defaults applied.
31
31
  *
32
32
  * Produced by {@link resolveOptions}; consumed internally by the transform
33
- * pipeline. Every field is present and normalised callers should not
34
- * construct this type directly.
33
+ * pipeline. Every field is present and normalised; callers should not construct
34
+ * this type directly.
35
35
  */
36
36
  export interface ResolvedTtscUnpluginOptions {
37
37
  /** Compiler-options overlay applied on top of the discovered tsconfig. */
@@ -27,7 +27,7 @@ export interface TtscTransformAlias {
27
27
  * input file. On subsequent transforms the cached entry is validated by
28
28
  * re-hashing the project and comparing against {@link inputHashes}; a mismatch
29
29
  * triggers a full re-transform. Both sides hash the same set of files (the
30
- * project directory walk), so the comparison is meaningful keying the
30
+ * project directory walk), so the comparison is meaningful; keying the
31
31
  * compiler's out-of-walk output paths on only one side is what made the cache
32
32
  * miss on every module.
33
33
  */
@@ -85,7 +85,7 @@ export interface TtscTransformHooks {
85
85
  * @param cache - Optional per-build cache; cleared by the caller on
86
86
  * `buildStart`.
87
87
  * @param hooks - Optional adapter callbacks; see {@link TtscTransformHooks}.
88
- * Dependency notifications fire on cache hits too watch registrations are
88
+ * Dependency notifications fire on cache hits too; watch registrations are
89
89
  * per build, not per compilation.
90
90
  */
91
91
  export declare function transformTtsc(id: string, source: string, options: ResolvedTtscUnpluginOptions, aliases?: unknown, cache?: TtscTransformCache, hooks?: TtscTransformHooks): Promise<TtscTransformResult | undefined>;
@@ -31,7 +31,7 @@ function createTtscTransformCache() {
31
31
  * @param cache - Optional per-build cache; cleared by the caller on
32
32
  * `buildStart`.
33
33
  * @param hooks - Optional adapter callbacks; see {@link TtscTransformHooks}.
34
- * Dependency notifications fire on cache hits too watch registrations are
34
+ * Dependency notifications fire on cache hits too; watch registrations are
35
35
  * per build, not per compilation.
36
36
  */
37
37
  async function transformTtsc(id, source, options, aliases, cache, hooks) {
@@ -98,7 +98,7 @@ async function transformTtsc(id, source, options, aliases, cache, hooks) {
98
98
  * The transform envelope's `dependencies` keys mirror the `typescript` keys
99
99
  * (project-relative); values may be project-relative or absolute. Every path is
100
100
  * absolutized against the project root and deduplicated, and the file itself is
101
- * dropped the bundler already watches the module it transforms.
101
+ * dropped; the bundler already watches the module it transforms.
102
102
  */
103
103
  function notifyFileDependencies(hooks, props) {
104
104
  const addWatchFile = hooks?.addWatchFile;
@@ -196,9 +196,9 @@ function createTransformResult(source, code) {
196
196
  *
197
197
  * Re-hashes every file under the project root and overlays the current module's
198
198
  * in-memory source, then compares the snapshot against the one captured when
199
- * the result was produced. Any input under the project root changing the
200
- * module itself or a sibling the plugin reads invalidates the entry and
201
- * forces a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
199
+ * the result was produced. Any input under the project root changing (the
200
+ * module itself or a sibling the plugin reads) invalidates the entry and forces
201
+ * a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
202
202
  * declarations, sibling-package sources) are not seen here; adapters invalidate
203
203
  * on those through the reported `dependencies` → `addWatchFile` → the bundler's
204
204
  * next `buildStart` cache clear.
@@ -208,8 +208,8 @@ function createTransformResult(source, code) {
208
208
  * the key universe. The earlier implementation overlaid the compiler's output
209
209
  * keys here on only one side; those keys include out-of-walk program inputs
210
210
  * (`node_modules` declarations, sibling-package sources), so the snapshots
211
- * never matched and the cache missed on every module re-transforming the
212
- * whole project once per file on any project that imports a typed dependency.
211
+ * never matched and the cache missed on every module; re-transforming the whole
212
+ * project once per file on any project that imports a typed dependency.
213
213
  */
214
214
  function matchesCachedSource(cached, file, source) {
215
215
  const currentKey = toProjectKey(cached.projectRoot, file);
@@ -220,8 +220,8 @@ function matchesCachedSource(cached, file, source) {
220
220
  /**
221
221
  * Build the input-hash snapshot stored alongside a fresh compiler result.
222
222
  *
223
- * Hashes every file under the project directory the exact universe
224
- * {@link matchesCachedSource} re-hashes to validate then overlays the
223
+ * Hashes every file under the project directory (the exact universe
224
+ * {@link matchesCachedSource} re-hashes to validate), then overlays the
225
225
  * in-memory source for the module that triggered the compile so unsaved editor
226
226
  * content is captured correctly.
227
227
  *
@@ -419,7 +419,7 @@ function normalizePluginConfigForGeneratedTsconfig(entry, tsconfigDir) {
419
419
  * project's own `paths` wholesale. The overlay therefore re-states the
420
420
  * project's effective mappings first, so tsconfig-only aliases keep resolving;
421
421
  * inline `compilerOptions.paths` from the plugin options ride on top, and the
422
- * bundler aliases win last they mirror what the bundler will actually do at
422
+ * bundler aliases win last; they mirror what the bundler will actually do at
423
423
  * resolve time.
424
424
  *
425
425
  * No `baseUrl` is emitted: TypeScript-Go removed the option (TS5102), and all
@@ -624,7 +624,7 @@ function formatUnknownError(error) {
624
624
  * If `tsconfig` is supplied it is returned as-is (absolute) or resolved from
625
625
  * `process.cwd()` (relative). Otherwise the function walks ancestor directories
626
626
  * starting at `file`'s directory, returning the first `tsconfig.json` found.
627
- * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one the
627
+ * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one; the
628
628
  * compiler will error if that file does not exist, which is the correct
629
629
  * behavior for a mis-configured project.
630
630
  */
@@ -641,7 +641,7 @@ function resolveTsconfig(file, tsconfig) {
641
641
  return candidate;
642
642
  }
643
643
  const parent = path.dirname(current);
644
- // Reached filesystem root stop walking.
644
+ // Reached filesystem root, stop walking.
645
645
  if (parent === current) {
646
646
  break;
647
647
  }
@@ -29,7 +29,7 @@ function createTtscTransformCache() {
29
29
  * @param cache - Optional per-build cache; cleared by the caller on
30
30
  * `buildStart`.
31
31
  * @param hooks - Optional adapter callbacks; see {@link TtscTransformHooks}.
32
- * Dependency notifications fire on cache hits too watch registrations are
32
+ * Dependency notifications fire on cache hits too; watch registrations are
33
33
  * per build, not per compilation.
34
34
  */
35
35
  async function transformTtsc(id, source, options, aliases, cache, hooks) {
@@ -96,7 +96,7 @@ async function transformTtsc(id, source, options, aliases, cache, hooks) {
96
96
  * The transform envelope's `dependencies` keys mirror the `typescript` keys
97
97
  * (project-relative); values may be project-relative or absolute. Every path is
98
98
  * absolutized against the project root and deduplicated, and the file itself is
99
- * dropped the bundler already watches the module it transforms.
99
+ * dropped; the bundler already watches the module it transforms.
100
100
  */
101
101
  function notifyFileDependencies(hooks, props) {
102
102
  const addWatchFile = hooks?.addWatchFile;
@@ -194,9 +194,9 @@ function createTransformResult(source, code) {
194
194
  *
195
195
  * Re-hashes every file under the project root and overlays the current module's
196
196
  * in-memory source, then compares the snapshot against the one captured when
197
- * the result was produced. Any input under the project root changing the
198
- * module itself or a sibling the plugin reads invalidates the entry and
199
- * forces a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
197
+ * the result was produced. Any input under the project root changing (the
198
+ * module itself or a sibling the plugin reads) invalidates the entry and forces
199
+ * a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
200
200
  * declarations, sibling-package sources) are not seen here; adapters invalidate
201
201
  * on those through the reported `dependencies` → `addWatchFile` → the bundler's
202
202
  * next `buildStart` cache clear.
@@ -206,8 +206,8 @@ function createTransformResult(source, code) {
206
206
  * the key universe. The earlier implementation overlaid the compiler's output
207
207
  * keys here on only one side; those keys include out-of-walk program inputs
208
208
  * (`node_modules` declarations, sibling-package sources), so the snapshots
209
- * never matched and the cache missed on every module re-transforming the
210
- * whole project once per file on any project that imports a typed dependency.
209
+ * never matched and the cache missed on every module; re-transforming the whole
210
+ * project once per file on any project that imports a typed dependency.
211
211
  */
212
212
  function matchesCachedSource(cached, file, source) {
213
213
  const currentKey = toProjectKey(cached.projectRoot, file);
@@ -218,8 +218,8 @@ function matchesCachedSource(cached, file, source) {
218
218
  /**
219
219
  * Build the input-hash snapshot stored alongside a fresh compiler result.
220
220
  *
221
- * Hashes every file under the project directory the exact universe
222
- * {@link matchesCachedSource} re-hashes to validate then overlays the
221
+ * Hashes every file under the project directory (the exact universe
222
+ * {@link matchesCachedSource} re-hashes to validate), then overlays the
223
223
  * in-memory source for the module that triggered the compile so unsaved editor
224
224
  * content is captured correctly.
225
225
  *
@@ -417,7 +417,7 @@ function normalizePluginConfigForGeneratedTsconfig(entry, tsconfigDir) {
417
417
  * project's own `paths` wholesale. The overlay therefore re-states the
418
418
  * project's effective mappings first, so tsconfig-only aliases keep resolving;
419
419
  * inline `compilerOptions.paths` from the plugin options ride on top, and the
420
- * bundler aliases win last they mirror what the bundler will actually do at
420
+ * bundler aliases win last; they mirror what the bundler will actually do at
421
421
  * resolve time.
422
422
  *
423
423
  * No `baseUrl` is emitted: TypeScript-Go removed the option (TS5102), and all
@@ -622,7 +622,7 @@ function formatUnknownError(error) {
622
622
  * If `tsconfig` is supplied it is returned as-is (absolute) or resolved from
623
623
  * `process.cwd()` (relative). Otherwise the function walks ancestor directories
624
624
  * starting at `file`'s directory, returning the first `tsconfig.json` found.
625
- * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one the
625
+ * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one; the
626
626
  * compiler will error if that file does not exist, which is the correct
627
627
  * behavior for a mis-configured project.
628
628
  */
@@ -639,7 +639,7 @@ function resolveTsconfig(file, tsconfig) {
639
639
  return candidate;
640
640
  }
641
641
  const parent = path.dirname(current);
642
- // Reached filesystem root stop walking.
642
+ // Reached filesystem root, stop walking.
643
643
  if (parent === current) {
644
644
  break;
645
645
  }
@@ -6,8 +6,8 @@
6
6
  * is the whole object from the nearest config in the chain that declares one
7
7
  * (own config first, then `extends` entries in reverse priority order).
8
8
  * Relative targets are anchored at the directory of the config that declares
9
- * them TypeScript-Go resolves inherited relative `paths` against the
10
- * declaring file, not the extending one.
9
+ * them. TypeScript-Go resolves inherited relative `paths` against the declaring
10
+ * file, not the extending one.
11
11
  *
12
12
  * The generated transform tsconfig replaces `paths` wholesale (standard
13
13
  * `extends` semantics), so the alias overlay must re-state these base mappings
@@ -12,8 +12,8 @@ var path = require('node:path');
12
12
  * is the whole object from the nearest config in the chain that declares one
13
13
  * (own config first, then `extends` entries in reverse priority order).
14
14
  * Relative targets are anchored at the directory of the config that declares
15
- * them TypeScript-Go resolves inherited relative `paths` against the
16
- * declaring file, not the extending one.
15
+ * them. TypeScript-Go resolves inherited relative `paths` against the declaring
16
+ * file, not the extending one.
17
17
  *
18
18
  * The generated transform tsconfig replaces `paths` wholesale (standard
19
19
  * `extends` semantics), so the alias overlay must re-state these base mappings
@@ -59,7 +59,7 @@ function absolutizePathsTarget(baseDir, target) {
59
59
  /**
60
60
  * Locate the nearest `compilerOptions.paths` declaration in the `extends` chain
61
61
  * rooted at `tsconfig`. The own config wins over its bases; within an `extends`
62
- * array, later entries win over earlier ones. `seen` breaks circular chains
62
+ * array, later entries win over earlier ones. `seen` breaks circular chains;
63
63
  * the compiler reports the actual config error.
64
64
  */
65
65
  function findDeclaredPaths(tsconfig, seen) {
@@ -111,7 +111,7 @@ function extendsSpecifiers(extended) {
111
111
  * Resolve an `extends` specifier to an absolute config path using TypeScript's
112
112
  * rules: absolute paths and relative specifiers get `.json` /
113
113
  * `tsconfig.json`-directory fallbacks; bare specifiers go through Node's module
114
- * resolver scoped to the declaring config. Returns `null` instead of throwing
114
+ * resolver scoped to the declaring config. Returns `null` instead of throwing;
115
115
  * the compiler reports unresolvable `extends` itself.
116
116
  */
117
117
  function resolveExtendsConfig(tsconfig, specifier) {
@@ -176,7 +176,7 @@ function resolveRealPath(location) {
176
176
  }
177
177
  /**
178
178
  * Parse a JSONC (JSON with Comments) string by stripping comments and trailing
179
- * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped
179
+ * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped;
180
180
  * `JSON.parse` rejects it, and this reader must not lose `paths` for a config
181
181
  * the compiler accepts.
182
182
  */
@@ -10,8 +10,8 @@ import path from 'node:path';
10
10
  * is the whole object from the nearest config in the chain that declares one
11
11
  * (own config first, then `extends` entries in reverse priority order).
12
12
  * Relative targets are anchored at the directory of the config that declares
13
- * them TypeScript-Go resolves inherited relative `paths` against the
14
- * declaring file, not the extending one.
13
+ * them. TypeScript-Go resolves inherited relative `paths` against the declaring
14
+ * file, not the extending one.
15
15
  *
16
16
  * The generated transform tsconfig replaces `paths` wholesale (standard
17
17
  * `extends` semantics), so the alias overlay must re-state these base mappings
@@ -57,7 +57,7 @@ function absolutizePathsTarget(baseDir, target) {
57
57
  /**
58
58
  * Locate the nearest `compilerOptions.paths` declaration in the `extends` chain
59
59
  * rooted at `tsconfig`. The own config wins over its bases; within an `extends`
60
- * array, later entries win over earlier ones. `seen` breaks circular chains
60
+ * array, later entries win over earlier ones. `seen` breaks circular chains;
61
61
  * the compiler reports the actual config error.
62
62
  */
63
63
  function findDeclaredPaths(tsconfig, seen) {
@@ -109,7 +109,7 @@ function extendsSpecifiers(extended) {
109
109
  * Resolve an `extends` specifier to an absolute config path using TypeScript's
110
110
  * rules: absolute paths and relative specifiers get `.json` /
111
111
  * `tsconfig.json`-directory fallbacks; bare specifiers go through Node's module
112
- * resolver scoped to the declaring config. Returns `null` instead of throwing
112
+ * resolver scoped to the declaring config. Returns `null` instead of throwing;
113
113
  * the compiler reports unresolvable `extends` itself.
114
114
  */
115
115
  function resolveExtendsConfig(tsconfig, specifier) {
@@ -174,7 +174,7 @@ function resolveRealPath(location) {
174
174
  }
175
175
  /**
176
176
  * Parse a JSONC (JSON with Comments) string by stripping comments and trailing
177
- * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped
177
+ * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped;
178
178
  * `JSON.parse` rejects it, and this reader must not lose `paths` for a config
179
179
  * the compiler accepts.
180
180
  */
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @ttsc/unplugin bundler-agnostic ttsc plugin adapter.
2
+ * @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
3
3
  *
4
4
  * Re-exports the unified `unplugin` instance that carries named bundler
5
5
  * adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var index = require('./core/index.js');
6
6
 
7
7
  /**
8
- * @ttsc/unplugin bundler-agnostic ttsc plugin adapter.
8
+ * @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
9
9
  *
10
10
  * Re-exports the unified `unplugin` instance that carries named bundler
11
11
  * adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
package/lib/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import unplugin from './core/index.mjs';
2
2
 
3
3
  /**
4
- * @ttsc/unplugin bundler-agnostic ttsc plugin adapter.
4
+ * @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
5
5
  *
6
6
  * Re-exports the unified `unplugin` instance that carries named bundler
7
7
  * adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
@@ -36,7 +36,7 @@ export interface TtscTurbopackLoaderContext {
36
36
  *
37
37
  * Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
38
38
  * loader returns the source unchanged for declaration files, `node_modules`
39
- * paths, and transforms that produce no change mirroring the unplugin
39
+ * paths, and transforms that produce no change, mirroring the unplugin
40
40
  * adapters' `transformInclude` filter, since a broad rule glob routes
41
41
  * everything matching the extension through the loader.
42
42
  */
package/lib/turbopack.js CHANGED
@@ -37,7 +37,7 @@ const transformCache = transform.createTtscTransformCache();
37
37
  *
38
38
  * Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
39
39
  * loader returns the source unchanged for declaration files, `node_modules`
40
- * paths, and transforms that produce no change mirroring the unplugin
40
+ * paths, and transforms that produce no change, mirroring the unplugin
41
41
  * adapters' `transformInclude` filter, since a broad rule glob routes
42
42
  * everything matching the extension through the loader.
43
43
  */
package/lib/turbopack.mjs CHANGED
@@ -33,7 +33,7 @@ const transformCache = createTtscTransformCache();
33
33
  *
34
34
  * Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
35
35
  * loader returns the source unchanged for declaration files, `node_modules`
36
- * paths, and transforms that produce no change mirroring the unplugin
36
+ * paths, and transforms that produce no change, mirroring the unplugin
37
37
  * adapters' `transformInclude` filter, since a broad rule glob routes
38
38
  * everything matching the extension through the loader.
39
39
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/unplugin",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "Bundler adapters for ttsc plugins.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -102,7 +102,7 @@
102
102
  "tslib": "^2.8.1",
103
103
  "typescript": "7.0.1-rc",
104
104
  "vite": "^7.1.12",
105
- "ttsc": "0.16.2"
105
+ "ttsc": "0.16.4"
106
106
  },
107
107
  "repository": {
108
108
  "type": "git",
package/src/core/index.ts CHANGED
@@ -20,7 +20,7 @@ export const sourceFilePattern = /\.[cm]?tsx?$/;
20
20
  /** Matches any path segment that is a `node_modules` directory (cross-platform). */
21
21
  const nodeModulesPattern = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
22
22
  /**
23
- * Matches virtual module ids Rollup/Vite use a leading NUL byte (`\0`) as
23
+ * Matches virtual module ids: Rollup/Vite use a leading NUL byte (`\0`) as
24
24
  * convention.
25
25
  */
26
26
  const virtualModulePattern = /\0/;
@@ -35,8 +35,8 @@ export interface TtscUnpluginOptions {
35
35
  * Fully-resolved plugin options with all defaults applied.
36
36
  *
37
37
  * Produced by {@link resolveOptions}; consumed internally by the transform
38
- * pipeline. Every field is present and normalised callers should not
39
- * construct this type directly.
38
+ * pipeline. Every field is present and normalised; callers should not construct
39
+ * this type directly.
40
40
  */
41
41
  export interface ResolvedTtscUnpluginOptions {
42
42
  /** Compiler-options overlay applied on top of the discovered tsconfig. */
@@ -46,7 +46,7 @@ export interface TtscTransformAlias {
46
46
  * input file. On subsequent transforms the cached entry is validated by
47
47
  * re-hashing the project and comparing against {@link inputHashes}; a mismatch
48
48
  * triggers a full re-transform. Both sides hash the same set of files (the
49
- * project directory walk), so the comparison is meaningful keying the
49
+ * project directory walk), so the comparison is meaningful; keying the
50
50
  * compiler's out-of-walk output paths on only one side is what made the cache
51
51
  * miss on every module.
52
52
  */
@@ -113,7 +113,7 @@ export interface TtscTransformHooks {
113
113
  * @param cache - Optional per-build cache; cleared by the caller on
114
114
  * `buildStart`.
115
115
  * @param hooks - Optional adapter callbacks; see {@link TtscTransformHooks}.
116
- * Dependency notifications fire on cache hits too watch registrations are
116
+ * Dependency notifications fire on cache hits too; watch registrations are
117
117
  * per build, not per compilation.
118
118
  */
119
119
  export async function transformTtsc(
@@ -191,7 +191,7 @@ export async function transformTtsc(
191
191
  * The transform envelope's `dependencies` keys mirror the `typescript` keys
192
192
  * (project-relative); values may be project-relative or absolute. Every path is
193
193
  * absolutized against the project root and deduplicated, and the file itself is
194
- * dropped the bundler already watches the module it transforms.
194
+ * dropped; the bundler already watches the module it transforms.
195
195
  */
196
196
  function notifyFileDependencies(
197
197
  hooks: TtscTransformHooks | undefined,
@@ -311,9 +311,9 @@ export function createTransformResult(
311
311
  *
312
312
  * Re-hashes every file under the project root and overlays the current module's
313
313
  * in-memory source, then compares the snapshot against the one captured when
314
- * the result was produced. Any input under the project root changing the
315
- * module itself or a sibling the plugin reads invalidates the entry and
316
- * forces a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
314
+ * the result was produced. Any input under the project root changing (the
315
+ * module itself or a sibling the plugin reads) invalidates the entry and forces
316
+ * a re-transform. Out-of-walk inputs a plugin pulls in (`node_modules`
317
317
  * declarations, sibling-package sources) are not seen here; adapters invalidate
318
318
  * on those through the reported `dependencies` → `addWatchFile` → the bundler's
319
319
  * next `buildStart` cache clear.
@@ -323,8 +323,8 @@ export function createTransformResult(
323
323
  * the key universe. The earlier implementation overlaid the compiler's output
324
324
  * keys here on only one side; those keys include out-of-walk program inputs
325
325
  * (`node_modules` declarations, sibling-package sources), so the snapshots
326
- * never matched and the cache missed on every module re-transforming the
327
- * whole project once per file on any project that imports a typed dependency.
326
+ * never matched and the cache missed on every module; re-transforming the whole
327
+ * project once per file on any project that imports a typed dependency.
328
328
  */
329
329
  function matchesCachedSource(
330
330
  cached: TtscCachedProjectTransform,
@@ -340,8 +340,8 @@ function matchesCachedSource(
340
340
  /**
341
341
  * Build the input-hash snapshot stored alongside a fresh compiler result.
342
342
  *
343
- * Hashes every file under the project directory the exact universe
344
- * {@link matchesCachedSource} re-hashes to validate then overlays the
343
+ * Hashes every file under the project directory (the exact universe
344
+ * {@link matchesCachedSource} re-hashes to validate), then overlays the
345
345
  * in-memory source for the module that triggered the compile so unsaved editor
346
346
  * content is captured correctly.
347
347
  *
@@ -593,7 +593,7 @@ function normalizePluginConfigForGeneratedTsconfig(
593
593
  * project's own `paths` wholesale. The overlay therefore re-states the
594
594
  * project's effective mappings first, so tsconfig-only aliases keep resolving;
595
595
  * inline `compilerOptions.paths` from the plugin options ride on top, and the
596
- * bundler aliases win last they mirror what the bundler will actually do at
596
+ * bundler aliases win last; they mirror what the bundler will actually do at
597
597
  * resolve time.
598
598
  *
599
599
  * No `baseUrl` is emitted: TypeScript-Go removed the option (TS5102), and all
@@ -838,7 +838,7 @@ function formatUnknownError(error: unknown): string {
838
838
  * If `tsconfig` is supplied it is returned as-is (absolute) or resolved from
839
839
  * `process.cwd()` (relative). Otherwise the function walks ancestor directories
840
840
  * starting at `file`'s directory, returning the first `tsconfig.json` found.
841
- * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one the
841
+ * Falls back to `<cwd>/tsconfig.json` when no ancestor contains one; the
842
842
  * compiler will error if that file does not exist, which is the correct
843
843
  * behavior for a mis-configured project.
844
844
  */
@@ -856,7 +856,7 @@ function resolveTsconfig(file: string, tsconfig?: string): string {
856
856
  return candidate;
857
857
  }
858
858
  const parent = path.dirname(current);
859
- // Reached filesystem root stop walking.
859
+ // Reached filesystem root, stop walking.
860
860
  if (parent === current) {
861
861
  break;
862
862
  }
@@ -10,8 +10,8 @@ import path from "node:path";
10
10
  * is the whole object from the nearest config in the chain that declares one
11
11
  * (own config first, then `extends` entries in reverse priority order).
12
12
  * Relative targets are anchored at the directory of the config that declares
13
- * them TypeScript-Go resolves inherited relative `paths` against the
14
- * declaring file, not the extending one.
13
+ * them. TypeScript-Go resolves inherited relative `paths` against the declaring
14
+ * file, not the extending one.
15
15
  *
16
16
  * The generated transform tsconfig replaces `paths` wholesale (standard
17
17
  * `extends` semantics), so the alias overlay must re-state these base mappings
@@ -71,7 +71,7 @@ interface IDeclaredPaths {
71
71
  /**
72
72
  * Locate the nearest `compilerOptions.paths` declaration in the `extends` chain
73
73
  * rooted at `tsconfig`. The own config wins over its bases; within an `extends`
74
- * array, later entries win over earlier ones. `seen` breaks circular chains
74
+ * array, later entries win over earlier ones. `seen` breaks circular chains;
75
75
  * the compiler reports the actual config error.
76
76
  */
77
77
  function findDeclaredPaths(
@@ -132,7 +132,7 @@ function extendsSpecifiers(extended: unknown): string[] {
132
132
  * Resolve an `extends` specifier to an absolute config path using TypeScript's
133
133
  * rules: absolute paths and relative specifiers get `.json` /
134
134
  * `tsconfig.json`-directory fallbacks; bare specifiers go through Node's module
135
- * resolver scoped to the declaring config. Returns `null` instead of throwing
135
+ * resolver scoped to the declaring config. Returns `null` instead of throwing;
136
136
  * the compiler reports unresolvable `extends` itself.
137
137
  */
138
138
  function resolveExtendsConfig(
@@ -205,7 +205,7 @@ function resolveRealPath(location: string): string {
205
205
 
206
206
  /**
207
207
  * Parse a JSONC (JSON with Comments) string by stripping comments and trailing
208
- * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped
208
+ * commas before handing off to `JSON.parse`. A leading UTF-8 BOM is dropped;
209
209
  * `JSON.parse` rejects it, and this reader must not lose `paths` for a config
210
210
  * the compiler accepts.
211
211
  */
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @ttsc/unplugin bundler-agnostic ttsc plugin adapter.
2
+ * @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
3
3
  *
4
4
  * Re-exports the unified `unplugin` instance that carries named bundler
5
5
  * adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
package/src/turbopack.ts CHANGED
@@ -57,7 +57,7 @@ const transformCache = createTtscTransformCache();
57
57
  *
58
58
  * Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
59
59
  * loader returns the source unchanged for declaration files, `node_modules`
60
- * paths, and transforms that produce no change mirroring the unplugin
60
+ * paths, and transforms that produce no change, mirroring the unplugin
61
61
  * adapters' `transformInclude` filter, since a broad rule glob routes
62
62
  * everything matching the extension through the loader.
63
63
  */