@teacss/vite 0.10.3 → 0.10.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type { ShellOptions } from "@teacss/engine";
2
2
  export { INSPECTOR_BASE, type TeacssViteOptions, type TeacssVitePluginApi, teacss } from "./plugin.js";
3
- export { BUILD_PLACEHOLDER, DEFAULT_PIPELINE_INCLUDE, ENTRY_IDS, MINIFIED_PLACEHOLDER, RESOLVED_ENTRY } from "./virtual.js";
3
+ export { BUILD_PLACEHOLDER, BUILD_PLACEHOLDER_PATTERN, DEFAULT_PIPELINE_INCLUDE, ENTRY_IDS, RESOLVED_ENTRY } from "./virtual.js";
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { INSPECTOR_BASE, teacss } from "./plugin.js";
2
- export { BUILD_PLACEHOLDER, DEFAULT_PIPELINE_INCLUDE, ENTRY_IDS, MINIFIED_PLACEHOLDER, RESOLVED_ENTRY } from "./virtual.js";
2
+ export { BUILD_PLACEHOLDER, BUILD_PLACEHOLDER_PATTERN, DEFAULT_PIPELINE_INCLUDE, ENTRY_IDS, RESOLVED_ENTRY } from "./virtual.js";
3
3
  //# sourceMappingURL=index.js.map
package/dist/plugin.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { join, posix, resolve } from "node:path";
4
4
  import { createProject, extractBundledFonts, isCssId, markers, replaceEntryWithMap } from "@teacss/engine";
5
5
  import { createInspectorMiddleware } from "@teacss/inspector";
6
- import { buildPlaceholder, hmrPath, isResolvedEntry, resolveEntryId, shouldTransform } from "./virtual.js";
6
+ import { BUILD_PLACEHOLDER, BUILD_PLACEHOLDER_PATTERN, hmrPath, isResolvedEntry, resolveEntryId, shouldTransform } from "./virtual.js";
7
7
  const INCLUDE_COMMENT = markers().includeComment;
8
8
  /** architecture §5: the files `loadProjectFromRoot` discovers the entry through. */
9
9
  const ENTRY_CANDIDATES = ["package.json", "index.css", "src/index.css"];
@@ -185,7 +185,7 @@ export function teacss(options = {}) {
185
185
  */
186
186
  function generated(warn) {
187
187
  if (config.command === "build")
188
- return buildPlaceholder(config.build.cssMinify, viteVersion);
188
+ return BUILD_PLACEHOLDER;
189
189
  if (failure)
190
190
  server?.hot.send({ type: "error", err: failure });
191
191
  const result = project.css();
@@ -304,14 +304,13 @@ export function teacss(options = {}) {
304
304
  },
305
305
  },
306
306
  generateBundle(_options, bundle) {
307
- const placeholder = buildPlaceholder(config.build.cssMinify, viteVersion);
308
307
  let css;
309
308
  const fonts = new Map();
310
309
  for (const file of Object.values(bundle)) {
311
310
  if (file.type !== "asset" || !file.fileName.endsWith(".css"))
312
311
  continue;
313
312
  const source = typeof file.source === "string" ? file.source : new TextDecoder().decode(file.source);
314
- if (!source.includes(placeholder))
313
+ if (source.search(BUILD_PLACEHOLDER_PATTERN) === -1)
315
314
  continue;
316
315
  if (css === undefined) {
317
316
  const result = project.css();
@@ -329,7 +328,7 @@ export function teacss(options = {}) {
329
328
  emitted.add(fileName);
330
329
  return assetUrl(config.base, file.fileName, fileName);
331
330
  }).css;
332
- file.source = source.replaceAll(placeholder, spliced);
331
+ file.source = source.replace(BUILD_PLACEHOLDER_PATTERN, () => spliced);
333
332
  // Vite's manifest lists a chunk's assets from `viteMetadata.importedAssets`; Astro moves the
334
333
  // fonts of its server build to the client output from that list.
335
334
  for (const chunk of Object.values(bundle)) {
package/dist/virtual.d.ts CHANGED
@@ -2,19 +2,14 @@
2
2
  export declare const ENTRY_IDS: ReadonlySet<string>;
3
3
  /** The resolved id of the virtual entry; Vite's CSS pipeline treats it as a `.css` module. */
4
4
  export declare const RESOLVED_ENTRY = "\0virtual:teacss.css";
5
- /** What `load` returns for the entry in a build; `generateBundle` replaces it with the generated CSS. */
6
- export declare const BUILD_PLACEHOLDER: string;
7
- /**
8
- * The placeholder for a build whose `cssMinify` is esbuild: Vite minifies with `legalComments: "none"`,
9
- * which drops the comment, while an unknown at-rule passes esbuild untouched and without a warning.
10
- * lightningcss keeps the comment and would warn about the at-rule, so it gets `BUILD_PLACEHOLDER`.
11
- */
12
- export declare const MINIFIED_PLACEHOLDER: string;
13
5
  /**
14
- * The placeholder a build with Vite's resolved `build.cssMinify` keeps until `generateBundle`. `true`
15
- * minifies with esbuild on Vite 7 and with lightningcss on Vite 8.
6
+ * What `load` returns for the entry in a build; `generateBundle` replaces it with the generated CSS. A rule,
7
+ * because every minifier keeps one: lightningcss keeps a legal comment only at the top of a stylesheet and
8
+ * warns about an unknown at-rule, esbuild drops the comment, and other CSS can precede the entry in a chunk.
16
9
  */
17
- export declare function buildPlaceholder(cssMinify: boolean | "esbuild" | "lightningcss", viteVersion: string): string;
10
+ export declare const BUILD_PLACEHOLDER: string;
11
+ /** `BUILD_PLACEHOLDER` as any minifier prints it. */
12
+ export declare const BUILD_PLACEHOLDER_PATTERN: RegExp;
18
13
  /** Resolves `virtual:teacss.css`, `teacss.css`, their `/`-prefixed forms and the resolved id itself, keeping a `?query`. */
19
14
  export declare function resolveEntryId(id: string): string | null;
20
15
  /**
package/dist/virtual.js CHANGED
@@ -3,22 +3,15 @@ import { CSS_PLACEHOLDER, isCssId } from "@teacss/engine";
3
3
  export const ENTRY_IDS = new Set(["virtual:teacss.css", "teacss.css"]);
4
4
  /** The resolved id of the virtual entry; Vite's CSS pipeline treats it as a `.css` module. */
5
5
  export const RESOLVED_ENTRY = "\0virtual:teacss.css";
6
- /** What `load` returns for the entry in a build; `generateBundle` replaces it with the generated CSS. */
7
- export const BUILD_PLACEHOLDER = `/*! ${CSS_PLACEHOLDER} */`;
6
+ const PLACEHOLDER_NAME = CSS_PLACEHOLDER.slice(1);
8
7
  /**
9
- * The placeholder for a build whose `cssMinify` is esbuild: Vite minifies with `legalComments: "none"`,
10
- * which drops the comment, while an unknown at-rule passes esbuild untouched and without a warning.
11
- * lightningcss keeps the comment and would warn about the at-rule, so it gets `BUILD_PLACEHOLDER`.
8
+ * What `load` returns for the entry in a build; `generateBundle` replaces it with the generated CSS. A rule,
9
+ * because every minifier keeps one: lightningcss keeps a legal comment only at the top of a stylesheet and
10
+ * warns about an unknown at-rule, esbuild drops the comment, and other CSS can precede the entry in a chunk.
12
11
  */
13
- export const MINIFIED_PLACEHOLDER = `${CSS_PLACEHOLDER};`;
14
- /**
15
- * The placeholder a build with Vite's resolved `build.cssMinify` keeps until `generateBundle`. `true`
16
- * minifies with esbuild on Vite 7 and with lightningcss on Vite 8.
17
- */
18
- export function buildPlaceholder(cssMinify, viteVersion) {
19
- const esbuild = cssMinify === "esbuild" || (cssMinify === true && Number.parseInt(viteVersion, 10) < 8);
20
- return esbuild ? MINIFIED_PLACEHOLDER : BUILD_PLACEHOLDER;
21
- }
12
+ export const BUILD_PLACEHOLDER = `#${PLACEHOLDER_NAME}{--${PLACEHOLDER_NAME}:0}`;
13
+ /** `BUILD_PLACEHOLDER` as any minifier prints it. */
14
+ export const BUILD_PLACEHOLDER_PATTERN = new RegExp(`#${PLACEHOLDER_NAME}\\s*\\{\\s*--${PLACEHOLDER_NAME}\\s*:\\s*0\\s*;?\\s*\\}`, "g");
22
15
  /** Resolves `virtual:teacss.css`, `teacss.css`, their `/`-prefixed forms and the resolved id itself, keeping a `?query`. */
23
16
  export function resolveEntryId(id) {
24
17
  const [bare = "", query] = splitQuery(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teacss/vite",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Vite plugin for TeaCSS on the Rust engine (@teacss/engine)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,11 +36,12 @@
36
36
  "vite": ">=7"
37
37
  },
38
38
  "dependencies": {
39
- "@teacss/engine": "0.10.3",
40
- "@teacss/inspector": "0.10.3"
39
+ "@teacss/engine": "0.10.4",
40
+ "@teacss/inspector": "0.10.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.20.5",
44
+ "lightningcss": "^1.32.0",
44
45
  "typescript": "^5.9.3",
45
46
  "vite": "^7.3.7"
46
47
  },