@ttsc/unplugin 0.28.1 → 0.28.3
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 +3 -1
- package/lib/api.d.cts +8 -0
- package/lib/api.d.mts +8 -0
- package/lib/bun-register.d.cts +25 -0
- package/lib/bun-register.d.mts +25 -0
- package/lib/bun.d.cts +95 -0
- package/lib/bun.d.mts +95 -0
- package/lib/core/index.d.cts +23 -0
- package/lib/core/index.d.mts +23 -0
- package/lib/core/index.js +18 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +19 -2
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/options.d.cts +54 -0
- package/lib/core/options.d.mts +54 -0
- package/lib/core/transform.d.cts +433 -0
- package/lib/core/transform.d.mts +433 -0
- package/lib/core/transform.d.ts +23 -4
- package/lib/core/transform.js +715 -117
- package/lib/core/transform.js.map +1 -1
- package/lib/core/transform.mjs +715 -117
- package/lib/core/transform.mjs.map +1 -1
- package/lib/core/tsconfigPaths.d.cts +29 -0
- package/lib/core/tsconfigPaths.d.mts +29 -0
- package/lib/core/viteServe.d.cts +81 -0
- package/lib/core/viteServe.d.mts +81 -0
- package/lib/esbuild.d.cts +3 -0
- package/lib/esbuild.d.mts +3 -0
- package/lib/farm.d.cts +3 -0
- package/lib/farm.d.mts +3 -0
- package/lib/index.d.cts +12 -0
- package/lib/index.d.mts +12 -0
- package/lib/next.d.cts +37 -0
- package/lib/next.d.mts +37 -0
- package/lib/rolldown.d.cts +3 -0
- package/lib/rolldown.d.mts +3 -0
- package/lib/rollup.d.cts +3 -0
- package/lib/rollup.d.mts +3 -0
- package/lib/rspack.d.cts +3 -0
- package/lib/rspack.d.mts +3 -0
- package/lib/turbopack.d.cts +58 -0
- package/lib/turbopack.d.mts +58 -0
- package/lib/vite.d.cts +3 -0
- package/lib/vite.d.mts +3 -0
- package/lib/webpack.d.cts +3 -0
- package/lib/webpack.d.mts +3 -0
- package/package.json +122 -17
- package/src/core/index.ts +18 -1
- package/src/core/transform.ts +1014 -139
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** One module node inside a Vite module graph; opaque to this module. */
|
|
2
|
+
type ViteModuleNodeLike = object;
|
|
3
|
+
/**
|
|
4
|
+
* The module-graph surface this module touches, shared by Vite's mixed module
|
|
5
|
+
* graph and the per-environment graphs of the environment API.
|
|
6
|
+
*/
|
|
7
|
+
interface ViteModuleGraphLike {
|
|
8
|
+
fileToModulesMap?: Map<string, Set<ViteModuleNodeLike>>;
|
|
9
|
+
getModulesByFile?(file: string): Set<ViteModuleNodeLike> | undefined;
|
|
10
|
+
invalidateModule?(node: ViteModuleNodeLike): void;
|
|
11
|
+
}
|
|
12
|
+
/** A channel that can deliver a full-reload event to connected clients. */
|
|
13
|
+
interface ViteHotChannelLike {
|
|
14
|
+
send?(payload: {
|
|
15
|
+
path?: string;
|
|
16
|
+
type: "full-reload";
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
19
|
+
/** One dev-server environment (client, ssr, or a custom one). */
|
|
20
|
+
interface ViteEnvironmentLike {
|
|
21
|
+
hot?: ViteHotChannelLike;
|
|
22
|
+
moduleGraph?: ViteModuleGraphLike;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Minimal structural view of the Vite dev server. Declared locally instead of
|
|
26
|
+
* importing `vite` so the published type declarations never require Vite to be
|
|
27
|
+
* installed, and so one shape spans the mixed module graph (Vite 5), the
|
|
28
|
+
* environment API (Vite 6+), and whichever of `ws`/`hot` a major still
|
|
29
|
+
* carries.
|
|
30
|
+
*/
|
|
31
|
+
export interface ViteDevServerLike {
|
|
32
|
+
environments?: Record<string, ViteEnvironmentLike>;
|
|
33
|
+
hot?: ViteHotChannelLike;
|
|
34
|
+
moduleGraph?: ViteModuleGraphLike;
|
|
35
|
+
ws?: ViteHotChannelLike;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Filesystem watch for derived watch inputs that do not exist while a Vite dev
|
|
39
|
+
* server is running.
|
|
40
|
+
*
|
|
41
|
+
* Vite serve treats every transform-context `addWatchFile()` registration as an
|
|
42
|
+
* added import: `TransformPluginContext.addWatchFile` stores the path in
|
|
43
|
+
* `_addedImports`, and `vite:import-analysis` resolves each entry like a real
|
|
44
|
+
* import of the transformed module. A missing path — a superseding resolution
|
|
45
|
+
* candidate or a plugin-reported dependency that is not generated yet — then
|
|
46
|
+
* fails that resolve and turns the importer's first request into a 500, even
|
|
47
|
+
* though the transform itself succeeded.
|
|
48
|
+
*
|
|
49
|
+
* This registry is the serve-only replacement for those registrations. Each
|
|
50
|
+
* missing path is stat-polled; when it is created, every importer that
|
|
51
|
+
* registered it is invalidated in the server's module graphs and one
|
|
52
|
+
* full-reload is sent, so the next request retransforms the importer against
|
|
53
|
+
* the new resolution winner. The project transform cache re-validates through
|
|
54
|
+
* its external-input hashes (a recorded `missing` marker differs from a content
|
|
55
|
+
* hash), so the retransform recompiles instead of replaying.
|
|
56
|
+
*/
|
|
57
|
+
export interface ViteServeMissingInputWatch {
|
|
58
|
+
/** Adopt the dev server whose module graphs creation events invalidate. */
|
|
59
|
+
attach(server: ViteDevServerLike): void;
|
|
60
|
+
/** Stop every poll; safe to call repeatedly. */
|
|
61
|
+
dispose(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Report whether a dev server has ever been attached. This is not a liveness
|
|
64
|
+
* predicate — the reference intentionally survives the server's close (see
|
|
65
|
+
* {@link dispose}) — so route decisions must also gate on the resolved
|
|
66
|
+
* config's `command`, as the adapter does.
|
|
67
|
+
*/
|
|
68
|
+
serving(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Register one missing watch input derived for `importer`.
|
|
71
|
+
*
|
|
72
|
+
* `identity` is the filesystem identity the transform generation already
|
|
73
|
+
* resolved for `input`. Resolving it here instead costs a `realpath` and a
|
|
74
|
+
* case-sensitivity directory listing per input per delivery, because a
|
|
75
|
+
* per-call identity context memoizes nothing (samchon/ttsc#1246).
|
|
76
|
+
*/
|
|
77
|
+
watch(input: string, importer: string, identity?: string): void;
|
|
78
|
+
}
|
|
79
|
+
/** Create an empty missing-input watch for one plugin instance. */
|
|
80
|
+
export declare function createViteServeMissingInputWatch(): ViteServeMissingInputWatch;
|
|
81
|
+
export {};
|
package/lib/farm.d.cts
ADDED
package/lib/farm.d.mts
ADDED
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the unified `unplugin` instance that carries named bundler
|
|
5
|
+
* adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
|
|
6
|
+
* `.farm`) as well as the raw factory for custom integrations. Per-bundler
|
|
7
|
+
* entry points (`@ttsc/unplugin/vite`, `/webpack`, …) each re-export the
|
|
8
|
+
* matching adapter directly to keep bundler-specific builds lean.
|
|
9
|
+
*/
|
|
10
|
+
import unplugin from "./core/index.cjs";
|
|
11
|
+
export type { TtscUnpluginOptions } from "./core/options.cjs";
|
|
12
|
+
export default unplugin;
|
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ttsc/unplugin: bundler-agnostic ttsc plugin adapter.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the unified `unplugin` instance that carries named bundler
|
|
5
|
+
* adapters (`.vite`, `.rollup`, `.rolldown`, `.webpack`, `.rspack`, `.esbuild`,
|
|
6
|
+
* `.farm`) as well as the raw factory for custom integrations. Per-bundler
|
|
7
|
+
* entry points (`@ttsc/unplugin/vite`, `/webpack`, …) each re-export the
|
|
8
|
+
* matching adapter directly to keep bundler-specific builds lean.
|
|
9
|
+
*/
|
|
10
|
+
import unplugin from "./core/index.mjs";
|
|
11
|
+
export type { TtscUnpluginOptions } from "./core/options.mjs";
|
|
12
|
+
export default unplugin;
|
package/lib/next.d.cts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TtscUnpluginOptions } from "./core/options.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal structural type for a Next.js configuration object.
|
|
4
|
+
*
|
|
5
|
+
* Only the `webpack` field is used by this adapter; all other Next.js options
|
|
6
|
+
* are forwarded as-is through the spread operator.
|
|
7
|
+
*/
|
|
8
|
+
export type NextLikeConfig = Record<string, unknown> & {
|
|
9
|
+
/**
|
|
10
|
+
* Optional existing webpack customisation hook. When the caller has already
|
|
11
|
+
* defined one, `next()` will chain through to it after injecting the ttsc
|
|
12
|
+
* webpack plugin.
|
|
13
|
+
*/
|
|
14
|
+
webpack?: (config: WebpackLikeConfig, options: unknown) => WebpackLikeConfig;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Minimal structural type for a webpack configuration object as seen by the
|
|
18
|
+
* Next.js `webpack` hook callback.
|
|
19
|
+
*/
|
|
20
|
+
export type WebpackLikeConfig = Record<string, unknown> & {
|
|
21
|
+
/** The webpack plugin array; initialised to `[]` by this adapter if absent. */
|
|
22
|
+
plugins?: unknown[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Wrap a Next.js config object so that the ttsc webpack plugin is injected into
|
|
26
|
+
* every webpack build Next.js performs.
|
|
27
|
+
*
|
|
28
|
+
* The adapter uses `unshift` to ensure the ttsc plugin runs before any other
|
|
29
|
+
* plugins in the array (unplugin `enforce: "pre"` semantics). An existing
|
|
30
|
+
* `nextConfig.webpack` hook is preserved and called after the plugin is
|
|
31
|
+
* injected.
|
|
32
|
+
*
|
|
33
|
+
* @param nextConfig - The caller's existing Next.js config (spread into the
|
|
34
|
+
* returned object unchanged, except for `webpack`).
|
|
35
|
+
* @param options - Ttsc plugin options forwarded to the webpack adapter.
|
|
36
|
+
*/
|
|
37
|
+
export default function next(nextConfig?: NextLikeConfig, options?: TtscUnpluginOptions): NextLikeConfig;
|
package/lib/next.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TtscUnpluginOptions } from "./core/options.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal structural type for a Next.js configuration object.
|
|
4
|
+
*
|
|
5
|
+
* Only the `webpack` field is used by this adapter; all other Next.js options
|
|
6
|
+
* are forwarded as-is through the spread operator.
|
|
7
|
+
*/
|
|
8
|
+
export type NextLikeConfig = Record<string, unknown> & {
|
|
9
|
+
/**
|
|
10
|
+
* Optional existing webpack customisation hook. When the caller has already
|
|
11
|
+
* defined one, `next()` will chain through to it after injecting the ttsc
|
|
12
|
+
* webpack plugin.
|
|
13
|
+
*/
|
|
14
|
+
webpack?: (config: WebpackLikeConfig, options: unknown) => WebpackLikeConfig;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Minimal structural type for a webpack configuration object as seen by the
|
|
18
|
+
* Next.js `webpack` hook callback.
|
|
19
|
+
*/
|
|
20
|
+
export type WebpackLikeConfig = Record<string, unknown> & {
|
|
21
|
+
/** The webpack plugin array; initialised to `[]` by this adapter if absent. */
|
|
22
|
+
plugins?: unknown[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Wrap a Next.js config object so that the ttsc webpack plugin is injected into
|
|
26
|
+
* every webpack build Next.js performs.
|
|
27
|
+
*
|
|
28
|
+
* The adapter uses `unshift` to ensure the ttsc plugin runs before any other
|
|
29
|
+
* plugins in the array (unplugin `enforce: "pre"` semantics). An existing
|
|
30
|
+
* `nextConfig.webpack` hook is preserved and called after the plugin is
|
|
31
|
+
* injected.
|
|
32
|
+
*
|
|
33
|
+
* @param nextConfig - The caller's existing Next.js config (spread into the
|
|
34
|
+
* returned object unchanged, except for `webpack`).
|
|
35
|
+
* @param options - Ttsc plugin options forwarded to the webpack adapter.
|
|
36
|
+
*/
|
|
37
|
+
export default function next(nextConfig?: NextLikeConfig, options?: TtscUnpluginOptions): NextLikeConfig;
|
package/lib/rollup.d.cts
ADDED
package/lib/rollup.d.mts
ADDED
package/lib/rspack.d.cts
ADDED
package/lib/rspack.d.mts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TtscUnpluginOptions } from "./core/options.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Subset of the webpack loader context Turbopack provides to loaders wired
|
|
4
|
+
* through `turbopack.rules`. Turbopack has no JS plugin API, but it runs
|
|
5
|
+
* webpack-compatible loaders: source string in, source string out, with
|
|
6
|
+
* `async()` for asynchronous completion and `getOptions()` for the rule's
|
|
7
|
+
* `options` object.
|
|
8
|
+
*/
|
|
9
|
+
export interface TtscTurbopackLoaderContext {
|
|
10
|
+
/** Marks the loader asynchronous and returns the completion callback. */
|
|
11
|
+
async(): (error?: unknown, content?: string) => void;
|
|
12
|
+
/** Absolute path of the module being loaded. */
|
|
13
|
+
resourcePath: string;
|
|
14
|
+
/** The rule's `options` object, when one was configured. */
|
|
15
|
+
getOptions?(): TtscUnpluginOptions | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Register an additional file the transformed module depends on. Part of the
|
|
18
|
+
* webpack loader context contract Turbopack implements; a registered file
|
|
19
|
+
* enters Turbopack's `fileDependencies` set so editing it re-runs this loader
|
|
20
|
+
* for the owning module. Optional so a minimal stub context (or a Turbopack
|
|
21
|
+
* build that predates the method) still loads.
|
|
22
|
+
*/
|
|
23
|
+
addDependency?(file: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Toggle result cacheability. Part of the webpack loader context contract;
|
|
26
|
+
* called with `false` when the ttsc plugin declared the module volatile
|
|
27
|
+
* (output depends on non-file inputs), so the bundler never replays a cached
|
|
28
|
+
* result for it. Optional so a minimal stub context still loads.
|
|
29
|
+
*/
|
|
30
|
+
cacheable?(flag: boolean): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Standalone webpack-loader entrypoint for Turbopack.
|
|
34
|
+
*
|
|
35
|
+
* Turbopack cannot load unplugin-based plugins (no JS plugin API), but its
|
|
36
|
+
* `turbopack.rules` accept webpack loaders, and a ttsc transform is exactly
|
|
37
|
+
* loader-shaped: pure TypeScript source in, transformed source out. Wire it per
|
|
38
|
+
* extension:
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* // next.config.mjs
|
|
42
|
+
* const nextConfig = {
|
|
43
|
+
* turbopack: {
|
|
44
|
+
* rules: {
|
|
45
|
+
* "*.ts": { loaders: ["@ttsc/unplugin/turbopack"] },
|
|
46
|
+
* "*.tsx": { loaders: ["@ttsc/unplugin/turbopack"] },
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* };
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
|
|
53
|
+
* loader returns the source unchanged for declaration files, `node_modules`
|
|
54
|
+
* paths, and transforms that produce no change, mirroring the unplugin
|
|
55
|
+
* adapters' `transformInclude` filter, since a broad rule glob routes
|
|
56
|
+
* everything matching the extension through the loader.
|
|
57
|
+
*/
|
|
58
|
+
export default function turbopack(this: TtscTurbopackLoaderContext, source: string): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TtscUnpluginOptions } from "./core/options.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Subset of the webpack loader context Turbopack provides to loaders wired
|
|
4
|
+
* through `turbopack.rules`. Turbopack has no JS plugin API, but it runs
|
|
5
|
+
* webpack-compatible loaders: source string in, source string out, with
|
|
6
|
+
* `async()` for asynchronous completion and `getOptions()` for the rule's
|
|
7
|
+
* `options` object.
|
|
8
|
+
*/
|
|
9
|
+
export interface TtscTurbopackLoaderContext {
|
|
10
|
+
/** Marks the loader asynchronous and returns the completion callback. */
|
|
11
|
+
async(): (error?: unknown, content?: string) => void;
|
|
12
|
+
/** Absolute path of the module being loaded. */
|
|
13
|
+
resourcePath: string;
|
|
14
|
+
/** The rule's `options` object, when one was configured. */
|
|
15
|
+
getOptions?(): TtscUnpluginOptions | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Register an additional file the transformed module depends on. Part of the
|
|
18
|
+
* webpack loader context contract Turbopack implements; a registered file
|
|
19
|
+
* enters Turbopack's `fileDependencies` set so editing it re-runs this loader
|
|
20
|
+
* for the owning module. Optional so a minimal stub context (or a Turbopack
|
|
21
|
+
* build that predates the method) still loads.
|
|
22
|
+
*/
|
|
23
|
+
addDependency?(file: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Toggle result cacheability. Part of the webpack loader context contract;
|
|
26
|
+
* called with `false` when the ttsc plugin declared the module volatile
|
|
27
|
+
* (output depends on non-file inputs), so the bundler never replays a cached
|
|
28
|
+
* result for it. Optional so a minimal stub context still loads.
|
|
29
|
+
*/
|
|
30
|
+
cacheable?(flag: boolean): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Standalone webpack-loader entrypoint for Turbopack.
|
|
34
|
+
*
|
|
35
|
+
* Turbopack cannot load unplugin-based plugins (no JS plugin API), but its
|
|
36
|
+
* `turbopack.rules` accept webpack loaders, and a ttsc transform is exactly
|
|
37
|
+
* loader-shaped: pure TypeScript source in, transformed source out. Wire it per
|
|
38
|
+
* extension:
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* // next.config.mjs
|
|
42
|
+
* const nextConfig = {
|
|
43
|
+
* turbopack: {
|
|
44
|
+
* rules: {
|
|
45
|
+
* "*.ts": { loaders: ["@ttsc/unplugin/turbopack"] },
|
|
46
|
+
* "*.tsx": { loaders: ["@ttsc/unplugin/turbopack"] },
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* };
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Pass {@link TtscUnpluginOptions} through the rule's `options` object. The
|
|
53
|
+
* loader returns the source unchanged for declaration files, `node_modules`
|
|
54
|
+
* paths, and transforms that produce no change, mirroring the unplugin
|
|
55
|
+
* adapters' `transformInclude` filter, since a broad rule glob routes
|
|
56
|
+
* everything matching the extension through the loader.
|
|
57
|
+
*/
|
|
58
|
+
export default function turbopack(this: TtscTurbopackLoaderContext, source: string): void;
|
package/lib/vite.d.cts
ADDED
package/lib/vite.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,74 +1,178 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/unplugin",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.3",
|
|
4
4
|
"description": "Bundler adapters for ttsc plugins.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"lib/*": [
|
|
11
|
+
"lib/*"
|
|
12
|
+
],
|
|
13
|
+
"package.json": [
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"*": [
|
|
17
|
+
"lib/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
8
21
|
"exports": {
|
|
9
22
|
".": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./lib/index.d.mts",
|
|
25
|
+
"default": "./lib/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./lib/index.d.cts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
30
|
+
},
|
|
10
31
|
"types": "./lib/index.d.ts",
|
|
11
|
-
"import": "./lib/index.mjs",
|
|
12
32
|
"default": "./lib/index.js"
|
|
13
33
|
},
|
|
14
34
|
"./api": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./lib/api.d.mts",
|
|
37
|
+
"default": "./lib/api.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/api.d.cts",
|
|
41
|
+
"default": "./lib/api.js"
|
|
42
|
+
},
|
|
15
43
|
"types": "./lib/api.d.ts",
|
|
16
|
-
"import": "./lib/api.mjs",
|
|
17
44
|
"default": "./lib/api.js"
|
|
18
45
|
},
|
|
19
46
|
"./bun": {
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./lib/bun.d.mts",
|
|
49
|
+
"default": "./lib/bun.mjs"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./lib/bun.d.cts",
|
|
53
|
+
"default": "./lib/bun.js"
|
|
54
|
+
},
|
|
20
55
|
"types": "./lib/bun.d.ts",
|
|
21
|
-
"import": "./lib/bun.mjs",
|
|
22
56
|
"default": "./lib/bun.js"
|
|
23
57
|
},
|
|
24
58
|
"./bun-register": {
|
|
59
|
+
"import": {
|
|
60
|
+
"types": "./lib/bun-register.d.mts",
|
|
61
|
+
"default": "./lib/bun-register.mjs"
|
|
62
|
+
},
|
|
63
|
+
"require": {
|
|
64
|
+
"types": "./lib/bun-register.d.cts",
|
|
65
|
+
"default": "./lib/bun-register.js"
|
|
66
|
+
},
|
|
25
67
|
"types": "./lib/bun-register.d.ts",
|
|
26
|
-
"import": "./lib/bun-register.mjs",
|
|
27
68
|
"default": "./lib/bun-register.js"
|
|
28
69
|
},
|
|
29
70
|
"./esbuild": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./lib/esbuild.d.mts",
|
|
73
|
+
"default": "./lib/esbuild.mjs"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./lib/esbuild.d.cts",
|
|
77
|
+
"default": "./lib/esbuild.js"
|
|
78
|
+
},
|
|
30
79
|
"types": "./lib/esbuild.d.ts",
|
|
31
|
-
"import": "./lib/esbuild.mjs",
|
|
32
80
|
"default": "./lib/esbuild.js"
|
|
33
81
|
},
|
|
34
82
|
"./farm": {
|
|
83
|
+
"import": {
|
|
84
|
+
"types": "./lib/farm.d.mts",
|
|
85
|
+
"default": "./lib/farm.mjs"
|
|
86
|
+
},
|
|
87
|
+
"require": {
|
|
88
|
+
"types": "./lib/farm.d.cts",
|
|
89
|
+
"default": "./lib/farm.js"
|
|
90
|
+
},
|
|
35
91
|
"types": "./lib/farm.d.ts",
|
|
36
|
-
"import": "./lib/farm.mjs",
|
|
37
92
|
"default": "./lib/farm.js"
|
|
38
93
|
},
|
|
39
94
|
"./next": {
|
|
95
|
+
"import": {
|
|
96
|
+
"types": "./lib/next.d.mts",
|
|
97
|
+
"default": "./lib/next.mjs"
|
|
98
|
+
},
|
|
99
|
+
"require": {
|
|
100
|
+
"types": "./lib/next.d.cts",
|
|
101
|
+
"default": "./lib/next.js"
|
|
102
|
+
},
|
|
40
103
|
"types": "./lib/next.d.ts",
|
|
41
|
-
"import": "./lib/next.mjs",
|
|
42
104
|
"default": "./lib/next.js"
|
|
43
105
|
},
|
|
44
106
|
"./rolldown": {
|
|
107
|
+
"import": {
|
|
108
|
+
"types": "./lib/rolldown.d.mts",
|
|
109
|
+
"default": "./lib/rolldown.mjs"
|
|
110
|
+
},
|
|
111
|
+
"require": {
|
|
112
|
+
"types": "./lib/rolldown.d.cts",
|
|
113
|
+
"default": "./lib/rolldown.js"
|
|
114
|
+
},
|
|
45
115
|
"types": "./lib/rolldown.d.ts",
|
|
46
|
-
"import": "./lib/rolldown.mjs",
|
|
47
116
|
"default": "./lib/rolldown.js"
|
|
48
117
|
},
|
|
49
118
|
"./rollup": {
|
|
119
|
+
"import": {
|
|
120
|
+
"types": "./lib/rollup.d.mts",
|
|
121
|
+
"default": "./lib/rollup.mjs"
|
|
122
|
+
},
|
|
123
|
+
"require": {
|
|
124
|
+
"types": "./lib/rollup.d.cts",
|
|
125
|
+
"default": "./lib/rollup.js"
|
|
126
|
+
},
|
|
50
127
|
"types": "./lib/rollup.d.ts",
|
|
51
|
-
"import": "./lib/rollup.mjs",
|
|
52
128
|
"default": "./lib/rollup.js"
|
|
53
129
|
},
|
|
54
130
|
"./rspack": {
|
|
131
|
+
"import": {
|
|
132
|
+
"types": "./lib/rspack.d.mts",
|
|
133
|
+
"default": "./lib/rspack.mjs"
|
|
134
|
+
},
|
|
135
|
+
"require": {
|
|
136
|
+
"types": "./lib/rspack.d.cts",
|
|
137
|
+
"default": "./lib/rspack.js"
|
|
138
|
+
},
|
|
55
139
|
"types": "./lib/rspack.d.ts",
|
|
56
|
-
"import": "./lib/rspack.mjs",
|
|
57
140
|
"default": "./lib/rspack.js"
|
|
58
141
|
},
|
|
59
142
|
"./turbopack": {
|
|
143
|
+
"import": {
|
|
144
|
+
"types": "./lib/turbopack.d.mts",
|
|
145
|
+
"default": "./lib/turbopack.mjs"
|
|
146
|
+
},
|
|
147
|
+
"require": {
|
|
148
|
+
"types": "./lib/turbopack.d.cts",
|
|
149
|
+
"default": "./lib/turbopack.js"
|
|
150
|
+
},
|
|
60
151
|
"types": "./lib/turbopack.d.ts",
|
|
61
|
-
"import": "./lib/turbopack.mjs",
|
|
62
152
|
"default": "./lib/turbopack.js"
|
|
63
153
|
},
|
|
64
154
|
"./vite": {
|
|
155
|
+
"import": {
|
|
156
|
+
"types": "./lib/vite.d.mts",
|
|
157
|
+
"default": "./lib/vite.mjs"
|
|
158
|
+
},
|
|
159
|
+
"require": {
|
|
160
|
+
"types": "./lib/vite.d.cts",
|
|
161
|
+
"default": "./lib/vite.js"
|
|
162
|
+
},
|
|
65
163
|
"types": "./lib/vite.d.ts",
|
|
66
|
-
"import": "./lib/vite.mjs",
|
|
67
164
|
"default": "./lib/vite.js"
|
|
68
165
|
},
|
|
69
166
|
"./webpack": {
|
|
167
|
+
"import": {
|
|
168
|
+
"types": "./lib/webpack.d.mts",
|
|
169
|
+
"default": "./lib/webpack.mjs"
|
|
170
|
+
},
|
|
171
|
+
"require": {
|
|
172
|
+
"types": "./lib/webpack.d.cts",
|
|
173
|
+
"default": "./lib/webpack.js"
|
|
174
|
+
},
|
|
70
175
|
"types": "./lib/webpack.d.ts",
|
|
71
|
-
"import": "./lib/webpack.mjs",
|
|
72
176
|
"default": "./lib/webpack.js"
|
|
73
177
|
},
|
|
74
178
|
"./package.json": "./package.json"
|
|
@@ -95,7 +199,7 @@
|
|
|
95
199
|
"unplugin": "^2.3.11"
|
|
96
200
|
},
|
|
97
201
|
"peerDependencies": {
|
|
98
|
-
"ttsc": "^0.28.
|
|
202
|
+
"ttsc": "^0.28.3"
|
|
99
203
|
},
|
|
100
204
|
"devDependencies": {
|
|
101
205
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
@@ -105,10 +209,11 @@
|
|
|
105
209
|
"rimraf": "^6.1.2",
|
|
106
210
|
"rollup": "^4.60.3",
|
|
107
211
|
"tinyglobby": "^0.2.16",
|
|
212
|
+
"ts-legacy": "npm:typescript@~6.0.3",
|
|
108
213
|
"tslib": "^2.8.1",
|
|
109
214
|
"typescript": "^7.0.2",
|
|
110
215
|
"vite": "^7.3.5",
|
|
111
|
-
"ttsc": "0.28.
|
|
216
|
+
"ttsc": "0.28.3"
|
|
112
217
|
},
|
|
113
218
|
"repository": {
|
|
114
219
|
"type": "git",
|
|
@@ -122,6 +227,6 @@
|
|
|
122
227
|
"homepage": "https://ttsc.dev",
|
|
123
228
|
"sideEffects": false,
|
|
124
229
|
"scripts": {
|
|
125
|
-
"build": "rimraf lib && tsc --emitDeclarationOnly && rollup -c"
|
|
230
|
+
"build": "rimraf lib && tsc --emitDeclarationOnly && node scripts/emit-dual-declarations.mjs && rollup -c"
|
|
126
231
|
}
|
|
127
232
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -55,6 +55,12 @@ const unpluginFactory: UnpluginFactory<
|
|
|
55
55
|
let aliases: unknown;
|
|
56
56
|
let viteCommand: string | undefined;
|
|
57
57
|
let viteWatching = true;
|
|
58
|
+
// A restart can start the replacement plugin container before closing the
|
|
59
|
+
// old one, and Vite calls buildEnd even for a container that never started.
|
|
60
|
+
// Track the stable per-container PluginContext identity so that unstarted
|
|
61
|
+
// old containers cannot dispose a replacement's freshly initialized cache.
|
|
62
|
+
const viteBuildOwners = new WeakSet<object>();
|
|
63
|
+
let viteBuildLifecycles = 0;
|
|
58
64
|
|
|
59
65
|
return {
|
|
60
66
|
name,
|
|
@@ -89,13 +95,24 @@ const unpluginFactory: UnpluginFactory<
|
|
|
89
95
|
missingInputs.attach(server);
|
|
90
96
|
},
|
|
91
97
|
// Vite calls buildEnd when the dev server (or build) closes; drop every
|
|
92
|
-
// poller
|
|
98
|
+
// poller and, once the last overlapping container has closed, every
|
|
99
|
+
// generation-owned filesystem tracker as well.
|
|
93
100
|
buildEnd() {
|
|
94
101
|
missingInputs.dispose();
|
|
102
|
+
if (viteBuildOwners.delete(this)) {
|
|
103
|
+
viteBuildLifecycles -= 1;
|
|
104
|
+
}
|
|
105
|
+
if (viteBuildLifecycles === 0) {
|
|
106
|
+
resetTtscTransformCache(transformCache);
|
|
107
|
+
}
|
|
95
108
|
},
|
|
96
109
|
},
|
|
97
110
|
|
|
98
111
|
buildStart() {
|
|
112
|
+
if (viteCommand !== undefined && !viteBuildOwners.has(this as object)) {
|
|
113
|
+
viteBuildOwners.add(this as object);
|
|
114
|
+
viteBuildLifecycles += 1;
|
|
115
|
+
}
|
|
99
116
|
// Persistent validation exists for a session that spans edits it can
|
|
100
117
|
// observe, and a dev server told to open no watcher is not one:
|
|
101
118
|
// `server.watch: null` leaves Vite with no change channel at all, so no
|