@kirana-style/esbuild 0.1.0 → 0.2.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 ADDED
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ ## [0.2.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.2.0) (2026-10-15)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29))
9
+
10
+ ### Features
11
+
12
+ * **editor:** real editor output on the site, open vsx trusted publishing ([#21](https://github.com/kirana-style/kirana/issues/21)) ([350fa4e](https://github.com/kirana-style/kirana/commit/350fa4ec0d8054a082d6c7dcdae2b5be53f8d98a))
13
+ * one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29)) ([b3f3154](https://github.com/kirana-style/kirana/commit/b3f3154662589dd1bd43fd0ff2341acf4f3df628))
14
+ * **site:** paper, ink, scenery and type for one identity ([#27](https://github.com/kirana-style/kirana/issues/27)) ([5da3c6f](https://github.com/kirana-style/kirana/commit/5da3c6f0f1c8cbfdb450b36a6609a3ab4b20e358))
15
+ * **site:** reorganise the homepage, product pages and docs ([#28](https://github.com/kirana-style/kirana/issues/28)) ([88b5209](https://github.com/kirana-style/kirana/commit/88b52093488b2aa0112b458ca04b836c83d03954))
16
+ * **site:** scenery gradients, logo downloads, pixel k, glass icons ([#25](https://github.com/kirana-style/kirana/issues/25)) ([2953dc1](https://github.com/kirana-style/kirana/commit/2953dc126f47b68257ebfdb33c61992984708c49))
17
+
18
+
19
+ ### Bug fixes
20
+
21
+ * hold emnapi at 2.0.0-alpha.6, the wasi engine fails on the beta ([#26](https://github.com/kirana-style/kirana/issues/26)) ([8aa33e1](https://github.com/kirana-style/kirana/commit/8aa33e1dbccaefa15b87f6487ac0a346bbf6581a))
22
+ * settle the ember dev check, resolve code scanning findings ([#23](https://github.com/kirana-style/kirana/issues/23)) ([0c266c8](https://github.com/kirana-style/kirana/commit/0c266c8428c1453892beeeb5f98918cbc0eae6ff))
23
+ * **site:** keep syntax colours in the production build ([#22](https://github.com/kirana-style/kirana/issues/22)) ([621f2fc](https://github.com/kirana-style/kirana/commit/621f2fcf67dada773ca66110e295ab7ac5605f56))
24
+
25
+
26
+ ### Documentation
27
+
28
+ * fix the extension's settings table ([#13](https://github.com/kirana-style/kirana/issues/13)) ([457e06d](https://github.com/kirana-style/kirana/commit/457e06d12f9e3b005e0820aab36faac5bf3f80b3))
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * bump the minor-and-patch group across 1 directory with 3 updates ([#19](https://github.com/kirana-style/kirana/issues/19)) ([7ea00ed](https://github.com/kirana-style/kirana/commit/7ea00edcc5cc02b9ab5e41b13f152ae344ea448f))
34
+ * emnapi 2.0.0-beta.1, minor and patch updates ([#24](https://github.com/kirana-style/kirana/issues/24)) ([a399fa7](https://github.com/kirana-style/kirana/commit/a399fa78e53dcfd7f41f249ccee1133809e66544))
35
+
36
+ ## [0.1.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.1.0) (2026-10-13)
37
+
38
+
39
+ ### Features
40
+
41
+ * kirana goes public — write objects, read classes, ship css ([79732ed](https://github.com/kirana-style/kirana/commit/79732edd5cab419169ab74ad59e1c70053dfa57d))
42
+
43
+
44
+ ### Dependencies
45
+
46
+ * bump the minor-and-patch group in /packages/kirana with 6 updates ([#10](https://github.com/kirana-style/kirana/issues/10)) ([0deaf9f](https://github.com/kirana-style/kirana/commit/0deaf9f3e75ebc377d764c294250bd2577d53844))
47
+ * bump the oxc group in /packages/kirana with 7 updates ([#9](https://github.com/kirana-style/kirana/issues/9)) ([a3ca94c](https://github.com/kirana-style/kirana/commit/a3ca94c170b2ca49c9691abf5ad48c3ef4ac8620))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kirana authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -15,6 +15,6 @@ await esbuild.build({
15
15
  ```
16
16
 
17
17
  `onLoad` compiles modules that carry styles; the stylesheet entry loads as a placeholder esbuild
18
- bundles as CSS, and `onEnd` writes the finished stylesheet into it — on disk, or in `outputFiles`
18
+ bundles as CSS, and `onEnd` writes the finished stylesheet into it, on disk or in `outputFiles`
19
19
  with `write: false`. Under `context().watch()` and `serve()` the entry reloads from a file the plugin
20
20
  keeps current, so the served stylesheet follows every edit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-style/esbuild",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Kirana for esbuild: compiles modules and finishes the stylesheet esbuild bundles.",
5
5
  "license": "MIT",
6
6
  "author": "The Kirana authors",
@@ -14,6 +14,9 @@
14
14
  "url": "https://github.com/kirana-style/kirana/issues"
15
15
  },
16
16
  "type": "module",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
17
20
  "exports": {
18
21
  ".": {
19
22
  "types": "./src/index.d.ts",
@@ -22,8 +25,8 @@
22
25
  "./package.json": "./package.json"
23
26
  },
24
27
  "dependencies": {
25
- "@kirana-style/compiler": "0.1.0",
26
- "@kirana-style/core": "0.1.0"
28
+ "@kirana-style/compiler": "0.2.0",
29
+ "@kirana-style/core": "0.2.0"
27
30
  },
28
31
  "peerDependencies": {
29
32
  "esbuild": ">=0.25.0"
@@ -34,6 +37,8 @@
34
37
  "*.d.ts",
35
38
  "*.css",
36
39
  "README.md",
40
+ "CHANGELOG.md",
41
+ "LICENSE",
37
42
  "builders.json",
38
43
  "schemas",
39
44
  "gatsby-node.mjs",
package/src/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- import type { DriverOptions } from "@kirana-style/compiler";
2
- import type { KiranaConfig } from "@kirana-style/core/config";
3
- import type { Plugin } from "esbuild";
1
+ import { DriverOptions } from "@kirana-style/compiler";
2
+ import { KiranaConfig } from "@kirana-style/core/config";
3
+ import { Plugin } from "esbuild";
4
+ //#region src/index.d.ts
4
5
  export type KiranaEsbuildOptions = {
5
- /** The project root: where `kirana.config.*` and `@kirana-style/core` are found. Default: the working directory. */
6
- root?: string;
7
- /** Options that override `kirana.config.*`. */
8
- config?: KiranaConfig;
9
- /** Report `info` diagnostics (such as `dynamic-bridged`) as warnings. */
10
- reportInfo?: boolean;
11
- /** Injected Driver options (tests). */
12
- driver?: Pick<DriverOptions, "native" | "importModule">;
6
+ /** The project root: where `kirana.config.*` and `@kirana-style/core` are found. Default: the working directory. */
7
+ root?: string;
8
+ /** Options that override `kirana.config.*`. */
9
+ config?: KiranaConfig;
10
+ /** Report `info` diagnostics (such as `dynamic-bridged`) as warnings. */
11
+ reportInfo?: boolean;
12
+ /** Injected Driver options (tests). */
13
+ driver?: Pick<DriverOptions, "native" | "importModule">;
13
14
  };
14
15
  export default function kirana(options?: KiranaEsbuildOptions): Plugin;
16
+ //#endregion
package/src/index.js CHANGED
@@ -1,111 +1,102 @@
1
- /**
2
- * The esbuild host adapter (KRN-INT-001, KRN-INT-003): `onLoad` compiles modules, and `onEnd` writes
3
- * the finished stylesheet into the CSS esbuild bundled. It never interprets styles (D-028).
4
- *
5
- * The stylesheet entry loads as the placeholder rule, which esbuild bundles like any CSS import
6
- * (`main.css` beside `main.js`); once every module has loaded, the plugin replaces it — in the written
7
- * file, or in `outputFiles` when esbuild keeps them in memory (`write: false`). Watch and serve reload
8
- * the entry itself from a file the plugin keeps current, so what `serve` sends follows every edit. A
9
- * `naming` pattern that hashes CSS keeps the placeholder's hash.
10
- */
11
1
  import { createHash } from "node:crypto";
12
2
  import { existsSync, writeFileSync } from "node:fs";
13
3
  import { readFile, writeFile } from "node:fs/promises";
14
4
  import { tmpdir } from "node:os";
15
5
  import path from "node:path";
16
6
  import { Driver } from "@kirana-style/compiler";
17
- import { PLACEHOLDER, createReporter, fillStylesheet, shouldCompile, stylesheetPath, } from "@kirana-style/compiler/host";
7
+ import { PLACEHOLDER, createReporter, fillStylesheet, shouldCompile, stylesheetPath } from "@kirana-style/compiler/host";
8
+ //#region src/index.ts
9
+ /**
10
+ * The esbuild host adapter (KRN-INT-001, KRN-INT-003): `onLoad` compiles modules, and `onEnd` writes
11
+ * the finished stylesheet into the CSS esbuild bundled. It never interprets styles (D-028).
12
+ *
13
+ * The stylesheet entry loads as the placeholder rule, which esbuild bundles like any CSS import
14
+ * (`main.css` beside `main.js`); once every module has loaded, the plugin replaces it — in the written
15
+ * file, or in `outputFiles` when esbuild keeps them in memory (`write: false`). Watch and serve reload
16
+ * the entry itself from a file the plugin keeps current, so what `serve` sends follows every edit. A
17
+ * `naming` pattern that hashes CSS keeps the placeholder's hash.
18
+ */
18
19
  const LOADERS = {
19
- tsx: "tsx",
20
- ts: "ts",
21
- mts: "ts",
22
- cts: "ts",
23
- jsx: "jsx",
20
+ tsx: "tsx",
21
+ ts: "ts",
22
+ mts: "ts",
23
+ cts: "ts",
24
+ jsx: "jsx"
24
25
  };
25
26
  /** An output file with new text, in the shape esbuild gives them. */
26
27
  function outputFile(file, text) {
27
- return { ...file, contents: new TextEncoder().encode(text), text };
28
+ return {
29
+ ...file,
30
+ contents: new TextEncoder().encode(text),
31
+ text
32
+ };
28
33
  }
29
- export default function kirana(options = {}) {
30
- return {
31
- name: "kirana",
32
- setup(build) {
33
- const root = options.root ?? process.cwd();
34
- const stylesheetFile = stylesheetPath(root);
35
- // The written outputs are found through the metafile.
36
- build.initialOptions.metafile = true;
37
- let driver;
38
- const session = () => (driver ??= Driver.create({
39
- root,
40
- config: options.config,
41
- ...options.driver,
42
- }));
43
- const reporter = createReporter(options);
44
- const context = {
45
- warn: (message) => console.warn(message),
46
- error: (message) => {
47
- throw new Error(message);
48
- },
49
- };
50
- // Watch and serve: the entry follows a file `onEnd` writes whenever the stylesheet changes, so a
51
- // rebuild reloads it with the live stylesheet — which is what `serve` sends, from its own
52
- // copy of the outputs. The first load, and every load of a one-shot build, is the placeholder.
53
- const live = path.join(tmpdir(), `kirana-esbuild-${createHash("sha256").update(root).digest("hex").slice(0, 12)}.css`);
54
- let written;
55
- writeFileSync(live, "");
56
- build.onLoad({ filter: /stylesheet\.css$/ }, async ({ path: file }) => file === stylesheetFile
57
- ? {
58
- contents: written === undefined
59
- ? PLACEHOLDER
60
- : (await session()).stylesheet(Boolean(build.initialOptions.minify)),
61
- loader: "css",
62
- watchFiles: [live],
63
- }
64
- : undefined);
65
- build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async ({ path: file }) => {
66
- const compiler = await session();
67
- if (!compiler.compiles(file))
68
- return undefined;
69
- const code = await readFile(file, "utf8");
70
- if (!shouldCompile(file, code, compiler.libraries))
71
- return undefined;
72
- const result = compiler.transform(file, code);
73
- reporter.module(context, file, code, result.diagnostics);
74
- if (result.code === undefined)
75
- return undefined;
76
- return {
77
- contents: result.code,
78
- loader: LOADERS[file.slice(file.lastIndexOf(".") + 1)] ?? "js",
79
- };
80
- });
81
- build.onEnd(async (result) => {
82
- const compiler = await session();
83
- reporter.project(context, root, compiler.diagnostics());
84
- const css = compiler.stylesheet(Boolean(build.initialOptions.minify));
85
- if (css !== written) {
86
- written = css;
87
- await writeFile(live, css);
88
- }
89
- if (result.outputFiles) {
90
- result.outputFiles.forEach((file, index) => {
91
- const source = file.path.endsWith(".css")
92
- ? fillStylesheet(file.text, css)
93
- : undefined;
94
- if (source !== undefined)
95
- result.outputFiles[index] = outputFile(file, source);
96
- });
97
- return;
98
- }
99
- const base = build.initialOptions.absWorkingDir ?? process.cwd();
100
- for (const output of Object.keys(result.metafile.outputs)) {
101
- const file = path.resolve(base, output);
102
- if (!file.endsWith(".css") || !existsSync(file))
103
- continue;
104
- const source = fillStylesheet(await readFile(file, "utf8"), css);
105
- if (source !== undefined)
106
- await writeFile(file, source);
107
- }
108
- });
109
- },
110
- };
34
+ function kirana(options = {}) {
35
+ return {
36
+ name: "kirana",
37
+ setup(build) {
38
+ const root = options.root ?? process.cwd();
39
+ const stylesheetFile = stylesheetPath(root);
40
+ build.initialOptions.metafile = true;
41
+ let driver;
42
+ const session = () => driver ??= Driver.create({
43
+ root,
44
+ config: options.config,
45
+ ...options.driver
46
+ });
47
+ const reporter = createReporter(options);
48
+ const context = {
49
+ warn: (message) => console.warn(message),
50
+ error: (message) => {
51
+ throw new Error(message);
52
+ }
53
+ };
54
+ const live = path.join(tmpdir(), `kirana-esbuild-${createHash("sha256").update(root).digest("hex").slice(0, 12)}.css`);
55
+ let written;
56
+ writeFileSync(live, "");
57
+ build.onLoad({ filter: /stylesheet\.css$/ }, async ({ path: file }) => file === stylesheetFile ? {
58
+ contents: written === void 0 ? PLACEHOLDER : (await session()).stylesheet(Boolean(build.initialOptions.minify)),
59
+ loader: "css",
60
+ watchFiles: [live]
61
+ } : void 0);
62
+ build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async ({ path: file }) => {
63
+ const compiler = await session();
64
+ if (!compiler.compiles(file)) return void 0;
65
+ const code = await readFile(file, "utf8");
66
+ if (!shouldCompile(file, code, compiler.libraries)) return void 0;
67
+ const result = compiler.transform(file, code);
68
+ reporter.module(context, file, code, result.diagnostics);
69
+ if (result.code === void 0) return void 0;
70
+ return {
71
+ contents: result.code,
72
+ loader: LOADERS[file.slice(file.lastIndexOf(".") + 1)] ?? "js"
73
+ };
74
+ });
75
+ build.onEnd(async (result) => {
76
+ const compiler = await session();
77
+ reporter.project(context, root, compiler.diagnostics());
78
+ const css = compiler.stylesheet(Boolean(build.initialOptions.minify));
79
+ if (css !== written) {
80
+ written = css;
81
+ await writeFile(live, css);
82
+ }
83
+ if (result.outputFiles) {
84
+ result.outputFiles.forEach((file, index) => {
85
+ const source = file.path.endsWith(".css") ? fillStylesheet(file.text, css) : void 0;
86
+ if (source !== void 0) result.outputFiles[index] = outputFile(file, source);
87
+ });
88
+ return;
89
+ }
90
+ const base = build.initialOptions.absWorkingDir ?? process.cwd();
91
+ for (const output of Object.keys(result.metafile.outputs)) {
92
+ const file = path.resolve(base, output);
93
+ if (!file.endsWith(".css") || !existsSync(file)) continue;
94
+ const source = fillStylesheet(await readFile(file, "utf8"), css);
95
+ if (source !== void 0) await writeFile(file, source);
96
+ }
97
+ });
98
+ }
99
+ };
111
100
  }
101
+ //#endregion
102
+ export { kirana as default };