@teacss/bun 0.4.7 → 0.5.1

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
@@ -1,26 +1,12 @@
1
1
  # @teacss/bun
2
2
 
3
- **Bun build plugin for TeaCSS.**
4
-
5
- ## Purpose
6
-
7
- The plugin emits `virtual:teacss.css`, resolves CSS-entry configuration, and
8
- transforms TeaCSS CSS directives.
9
-
10
- Use this package when an application or build tool runs through `Bun.build`,
11
- including programmatic watch builds. It owns Bun's plugin and watcher
12
- lifecycles; use `@teacss/cli` for standalone CSS output, or the matching
13
- framework integration when another build system owns the module graph.
14
-
15
- Install the owning Bun adapter beside the `teacss` runtime:
3
+ Bun Build integration for TeaCSS.
16
4
 
17
5
  ```sh
18
6
  bun add teacss
19
- bun add -d @teacss/bun
7
+ bun add --dev @teacss/bun
20
8
  ```
21
9
 
22
- ## Usage
23
-
24
10
  ```ts
25
11
  import { pluginTeacss } from "@teacss/bun";
26
12
 
@@ -31,20 +17,16 @@ await Bun.build({
31
17
  });
32
18
  ```
33
19
 
34
- `pluginTeacss()` is the one-shot `Bun.build` integration. Bun 1.3 does not
35
- expose watch-dependency registration or invalidation through its JavaScript
36
- plugin API. For a programmatic watch build, use `watchTeacssBuild`; it watches
37
- the Bun module graph together with the CSS entry, resolved config dependencies,
38
- and positive `@source` roots:
20
+ Import `virtual:teacss.css` from the application. `pluginTeacss()` is for a
21
+ one-shot build because Bun's plugin API does not expose watch invalidation.
22
+
23
+ For programmatic watch builds, use `watchTeacssBuild`:
39
24
 
40
25
  ```ts
41
26
  import { watchTeacssBuild } from "@teacss/bun";
42
27
 
43
28
  const session = await watchTeacssBuild(
44
- {
45
- entrypoints: ["./src/index.ts"],
46
- outdir: "./dist",
47
- },
29
+ { entrypoints: ["./src/index.ts"], outdir: "./dist" },
48
30
  {
49
31
  configOrPath: "./index.css",
50
32
  onError: (error) => console.error(error),
@@ -54,45 +36,13 @@ const session = await watchTeacssBuild(
54
36
  await session.dispose();
55
37
  ```
56
38
 
57
- The session exposes the latest successful `result`, background `error`, and
58
- successful-build `version`. An initial build or config failure still returns an
59
- active session: `result` is `undefined`, `version` is `0`, and `error` contains
60
- the failure until a watched change succeeds. With `throw: false`, an
61
- unsuccessful Bun result likewise calls only `onError` and does not replace the
62
- last successful result, version, or module inputs.
63
-
64
- A successful config reload replaces stale watch roots; a failed reload keeps
65
- the last successful configuration active while watching the failed attempt's
66
- dependencies for recovery. Callback failures are logged without changing build
67
- state. Known watch roots are installed before each build, newly discovered
68
- module roots receive a stabilizing rebuild, and failed native watchers are
69
- replaced on the next attempt. Writes outside the tracked config, source, module,
70
- and entry inputs do not force stabilization. Concurrent `dispose()` calls share
71
- one completion and wait for all in-flight builds and callbacks. A callback may
72
- also `await session.dispose()` to stop its own session; that reentrant call
73
- cannot wait for the invoking callback itself, while disposal started outside a
74
- callback still waits for the callback to finish.
75
-
76
- `Bun.build` added JavaScript metafile support in Bun 1.3.6. On older supported
77
- Bun versions, the helper omits that option and continues watching entry,
78
- TeaCSS config, and `@source` roots, but it cannot discover additional
79
- module-graph inputs outside those roots.
80
-
81
- ```ts
82
- import "virtual:teacss.css";
83
- ```
84
-
85
- ```css
86
- @preset "standard";
87
- @source "./src/**/*.{ts,tsx}";
88
- @teacss;
89
- ```
90
-
91
- Default source discovery skips dependency and common build-output directories.
92
- Explicit `@source` globs remain authoritative and can include those directories.
39
+ The session exposes the latest successful `result`, current `error`, and
40
+ successful-build `version`. Failed rebuilds preserve the last valid result and
41
+ continue watching configuration, module, entry, and positive `@source` roots.
42
+ `dispose()` waits for active work and is safe to call more than once.
93
43
 
94
- ## Status
44
+ Bun versions before 1.3.6 cannot expose extra module-graph inputs through a
45
+ metafile, so watch coverage is limited to entries, TeaCSS configuration, and
46
+ `@source` roots.
95
47
 
96
- Pre-1.0. `@teacss/bun` is the owning Bun adapter. Applications import it
97
- directly from `@teacss/bun`. Source transformers such as `:css:` compile-class
98
- are not run here.
48
+ Pre-1.0. Source compile-class transformers are not run by this adapter.
package/dist/index.d.ts CHANGED
@@ -20,8 +20,8 @@ import { BuildConfig, BuildOutput, BunPlugin } from "bun";
20
20
  * Like `@teacss/rsbuild`, this path does not run source transformers (so the
21
21
  * `:css:` compile-class transform is not applied here).
22
22
  */
23
- declare function pluginTeacss(configOrPath?: UserConfig<object> | string, defaults?: UserConfigDefaults): BunPlugin;
24
- interface WatchTeacssBuildOptions {
23
+ export declare function pluginTeacss(configOrPath?: UserConfig<object> | string, defaults?: UserConfigDefaults): BunPlugin;
24
+ export interface WatchTeacssBuildOptions {
25
25
  /** CSS entry file, discovery root, or inline configuration. */
26
26
  configOrPath?: UserConfig<object> | string;
27
27
  /** Defaults merged below the resolved TeaCSS configuration. */
@@ -31,7 +31,7 @@ interface WatchTeacssBuildOptions {
31
31
  onBuild?: (result: BuildOutput) => void | Promise<void>;
32
32
  onError?: (error: unknown) => void | Promise<void>;
33
33
  }
34
- interface TeacssBuildWatchSession {
34
+ export interface TeacssBuildWatchSession {
35
35
  /** Latest background rebuild error, cleared by the next successful build. */
36
36
  readonly error: unknown | undefined;
37
37
  /** Latest successful build result, or undefined until the first success. */
@@ -46,6 +46,5 @@ interface TeacssBuildWatchSession {
46
46
  * config and `@source` inputs change. Bun 1.3's plugin API has no dependency
47
47
  * registration or invalidation hook, so watch ownership lives in this helper.
48
48
  */
49
- declare function watchTeacssBuild(buildConfig: BuildConfig, options?: WatchTeacssBuildOptions): Promise<TeacssBuildWatchSession>;
50
- //#endregion
51
- export { TeacssBuildWatchSession, WatchTeacssBuildOptions, pluginTeacss, watchTeacssBuild };
49
+ export declare function watchTeacssBuild(buildConfig: BuildConfig, options?: WatchTeacssBuildOptions): Promise<TeacssBuildWatchSession>;
50
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teacss/bun",
3
- "version": "0.4.7",
3
+ "version": "0.5.1",
4
4
  "description": "Bun plugin for TeaCSS — generate utilities and inline @apply via Bun.build.",
5
5
  "homepage": "https://css.teasim.com",
6
6
  "funding": "https://github.com/sponsors/billgo",
@@ -22,14 +22,14 @@
22
22
  "dev": "tsdown --watch"
23
23
  },
24
24
  "dependencies": {
25
- "@teacss/core": "0.4.7",
26
- "@teacss/directives": "0.4.7",
27
- "@teacss/runtime": "0.4.7",
25
+ "@teacss/core": "0.5.1",
26
+ "@teacss/directives": "0.5.1",
27
+ "@teacss/runtime": "0.5.1",
28
28
  "tinyglobby": "^0.2.17"
29
29
  },
30
30
  "devDependencies": {
31
- "@teacss/preset-standard": "0.4.7",
32
- "bun-types": "^1.3.14",
31
+ "@teacss/preset-standard": "0.5.1",
32
+ "bun-types": "^1.4.1",
33
33
  "consola": "^3.4.2"
34
34
  },
35
35
  "engines": {