@kirana-style/rolldown 0.2.3 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0](https://github.com/kirana-style/kirana/compare/v0.2.4...v0.3.0) (2026-10-21)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * declare a variable token only where something uses it ([#62](https://github.com/kirana-style/kirana/issues/62))
9
+
10
+ ### Features
11
+
12
+ * component states as condition keys, and values checked by grammar ([#82](https://github.com/kirana-style/kirana/issues/82)) ([2c034e7](https://github.com/kirana-style/kirana/commit/2c034e7b3c1e51f35a120c5af02934e3f3fa5b4e))
13
+ * declare a variable token only where something uses it ([#62](https://github.com/kirana-style/kirana/issues/62)) ([811fbdd](https://github.com/kirana-style/kirana/commit/811fbdd5d1276738306eb1e22cca6b5b3a77c92a))
14
+ * remix 3, with sx in compiled jsx ([#80](https://github.com/kirana-style/kirana/issues/80)) ([b6e9d12](https://github.com/kirana-style/kirana/commit/b6e9d1284d23e89e70ca7b82ef5eab2ca2378a74))
15
+ * **site:** a partners page, the theme in the footer, a new quick start ([#70](https://github.com/kirana-style/kirana/issues/70)) ([9f5552c](https://github.com/kirana-style/kirana/commit/9f5552c91801350ffe641f7482b1807096fed409))
16
+ * **site:** quick start pills, full chart comparisons, updated skills ([#72](https://github.com/kirana-style/kirana/issues/72)) ([abc2363](https://github.com/kirana-style/kirana/commit/abc23638a3e47a2daf8b3af89705bb67544dc879))
17
+ * **site:** what ci runs on, and a lighter quick start ([#79](https://github.com/kirana-style/kirana/issues/79)) ([5ef3c51](https://github.com/kirana-style/kirana/commit/5ef3c515b880c40fc4735954105b07ed7f4b3439))
18
+ * solidstart, vike, waku, vitepress, docusaurus and storybook ([#78](https://github.com/kirana-style/kirana/issues/78)) ([de928d2](https://github.com/kirana-style/kirana/commit/de928d2bb9438e5a02b529ed5aacc69456b32401))
19
+ * **ui:** charts on tanstack charts, with the benchmark and scale-curve charts ([#69](https://github.com/kirana-style/kirana/issues/69)) ([e33de7e](https://github.com/kirana-style/kirana/commit/e33de7e3fcb2d0ebe18c54cc2804a011782d47a1))
20
+
21
+
22
+ ### Performance
23
+
24
+ * keep the stylesheet and project diagnostics until something changes ([#65](https://github.com/kirana-style/kirana/issues/65)) ([91b67fa](https://github.com/kirana-style/kirana/commit/91b67fa77f99e714a2485752291139c54900cfd0))
25
+ * order atoms within a conflict key so adjacent keys share rules ([#63](https://github.com/kirana-style/kirana/issues/63)) ([42be523](https://github.com/kirana-style/kirana/commit/42be5231df063e5f9cece88a705808515bc13076))
26
+ * **site:** load the homepage's chapters below the hero on their own ([#68](https://github.com/kirana-style/kirana/issues/68)) ([5ccf916](https://github.com/kirana-style/kirana/commit/5ccf916d00cb253616650e7146d5d75d8ffefb3b))
27
+ * **site:** no software webgl, repository numbers through the worker ([#67](https://github.com/kirana-style/kirana/issues/67)) ([db11850](https://github.com/kirana-style/kirana/commit/db1185057b9048cb7296082318768f5307a9ed2d))
28
+ * **site:** prerender pages, split shared chunks, two new scenes ([#66](https://github.com/kirana-style/kirana/issues/66)) ([8e5160e](https://github.com/kirana-style/kirana/commit/8e5160e271970859dddb844e0290005d3cdd797c))
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * bump the minor-and-patch group across 1 directory with 2 updates ([#75](https://github.com/kirana-style/kirana/issues/75)) ([bccbb0c](https://github.com/kirana-style/kirana/commit/bccbb0c42e50915943e53b8c0dc3fc623ad9d5fa))
34
+ * bump the minor-and-patch group with 16 updates ([#76](https://github.com/kirana-style/kirana/issues/76)) ([9f4df94](https://github.com/kirana-style/kirana/commit/9f4df947dda37e45e80231fd36203cc08399e903))
35
+ * bump the oxc group in /packages/kirana with 7 updates ([#74](https://github.com/kirana-style/kirana/issues/74)) ([7718a1c](https://github.com/kirana-style/kirana/commit/7718a1cc0acb57d6816146ded78b02853b16c928))
36
+ * vite-plus 1.3.0, and a licence check for javascript dependencies ([#77](https://github.com/kirana-style/kirana/issues/77)) ([1ab86c3](https://github.com/kirana-style/kirana/commit/1ab86c33205b58ce714a5e605d7f9f0a3c63a4aa))
37
+
38
+ ## [0.2.4](https://github.com/kirana-style/kirana/compare/v0.2.3...v0.2.4) (2026-10-19)
39
+
40
+
41
+ ### Performance
42
+
43
+ * compile each module once in a one-shot build ([#59](https://github.com/kirana-style/kirana/issues/59)) ([df6d014](https://github.com/kirana-style/kirana/commit/df6d014fae6cd5c85a032056b1322db09427aed3))
44
+ * compile modules in parallel in vite and rolldown builds ([#60](https://github.com/kirana-style/kirana/issues/60)) ([e2eb29a](https://github.com/kirana-style/kirana/commit/e2eb29a667bd563cee2e2cf20f51a5e1d46f8c0d))
45
+
46
+
47
+ ### Documentation
48
+
49
+ * take the benchmarks of kirana 0.2.3 from kirana-lab ([#57](https://github.com/kirana-style/kirana/issues/57)) ([ab95357](https://github.com/kirana-style/kirana/commit/ab95357157fda97aad33007277c542118c89f5a9))
50
+
3
51
  ## [0.2.3](https://github.com/kirana-style/kirana/compare/v0.2.2...v0.2.3) (2026-10-19)
4
52
 
5
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-style/rolldown",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Kirana for Rolldown: compiles modules and emits the stylesheet.",
5
5
  "license": "MIT",
6
6
  "author": "The Kirana authors",
@@ -25,8 +25,8 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@kirana-style/compiler": "0.2.3",
29
- "@kirana-style/core": "0.2.3"
28
+ "@kirana-style/compiler": "0.3.0",
29
+ "@kirana-style/core": "0.3.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "rolldown": "^1.2.12"
package/src/index.d.ts CHANGED
@@ -49,8 +49,14 @@ export type Host = {
49
49
  export declare function createKirana(options?: KiranaRolldownOptions, host?: Host): {
50
50
  plugin: {
51
51
  name: string;
52
- buildStart(): Promise<void>;
53
- renderChunk(code: string, chunk: {
52
+ buildStart(this: {
53
+ meta: {
54
+ watchMode: boolean;
55
+ };
56
+ }): Promise<void>;
57
+ renderChunk(this: {
58
+ error: (message: string) => never;
59
+ }, code: string, chunk: {
54
60
  fileName: string;
55
61
  }): Promise<{
56
62
  code: string;
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { COMPONENT, Driver } from "@kirana-style/compiler";
2
- import { ASSET_QUERY, PLACEHOLDER, SCRIPT, STYLE_BEARING, cleanId, createReporter, fillStylesheet, renameAsset, stylesheetPath } from "@kirana-style/compiler/host";
2
+ import { ASSET_QUERY, PLACEHOLDER, SCRIPT, STYLE_BEARING, VIRTUAL, cleanId, createReporter, fillStylesheet, renameAsset, stylesheetPath, tokenNames } from "@kirana-style/compiler/host";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  //#region src/index.ts
@@ -32,6 +32,13 @@ function createKirana(options = {}, host = {}) {
32
32
  const development = () => host.development?.() ?? false;
33
33
  const fileName = options.fileName ?? "kirana.css";
34
34
  const dense = () => options.names === "dense" && !development();
35
+ /**
36
+ * Every variable token the bundle's chunks and other files name, across environments, and the
37
+ * ones the last stylesheet left out by identity (D-086): a token only code names is written when
38
+ * the finished bundle still names it, and a chunk rendered later must not name one left out.
39
+ */
40
+ const named = /* @__PURE__ */ new Set();
41
+ let pruned = /* @__PURE__ */ new Map();
35
42
  const session = () => {
36
43
  driver ??= Driver.create({
37
44
  root: state.root,
@@ -45,14 +52,24 @@ function createKirana(options = {}, host = {}) {
45
52
  name: "kirana",
46
53
  async buildStart() {
47
54
  const compiler = await session();
55
+ if (!development() && !this.meta.watchMode) compiler.reuseTransforms();
48
56
  if (dense()) {
49
57
  if (compiler.classModules.length > 0) throw new Error("kirana: `names: \"dense\"` cannot be used with a class map (`classes`): server templates read hashed names");
50
58
  compiler.markDense();
51
59
  }
52
60
  },
53
61
  async renderChunk(code, chunk) {
62
+ if (development()) return null;
63
+ const compiler = await session();
64
+ const names = tokenNames(code, compiler.prefix);
65
+ const late = names.filter((name) => pruned.has(name));
66
+ if (late.length > 0) {
67
+ const list = late.map((name) => `${pruned.get(name)} (${name})`).join(", ");
68
+ this.error(`kirana: ${chunk.fileName} reads tokens the stylesheet left out: ${list}. Nothing the stylesheet's own build bundled named them at runtime. Declare each one \`runtime: true\` in defineTokens (D-086).`);
69
+ }
70
+ for (const name of names) named.add(name);
54
71
  if (!dense()) return null;
55
- return (await session()).dense(code, chunk.fileName) ?? null;
72
+ return compiler.dense(code, chunk.fileName) ?? null;
56
73
  },
57
74
  load: {
58
75
  filter: { id: [/stylesheet\.css/, COMPONENT] },
@@ -83,7 +100,11 @@ function createKirana(options = {}, host = {}) {
83
100
  filter: {
84
101
  id: {
85
102
  include: SCRIPT,
86
- exclude: [ASSET_QUERY, COMPONENT_PART]
103
+ exclude: [
104
+ ASSET_QUERY,
105
+ COMPONENT_PART,
106
+ VIRTUAL
107
+ ]
87
108
  },
88
109
  code: STYLE_BEARING
89
110
  },
@@ -91,7 +112,7 @@ function createKirana(options = {}, host = {}) {
91
112
  const file = cleanId(id);
92
113
  const compiler = await session();
93
114
  if (!compiler.compiles(file)) return null;
94
- const result = compiler.transform(file, code);
115
+ const result = development() ? compiler.transform(file, code) : await compiler.transformAsync(file, code);
95
116
  for (const dependency of result.dependencies) this.addWatchFile(dependency);
96
117
  reporter.module(this, file, code, result.diagnostics);
97
118
  if (result.cssChanged) host.cssChanged?.();
@@ -113,7 +134,7 @@ function createKirana(options = {}, host = {}) {
113
134
  order: "pre",
114
135
  async handler(_output, bundle) {
115
136
  if (!host.bundlesCss) {
116
- const css = (await session()).stylesheet(true, dense());
137
+ const css = await finished(bundle);
117
138
  this.emitFile({
118
139
  type: "asset",
119
140
  fileName,
@@ -126,13 +147,24 @@ function createKirana(options = {}, host = {}) {
126
147
  }
127
148
  };
128
149
  /**
150
+ * The stylesheet for this bundle (D-086): the token names its other files hold join the chunks',
151
+ * and the tokens left out are kept for the chunks rendered after it.
152
+ */
153
+ const finished = async (bundle) => {
154
+ const compiler = await session();
155
+ for (const file of Object.values(bundle)) if (file.type === "asset" && typeof file.source === "string") for (const name of tokenNames(file.source, compiler.prefix)) named.add(name);
156
+ const result = compiler.finishedStylesheet(named, dense());
157
+ pruned = new Map(result.pruned.map((token) => [token.variable, token.identity]));
158
+ return result.css;
159
+ };
160
+ /**
129
161
  * Fills every stylesheet asset still holding the placeholder, renaming it by content unless the
130
162
  * host keeps names, and points the chunks and assets that named it at the new name. A second pass
131
163
  * finds nothing to do, so a host may run it again later in `generateBundle` for assets another
132
164
  * plugin added after the first pass (Qwik's).
133
165
  */
134
166
  const fill = async (bundle, emitFile) => {
135
- const css = (await session()).stylesheet(true, dense());
167
+ const css = await finished(bundle);
136
168
  for (const [key, asset] of Object.entries(bundle)) {
137
169
  if (asset.type !== "asset") continue;
138
170
  const source = fillStylesheet(String(asset.source), css);