@typestyles/vite 0.5.1 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @typestyles/vite
2
2
 
3
- Vite plugin for [typestyles](https://github.com/type-styles/typestyles): style HMR in development, optional zero-runtime CSS extraction in production.
3
+ Vite plugin for [typestyles](https://github.com/phthalo-dev/typestyles): style HMR in development, optional zero-runtime CSS extraction in production.
4
4
 
5
5
  TypeStyles works without a bundler plugin — styles inject at runtime on first use. This plugin is optional but recommended for Vite apps: it keeps component state while styles hot-reload, catches duplicate namespace collisions at build time, and can emit a static `typestyles.css` file so production ships without client-side `<style>` injection.
6
6
 
package/dist/index.cjs CHANGED
@@ -1,248 +1,207 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- DEFAULT_EXTRACT_MODULE_CANDIDATES: () => import_build_runner2.DEFAULT_EXTRACT_MODULE_CANDIDATES,
24
- default: () => typestylesPlugin,
25
- discoverDefaultExtractModules: () => import_build_runner2.discoverDefaultExtractModules,
26
- extractNamespaces: () => import_build_runner.extractNamespaces,
27
- htmlLinksTypestylesCss: () => htmlLinksTypestylesCss,
28
- moduleNeedsOverrideHmr: () => import_build_runner3.moduleNeedsOverrideHmr,
29
- resolveTypestylesCssHref: () => resolveTypestylesCssHref
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
30
4
  });
31
- module.exports = __toCommonJS(index_exports);
32
- var import_node_path = require("path");
33
- var import_build_runner = require("@typestyles/build-runner");
34
- var import_build_runner2 = require("@typestyles/build-runner");
35
- var import_build_runner3 = require("@typestyles/build-runner");
5
+ let node_path = require("node:path");
6
+ let _typestyles_build_runner = require("@typestyles/build-runner");
7
+ //#region src/index.ts
36
8
  function resolveExtractModulesForVite(root, extract) {
37
- return (0, import_build_runner.resolveExtractModules)(root, extract);
9
+ return (0, _typestyles_build_runner.resolveExtractModules)(root, extract);
38
10
  }
39
11
  function resolveTypestylesCssHref(base, fileName) {
40
- const normalizedFileName = fileName.replace(/^\//, "");
41
- const normalizedBase = base.replace(/\/$/, "") || "";
42
- if (normalizedBase === "" || normalizedBase === "/") {
43
- return `/${normalizedFileName}`;
44
- }
45
- return `${normalizedBase}/${normalizedFileName}`;
12
+ const normalizedFileName = fileName.replace(/^\//, "");
13
+ const normalizedBase = base.replace(/\/$/, "") || "";
14
+ if (normalizedBase === "" || normalizedBase === "/") return `/${normalizedFileName}`;
15
+ return `${normalizedBase}/${normalizedFileName}`;
46
16
  }
47
17
  function htmlLinksTypestylesCss(html, cssHref, fileName) {
48
- const bareName = fileName.replace(/^\//, "");
49
- const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
50
- const hrefPattern = /\bhref=["']([^"']+)["']/i;
51
- for (const match of html.matchAll(linkPattern)) {
52
- const hrefMatch = match[0].match(hrefPattern);
53
- const href = hrefMatch?.[1];
54
- if (!href) continue;
55
- if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) {
56
- return true;
57
- }
58
- }
59
- return false;
18
+ const bareName = fileName.replace(/^\//, "");
19
+ const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
20
+ const hrefPattern = /\bhref=["']([^"']+)["']/i;
21
+ for (const match of html.matchAll(linkPattern)) {
22
+ const href = match[0].match(hrefPattern)?.[1];
23
+ if (!href) continue;
24
+ if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) return true;
25
+ }
26
+ return false;
60
27
  }
61
28
  function typestylesPlugin(options = {}) {
62
- const { warnDuplicates = true, extract } = options;
63
- let resolvedExtractModules = [];
64
- let resolvedMode = "runtime";
65
- const moduleNamespaces = /* @__PURE__ */ new Map();
66
- let resolvedConfig = null;
67
- let isBuildCommand = false;
68
- let isServe = false;
69
- let devExtractCss = null;
70
- let devExtractInFlight = null;
71
- return {
72
- name: "typestyles",
73
- enforce: "pre",
74
- config(config, env) {
75
- isBuildCommand = env.command === "build";
76
- const root = (0, import_node_path.resolve)(config.root ?? process.cwd());
77
- resolvedExtractModules = resolveExtractModulesForVite(root, extract);
78
- resolvedMode = (0, import_build_runner.resolveExtractMode)(options.mode, resolvedExtractModules);
79
- if (env.command === "build" && (resolvedMode === "build" || resolvedMode === "hybrid")) {
80
- config.define = {
81
- ...config.define ?? {},
82
- // Inlined by the bundler so typestyles sheet skips creating <style> in production
83
- __TYPESTYLES_RUNTIME_DISABLED__: JSON.stringify("true")
84
- };
85
- }
86
- return config;
87
- },
88
- configResolved(config) {
89
- resolvedConfig = config;
90
- isServe = config.command === "serve";
91
- },
92
- configureServer(server) {
93
- if (resolvedExtractModules.length === 0) return;
94
- if (resolvedMode === "runtime") return;
95
- const fileName = extract?.fileName ?? "typestyles.css";
96
- const invalidateDevExtract = () => {
97
- devExtractCss = null;
98
- devExtractInFlight = null;
99
- };
100
- server.watcher.on("change", invalidateDevExtract);
101
- server.watcher.on("add", invalidateDevExtract);
102
- server.watcher.on("unlink", invalidateDevExtract);
103
- server.middlewares.use(async (req, res, next) => {
104
- if (req.method !== "GET" && req.method !== "HEAD") {
105
- next();
106
- return;
107
- }
108
- const config = resolvedConfig;
109
- if (!config) {
110
- next();
111
- return;
112
- }
113
- const url = req.url?.split("?")[0] ?? "";
114
- const base = config.base.replace(/\/$/, "") || "";
115
- const expectedPath = base === "" || base === "/" ? `/${fileName.replace(/^\//, "")}` : `${base}/${fileName.replace(/^\//, "")}`;
116
- if (url !== expectedPath) {
117
- next();
118
- return;
119
- }
120
- const root = config.root ?? process.cwd();
121
- try {
122
- if (devExtractCss !== null) {
123
- res.statusCode = 200;
124
- res.setHeader("Content-Type", "text/css; charset=utf-8");
125
- res.setHeader("Cache-Control", "no-cache");
126
- res.end(devExtractCss);
127
- return;
128
- }
129
- if (!devExtractInFlight) {
130
- devExtractInFlight = (0, import_build_runner.runTypestylesBuild)({
131
- root,
132
- modules: resolvedExtractModules
133
- }).then((css2) => {
134
- devExtractCss = css2;
135
- return css2;
136
- }).finally(() => {
137
- devExtractInFlight = null;
138
- });
139
- }
140
- const css = await devExtractInFlight;
141
- res.statusCode = 200;
142
- res.setHeader("Content-Type", "text/css; charset=utf-8");
143
- res.setHeader("Cache-Control", "no-cache");
144
- res.end(css);
145
- } catch (err) {
146
- next(err);
147
- }
148
- });
149
- },
150
- transform(code, id) {
151
- if (!/\.[jt]sx?$/.test(id)) return null;
152
- if (id.includes("node_modules")) return null;
153
- const { keys, prefixes } = (0, import_build_runner.extractNamespaces)(code);
154
- const overrideHmr = (0, import_build_runner.moduleNeedsOverrideHmr)(code);
155
- if (keys.length === 0 && prefixes.length === 0 && !overrideHmr) return null;
156
- if (warnDuplicates && prefixes.length > 0) {
157
- (0, import_build_runner.reportDuplicateNamespaces)(moduleNamespaces, id, prefixes, this);
158
- }
159
- if (keys.length > 0 || prefixes.length > 0) {
160
- moduleNamespaces.set(id, { keys, prefixes });
161
- }
162
- if (!isServe) {
163
- return null;
164
- }
165
- const keysJSON = JSON.stringify(keys);
166
- const prefixesJSON = JSON.stringify(prefixes);
167
- const hmrImports = overrideHmr ? `import { invalidateKeys as __typestylesInvalidateKeys, createOverrideHmrSlot as __tsCreateOvHmr } from 'typestyles/hmr';
168
- ` : `import { invalidateKeys as __typestylesInvalidateKeys } from 'typestyles/hmr';
169
- `;
170
- const overrideBootstrap = overrideHmr ? `const __tsOvHmr = __tsCreateOvHmr();
171
- __tsOvHmr.activate();
172
- ` : "";
173
- const overrideTeardown = overrideHmr ? `
174
- __tsOvHmr.deactivate();
175
- ` : "";
176
- const disposeBody = [
177
- keys.length > 0 || prefixes.length > 0 ? `__typestylesInvalidateKeys(${keysJSON}, ${prefixesJSON});` : null,
178
- overrideHmr ? `__tsOvHmr.dispose();` : null
179
- ].filter(Boolean).join("\n ");
180
- const hmrCode = `${overrideTeardown}
29
+ const { warnDuplicates = true, extract } = options;
30
+ let resolvedExtractModules = [];
31
+ let resolvedMode = "runtime";
32
+ const moduleNamespaces = new Map();
33
+ let resolvedConfig = null;
34
+ let isBuildCommand = false;
35
+ let isServe = false;
36
+ let devExtractCss = null;
37
+ let devExtractInFlight = null;
38
+ return {
39
+ name: "typestyles",
40
+ enforce: "pre",
41
+ config(config, env) {
42
+ isBuildCommand = env.command === "build";
43
+ resolvedExtractModules = resolveExtractModulesForVite((0, node_path.resolve)(config.root ?? process.cwd()), extract);
44
+ resolvedMode = (0, _typestyles_build_runner.resolveExtractMode)(options.mode, resolvedExtractModules);
45
+ if (env.command === "build" && (resolvedMode === "build" || resolvedMode === "hybrid")) config.define = {
46
+ ...config.define ?? {},
47
+ __TYPESTYLES_RUNTIME_DISABLED__: JSON.stringify("true")
48
+ };
49
+ return config;
50
+ },
51
+ configResolved(config) {
52
+ resolvedConfig = config;
53
+ isServe = config.command === "serve";
54
+ },
55
+ configureServer(server) {
56
+ if (resolvedExtractModules.length === 0) return;
57
+ if (resolvedMode === "runtime") return;
58
+ const fileName = extract?.fileName ?? "typestyles.css";
59
+ const invalidateDevExtract = () => {
60
+ devExtractCss = null;
61
+ devExtractInFlight = null;
62
+ };
63
+ server.watcher.on("change", invalidateDevExtract);
64
+ server.watcher.on("add", invalidateDevExtract);
65
+ server.watcher.on("unlink", invalidateDevExtract);
66
+ server.middlewares.use(async (req, res, next) => {
67
+ if (req.method !== "GET" && req.method !== "HEAD") {
68
+ next();
69
+ return;
70
+ }
71
+ const config = resolvedConfig;
72
+ if (!config) {
73
+ next();
74
+ return;
75
+ }
76
+ const url = req.url?.split("?")[0] ?? "";
77
+ const base = config.base.replace(/\/$/, "") || "";
78
+ if (url !== (base === "" || base === "/" ? `/${fileName.replace(/^\//, "")}` : `${base}/${fileName.replace(/^\//, "")}`)) {
79
+ next();
80
+ return;
81
+ }
82
+ const root = config.root ?? process.cwd();
83
+ try {
84
+ if (devExtractCss !== null) {
85
+ res.statusCode = 200;
86
+ res.setHeader("Content-Type", "text/css; charset=utf-8");
87
+ res.setHeader("Cache-Control", "no-cache");
88
+ res.end(devExtractCss);
89
+ return;
90
+ }
91
+ if (!devExtractInFlight) devExtractInFlight = (0, _typestyles_build_runner.runTypestylesBuild)({
92
+ root,
93
+ modules: resolvedExtractModules
94
+ }).then((css) => {
95
+ devExtractCss = css;
96
+ return css;
97
+ }).finally(() => {
98
+ devExtractInFlight = null;
99
+ });
100
+ const css = await devExtractInFlight;
101
+ res.statusCode = 200;
102
+ res.setHeader("Content-Type", "text/css; charset=utf-8");
103
+ res.setHeader("Cache-Control", "no-cache");
104
+ res.end(css);
105
+ } catch (err) {
106
+ next(err);
107
+ }
108
+ });
109
+ },
110
+ transform(code, id) {
111
+ if (!/\.[jt]sx?$/.test(id)) return null;
112
+ if (id.includes("node_modules")) return null;
113
+ const { keys, prefixes } = (0, _typestyles_build_runner.extractNamespaces)(code);
114
+ const overrideHmr = (0, _typestyles_build_runner.moduleNeedsOverrideHmr)(code);
115
+ if (keys.length === 0 && prefixes.length === 0 && !overrideHmr) return null;
116
+ if (warnDuplicates && prefixes.length > 0) (0, _typestyles_build_runner.reportDuplicateNamespaces)(moduleNamespaces, id, prefixes, this);
117
+ if (keys.length > 0 || prefixes.length > 0) moduleNamespaces.set(id, {
118
+ keys,
119
+ prefixes
120
+ });
121
+ if (!isServe) return null;
122
+ const keysJSON = JSON.stringify(keys);
123
+ const prefixesJSON = JSON.stringify(prefixes);
124
+ const hmrImports = overrideHmr ? `import { invalidateKeys as __typestylesInvalidateKeys, createOverrideHmrSlot as __tsCreateOvHmr } from 'typestyles/hmr';\n` : `import { invalidateKeys as __typestylesInvalidateKeys } from 'typestyles/hmr';\n`;
125
+ const overrideBootstrap = overrideHmr ? `const __tsOvHmr = __tsCreateOvHmr();\n__tsOvHmr.activate();\n` : "";
126
+ const hmrCode = `${overrideHmr ? `\n__tsOvHmr.deactivate();\n` : ""}
181
127
  if (import.meta.hot) {
182
128
  import.meta.hot.accept();
183
129
  import.meta.hot.dispose(() => {
184
- ${disposeBody}
130
+ ${[keys.length > 0 || prefixes.length > 0 ? `__typestylesInvalidateKeys(${keysJSON}, ${prefixesJSON});` : null, overrideHmr ? `__tsOvHmr.dispose();` : null].filter(Boolean).join("\n ")}
185
131
  });
186
132
  }`;
187
- return {
188
- code: hmrImports + overrideBootstrap + code + hmrCode,
189
- map: null
190
- };
191
- },
192
- transformIndexHtml: {
193
- order: "pre",
194
- handler(html) {
195
- if (resolvedExtractModules.length === 0) return;
196
- if (resolvedMode === "runtime") return;
197
- if (!resolvedConfig) return;
198
- const fileName = extract?.fileName ?? "typestyles.css";
199
- const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
200
- if (htmlLinksTypestylesCss(html, href, fileName)) {
201
- return;
202
- }
203
- return [
204
- {
205
- tag: "link",
206
- attrs: {
207
- rel: "stylesheet",
208
- href
209
- },
210
- injectTo: "head"
211
- }
212
- ];
213
- }
214
- },
215
- async generateBundle() {
216
- if (!isBuildCommand) return;
217
- if (resolvedMode === "runtime") return;
218
- if (!resolvedExtractModules.length) return;
219
- if (!resolvedConfig) return;
220
- const root = resolvedConfig.root ?? process.cwd();
221
- const fileName = extract?.fileName ?? "typestyles.css";
222
- try {
223
- const css = await (0, import_build_runner.runTypestylesBuild)({
224
- root,
225
- modules: resolvedExtractModules
226
- });
227
- this.emitFile({
228
- type: "asset",
229
- fileName,
230
- source: css
231
- });
232
- } catch (err) {
233
- this.error(
234
- `[typestyles] Failed to extract CSS: ${err instanceof Error ? err.message : String(err)}`
235
- );
236
- }
237
- }
238
- };
133
+ return {
134
+ code: hmrImports + overrideBootstrap + code + hmrCode,
135
+ map: null
136
+ };
137
+ },
138
+ transformIndexHtml: {
139
+ order: "pre",
140
+ handler(html) {
141
+ if (resolvedExtractModules.length === 0) return;
142
+ if (resolvedMode === "runtime") return;
143
+ if (!resolvedConfig) return;
144
+ const fileName = extract?.fileName ?? "typestyles.css";
145
+ const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
146
+ if (htmlLinksTypestylesCss(html, href, fileName)) return;
147
+ return [{
148
+ tag: "link",
149
+ attrs: {
150
+ rel: "stylesheet",
151
+ href
152
+ },
153
+ injectTo: "head"
154
+ }];
155
+ }
156
+ },
157
+ async generateBundle() {
158
+ if (!isBuildCommand) return;
159
+ if (resolvedMode === "runtime") return;
160
+ if (!resolvedExtractModules.length) return;
161
+ if (!resolvedConfig) return;
162
+ const root = resolvedConfig.root ?? process.cwd();
163
+ const fileName = extract?.fileName ?? "typestyles.css";
164
+ try {
165
+ const css = await (0, _typestyles_build_runner.runTypestylesBuild)({
166
+ root,
167
+ modules: resolvedExtractModules
168
+ });
169
+ this.emitFile({
170
+ type: "asset",
171
+ fileName,
172
+ source: css
173
+ });
174
+ } catch (err) {
175
+ this.error(`[typestyles] Failed to extract CSS: ${err instanceof Error ? err.message : String(err)}`);
176
+ }
177
+ }
178
+ };
239
179
  }
240
- // Annotate the CommonJS export names for ESM import in node:
241
- 0 && (module.exports = {
242
- DEFAULT_EXTRACT_MODULE_CANDIDATES,
243
- discoverDefaultExtractModules,
244
- extractNamespaces,
245
- htmlLinksTypestylesCss,
246
- moduleNeedsOverrideHmr,
247
- resolveTypestylesCssHref
180
+ //#endregion
181
+ Object.defineProperty(exports, "DEFAULT_EXTRACT_MODULE_CANDIDATES", {
182
+ enumerable: true,
183
+ get: function() {
184
+ return _typestyles_build_runner.DEFAULT_EXTRACT_MODULE_CANDIDATES;
185
+ }
248
186
  });
187
+ exports.default = typestylesPlugin;
188
+ Object.defineProperty(exports, "discoverDefaultExtractModules", {
189
+ enumerable: true,
190
+ get: function() {
191
+ return _typestyles_build_runner.discoverDefaultExtractModules;
192
+ }
193
+ });
194
+ Object.defineProperty(exports, "extractNamespaces", {
195
+ enumerable: true,
196
+ get: function() {
197
+ return _typestyles_build_runner.extractNamespaces;
198
+ }
199
+ });
200
+ exports.htmlLinksTypestylesCss = htmlLinksTypestylesCss;
201
+ Object.defineProperty(exports, "moduleNeedsOverrideHmr", {
202
+ enumerable: true,
203
+ get: function() {
204
+ return _typestyles_build_runner.moduleNeedsOverrideHmr;
205
+ }
206
+ });
207
+ exports.resolveTypestylesCssHref = resolveTypestylesCssHref;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { Plugin } from 'vite';
2
- import { TypestylesIntegrationMode, TypestylesExtractOptions } from '@typestyles/build-runner';
3
- export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr } from '@typestyles/build-runner';
4
-
1
+ import { Plugin } from "vite";
2
+ import { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, TypestylesIntegrationMode, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr } from "@typestyles/build-runner";
3
+ //#region src/index.d.ts
5
4
  /**
6
5
  * Regex patterns to extract namespace strings from typestyles API calls.
7
6
  *
@@ -15,39 +14,38 @@ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDe
15
14
  * global.rule('body', ...) → prefix "body"
16
15
  * global.fontFace('Inter', ...) → prefix "font-face:Inter"
17
16
  */
18
- interface TypestylesPluginOptions {
19
- /**
20
- * When true (default), fail the build if the same logical `styles.component` / `styles.class`
21
- * namespace appears in more than one module. Set to `false` to skip this check.
22
- */
23
- warnDuplicates?: boolean;
24
- /**
25
- * Mode for typestyles integration:
26
- * - `"runtime"`: HMR only, no build-time extraction.
27
- * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
28
- * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
29
- *
30
- * When omitted and at least one extraction module is resolved (explicit `extract.modules`, or a
31
- * discovered convention entry file), defaults to `"build"`: `vite dev` keeps runtime
32
- * injection + HMR (runtime is only disabled during `vite build`), serves the same extracted CSS
33
- * at `extract.fileName` so `<link href="/typestyles.css">` is valid (avoids SPA fallback
34
- * returning HTML for that URL), and production emits the CSS file. If no modules are resolved,
35
- * defaults to `"runtime"`.
36
- */
37
- mode?: TypestylesIntegrationMode;
38
- /**
39
- * Options for build-time CSS extraction when mode is "build" or "hybrid".
40
- *
41
- * Omitted entirely: discover a convention entry under the project root (see
42
- * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
43
- */
44
- extract?: TypestylesExtractOptions;
17
+ export interface TypestylesPluginOptions {
18
+ /**
19
+ * When true (default), fail the build if the same logical `styles.component` / `styles.class`
20
+ * namespace appears in more than one module. Set to `false` to skip this check.
21
+ */
22
+ warnDuplicates?: boolean;
23
+ /**
24
+ * Mode for typestyles integration:
25
+ * - `"runtime"`: HMR only, no build-time extraction.
26
+ * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
27
+ * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
28
+ *
29
+ * When omitted and at least one extraction module is resolved (explicit `extract.modules`, or a
30
+ * discovered convention entry file), defaults to `"build"`: `vite dev` keeps runtime
31
+ * injection + HMR (runtime is only disabled during `vite build`), serves the same extracted CSS
32
+ * at `extract.fileName` so `<link href="/typestyles.css">` is valid (avoids SPA fallback
33
+ * returning HTML for that URL), and production emits the CSS file. If no modules are resolved,
34
+ * defaults to `"runtime"`.
35
+ */
36
+ mode?: TypestylesIntegrationMode;
37
+ /**
38
+ * Options for build-time CSS extraction when mode is "build" or "hybrid".
39
+ *
40
+ * Omitted entirely: discover a convention entry under the project root (see
41
+ * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
42
+ */
43
+ extract?: TypestylesExtractOptions;
45
44
  }
46
45
  /** Public URL path for the extracted CSS asset (respects Vite `base`). */
47
- declare function resolveTypestylesCssHref(base: string, fileName: string): string;
46
+ export declare function resolveTypestylesCssHref(base: string, fileName: string): string;
48
47
  /** True when `html` already links the extracted stylesheet (avoids duplicate injection). */
49
- declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
50
-
48
+ export declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
51
49
  /**
52
50
  * Vite plugin for typestyles HMR support.
53
51
  *
@@ -56,6 +54,6 @@ declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName:
56
54
  * before re-execution. Files may import from a local re-export such as `./typestyles` rather
57
55
  * than `from 'typestyles'` directly — we key off API call patterns in the source, not the import path.
58
56
  */
59
- declare function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
60
-
61
- export { type TypestylesPluginOptions, typestylesPlugin as default, htmlLinksTypestylesCss, resolveTypestylesCssHref };
57
+ export default function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
58
+ //#endregion
59
+ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { Plugin } from 'vite';
2
- import { TypestylesIntegrationMode, TypestylesExtractOptions } from '@typestyles/build-runner';
3
- export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr } from '@typestyles/build-runner';
4
-
1
+ import { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, TypestylesIntegrationMode, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr } from "@typestyles/build-runner";
2
+ import { Plugin } from "vite";
3
+ //#region src/index.d.ts
5
4
  /**
6
5
  * Regex patterns to extract namespace strings from typestyles API calls.
7
6
  *
@@ -15,39 +14,38 @@ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDe
15
14
  * global.rule('body', ...) → prefix "body"
16
15
  * global.fontFace('Inter', ...) → prefix "font-face:Inter"
17
16
  */
18
- interface TypestylesPluginOptions {
19
- /**
20
- * When true (default), fail the build if the same logical `styles.component` / `styles.class`
21
- * namespace appears in more than one module. Set to `false` to skip this check.
22
- */
23
- warnDuplicates?: boolean;
24
- /**
25
- * Mode for typestyles integration:
26
- * - `"runtime"`: HMR only, no build-time extraction.
27
- * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
28
- * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
29
- *
30
- * When omitted and at least one extraction module is resolved (explicit `extract.modules`, or a
31
- * discovered convention entry file), defaults to `"build"`: `vite dev` keeps runtime
32
- * injection + HMR (runtime is only disabled during `vite build`), serves the same extracted CSS
33
- * at `extract.fileName` so `<link href="/typestyles.css">` is valid (avoids SPA fallback
34
- * returning HTML for that URL), and production emits the CSS file. If no modules are resolved,
35
- * defaults to `"runtime"`.
36
- */
37
- mode?: TypestylesIntegrationMode;
38
- /**
39
- * Options for build-time CSS extraction when mode is "build" or "hybrid".
40
- *
41
- * Omitted entirely: discover a convention entry under the project root (see
42
- * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
43
- */
44
- extract?: TypestylesExtractOptions;
17
+ export interface TypestylesPluginOptions {
18
+ /**
19
+ * When true (default), fail the build if the same logical `styles.component` / `styles.class`
20
+ * namespace appears in more than one module. Set to `false` to skip this check.
21
+ */
22
+ warnDuplicates?: boolean;
23
+ /**
24
+ * Mode for typestyles integration:
25
+ * - `"runtime"`: HMR only, no build-time extraction.
26
+ * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
27
+ * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
28
+ *
29
+ * When omitted and at least one extraction module is resolved (explicit `extract.modules`, or a
30
+ * discovered convention entry file), defaults to `"build"`: `vite dev` keeps runtime
31
+ * injection + HMR (runtime is only disabled during `vite build`), serves the same extracted CSS
32
+ * at `extract.fileName` so `<link href="/typestyles.css">` is valid (avoids SPA fallback
33
+ * returning HTML for that URL), and production emits the CSS file. If no modules are resolved,
34
+ * defaults to `"runtime"`.
35
+ */
36
+ mode?: TypestylesIntegrationMode;
37
+ /**
38
+ * Options for build-time CSS extraction when mode is "build" or "hybrid".
39
+ *
40
+ * Omitted entirely: discover a convention entry under the project root (see
41
+ * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
42
+ */
43
+ extract?: TypestylesExtractOptions;
45
44
  }
46
45
  /** Public URL path for the extracted CSS asset (respects Vite `base`). */
47
- declare function resolveTypestylesCssHref(base: string, fileName: string): string;
46
+ export declare function resolveTypestylesCssHref(base: string, fileName: string): string;
48
47
  /** True when `html` already links the extracted stylesheet (avoids duplicate injection). */
49
- declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
50
-
48
+ export declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
51
49
  /**
52
50
  * Vite plugin for typestyles HMR support.
53
51
  *
@@ -56,6 +54,6 @@ declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName:
56
54
  * before re-execution. Files may import from a local re-export such as `./typestyles` rather
57
55
  * than `from 'typestyles'` directly — we key off API call patterns in the source, not the import path.
58
56
  */
59
- declare function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
60
-
61
- export { type TypestylesPluginOptions, typestylesPlugin as default, htmlLinksTypestylesCss, resolveTypestylesCssHref };
57
+ export default function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
58
+ //#endregion
59
+ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr };
package/dist/index.js CHANGED
@@ -1,228 +1,177 @@
1
- // src/index.ts
2
- import { resolve as resolvePath } from "path";
3
- import {
4
- extractNamespaces,
5
- moduleNeedsOverrideHmr,
6
- reportDuplicateNamespaces,
7
- resolveExtractMode,
8
- resolveExtractModules,
9
- runTypestylesBuild
10
- } from "@typestyles/build-runner";
11
- import {
12
- DEFAULT_EXTRACT_MODULE_CANDIDATES,
13
- discoverDefaultExtractModules
14
- } from "@typestyles/build-runner";
15
- import { moduleNeedsOverrideHmr as moduleNeedsOverrideHmr2 } from "@typestyles/build-runner";
1
+ import { resolve } from "node:path";
2
+ import { DEFAULT_EXTRACT_MODULE_CANDIDATES, discoverDefaultExtractModules, extractNamespaces, moduleNeedsOverrideHmr, moduleNeedsOverrideHmr as moduleNeedsOverrideHmr$1, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild } from "@typestyles/build-runner";
3
+ //#region src/index.ts
16
4
  function resolveExtractModulesForVite(root, extract) {
17
- return resolveExtractModules(root, extract);
5
+ return resolveExtractModules(root, extract);
18
6
  }
19
7
  function resolveTypestylesCssHref(base, fileName) {
20
- const normalizedFileName = fileName.replace(/^\//, "");
21
- const normalizedBase = base.replace(/\/$/, "") || "";
22
- if (normalizedBase === "" || normalizedBase === "/") {
23
- return `/${normalizedFileName}`;
24
- }
25
- return `${normalizedBase}/${normalizedFileName}`;
8
+ const normalizedFileName = fileName.replace(/^\//, "");
9
+ const normalizedBase = base.replace(/\/$/, "") || "";
10
+ if (normalizedBase === "" || normalizedBase === "/") return `/${normalizedFileName}`;
11
+ return `${normalizedBase}/${normalizedFileName}`;
26
12
  }
27
13
  function htmlLinksTypestylesCss(html, cssHref, fileName) {
28
- const bareName = fileName.replace(/^\//, "");
29
- const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
30
- const hrefPattern = /\bhref=["']([^"']+)["']/i;
31
- for (const match of html.matchAll(linkPattern)) {
32
- const hrefMatch = match[0].match(hrefPattern);
33
- const href = hrefMatch?.[1];
34
- if (!href) continue;
35
- if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) {
36
- return true;
37
- }
38
- }
39
- return false;
14
+ const bareName = fileName.replace(/^\//, "");
15
+ const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
16
+ const hrefPattern = /\bhref=["']([^"']+)["']/i;
17
+ for (const match of html.matchAll(linkPattern)) {
18
+ const href = match[0].match(hrefPattern)?.[1];
19
+ if (!href) continue;
20
+ if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) return true;
21
+ }
22
+ return false;
40
23
  }
41
24
  function typestylesPlugin(options = {}) {
42
- const { warnDuplicates = true, extract } = options;
43
- let resolvedExtractModules = [];
44
- let resolvedMode = "runtime";
45
- const moduleNamespaces = /* @__PURE__ */ new Map();
46
- let resolvedConfig = null;
47
- let isBuildCommand = false;
48
- let isServe = false;
49
- let devExtractCss = null;
50
- let devExtractInFlight = null;
51
- return {
52
- name: "typestyles",
53
- enforce: "pre",
54
- config(config, env) {
55
- isBuildCommand = env.command === "build";
56
- const root = resolvePath(config.root ?? process.cwd());
57
- resolvedExtractModules = resolveExtractModulesForVite(root, extract);
58
- resolvedMode = resolveExtractMode(options.mode, resolvedExtractModules);
59
- if (env.command === "build" && (resolvedMode === "build" || resolvedMode === "hybrid")) {
60
- config.define = {
61
- ...config.define ?? {},
62
- // Inlined by the bundler so typestyles sheet skips creating <style> in production
63
- __TYPESTYLES_RUNTIME_DISABLED__: JSON.stringify("true")
64
- };
65
- }
66
- return config;
67
- },
68
- configResolved(config) {
69
- resolvedConfig = config;
70
- isServe = config.command === "serve";
71
- },
72
- configureServer(server) {
73
- if (resolvedExtractModules.length === 0) return;
74
- if (resolvedMode === "runtime") return;
75
- const fileName = extract?.fileName ?? "typestyles.css";
76
- const invalidateDevExtract = () => {
77
- devExtractCss = null;
78
- devExtractInFlight = null;
79
- };
80
- server.watcher.on("change", invalidateDevExtract);
81
- server.watcher.on("add", invalidateDevExtract);
82
- server.watcher.on("unlink", invalidateDevExtract);
83
- server.middlewares.use(async (req, res, next) => {
84
- if (req.method !== "GET" && req.method !== "HEAD") {
85
- next();
86
- return;
87
- }
88
- const config = resolvedConfig;
89
- if (!config) {
90
- next();
91
- return;
92
- }
93
- const url = req.url?.split("?")[0] ?? "";
94
- const base = config.base.replace(/\/$/, "") || "";
95
- const expectedPath = base === "" || base === "/" ? `/${fileName.replace(/^\//, "")}` : `${base}/${fileName.replace(/^\//, "")}`;
96
- if (url !== expectedPath) {
97
- next();
98
- return;
99
- }
100
- const root = config.root ?? process.cwd();
101
- try {
102
- if (devExtractCss !== null) {
103
- res.statusCode = 200;
104
- res.setHeader("Content-Type", "text/css; charset=utf-8");
105
- res.setHeader("Cache-Control", "no-cache");
106
- res.end(devExtractCss);
107
- return;
108
- }
109
- if (!devExtractInFlight) {
110
- devExtractInFlight = runTypestylesBuild({
111
- root,
112
- modules: resolvedExtractModules
113
- }).then((css2) => {
114
- devExtractCss = css2;
115
- return css2;
116
- }).finally(() => {
117
- devExtractInFlight = null;
118
- });
119
- }
120
- const css = await devExtractInFlight;
121
- res.statusCode = 200;
122
- res.setHeader("Content-Type", "text/css; charset=utf-8");
123
- res.setHeader("Cache-Control", "no-cache");
124
- res.end(css);
125
- } catch (err) {
126
- next(err);
127
- }
128
- });
129
- },
130
- transform(code, id) {
131
- if (!/\.[jt]sx?$/.test(id)) return null;
132
- if (id.includes("node_modules")) return null;
133
- const { keys, prefixes } = extractNamespaces(code);
134
- const overrideHmr = moduleNeedsOverrideHmr(code);
135
- if (keys.length === 0 && prefixes.length === 0 && !overrideHmr) return null;
136
- if (warnDuplicates && prefixes.length > 0) {
137
- reportDuplicateNamespaces(moduleNamespaces, id, prefixes, this);
138
- }
139
- if (keys.length > 0 || prefixes.length > 0) {
140
- moduleNamespaces.set(id, { keys, prefixes });
141
- }
142
- if (!isServe) {
143
- return null;
144
- }
145
- const keysJSON = JSON.stringify(keys);
146
- const prefixesJSON = JSON.stringify(prefixes);
147
- const hmrImports = overrideHmr ? `import { invalidateKeys as __typestylesInvalidateKeys, createOverrideHmrSlot as __tsCreateOvHmr } from 'typestyles/hmr';
148
- ` : `import { invalidateKeys as __typestylesInvalidateKeys } from 'typestyles/hmr';
149
- `;
150
- const overrideBootstrap = overrideHmr ? `const __tsOvHmr = __tsCreateOvHmr();
151
- __tsOvHmr.activate();
152
- ` : "";
153
- const overrideTeardown = overrideHmr ? `
154
- __tsOvHmr.deactivate();
155
- ` : "";
156
- const disposeBody = [
157
- keys.length > 0 || prefixes.length > 0 ? `__typestylesInvalidateKeys(${keysJSON}, ${prefixesJSON});` : null,
158
- overrideHmr ? `__tsOvHmr.dispose();` : null
159
- ].filter(Boolean).join("\n ");
160
- const hmrCode = `${overrideTeardown}
25
+ const { warnDuplicates = true, extract } = options;
26
+ let resolvedExtractModules = [];
27
+ let resolvedMode = "runtime";
28
+ const moduleNamespaces = new Map();
29
+ let resolvedConfig = null;
30
+ let isBuildCommand = false;
31
+ let isServe = false;
32
+ let devExtractCss = null;
33
+ let devExtractInFlight = null;
34
+ return {
35
+ name: "typestyles",
36
+ enforce: "pre",
37
+ config(config, env) {
38
+ isBuildCommand = env.command === "build";
39
+ resolvedExtractModules = resolveExtractModulesForVite(resolve(config.root ?? process.cwd()), extract);
40
+ resolvedMode = resolveExtractMode(options.mode, resolvedExtractModules);
41
+ if (env.command === "build" && (resolvedMode === "build" || resolvedMode === "hybrid")) config.define = {
42
+ ...config.define ?? {},
43
+ __TYPESTYLES_RUNTIME_DISABLED__: JSON.stringify("true")
44
+ };
45
+ return config;
46
+ },
47
+ configResolved(config) {
48
+ resolvedConfig = config;
49
+ isServe = config.command === "serve";
50
+ },
51
+ configureServer(server) {
52
+ if (resolvedExtractModules.length === 0) return;
53
+ if (resolvedMode === "runtime") return;
54
+ const fileName = extract?.fileName ?? "typestyles.css";
55
+ const invalidateDevExtract = () => {
56
+ devExtractCss = null;
57
+ devExtractInFlight = null;
58
+ };
59
+ server.watcher.on("change", invalidateDevExtract);
60
+ server.watcher.on("add", invalidateDevExtract);
61
+ server.watcher.on("unlink", invalidateDevExtract);
62
+ server.middlewares.use(async (req, res, next) => {
63
+ if (req.method !== "GET" && req.method !== "HEAD") {
64
+ next();
65
+ return;
66
+ }
67
+ const config = resolvedConfig;
68
+ if (!config) {
69
+ next();
70
+ return;
71
+ }
72
+ const url = req.url?.split("?")[0] ?? "";
73
+ const base = config.base.replace(/\/$/, "") || "";
74
+ if (url !== (base === "" || base === "/" ? `/${fileName.replace(/^\//, "")}` : `${base}/${fileName.replace(/^\//, "")}`)) {
75
+ next();
76
+ return;
77
+ }
78
+ const root = config.root ?? process.cwd();
79
+ try {
80
+ if (devExtractCss !== null) {
81
+ res.statusCode = 200;
82
+ res.setHeader("Content-Type", "text/css; charset=utf-8");
83
+ res.setHeader("Cache-Control", "no-cache");
84
+ res.end(devExtractCss);
85
+ return;
86
+ }
87
+ if (!devExtractInFlight) devExtractInFlight = runTypestylesBuild({
88
+ root,
89
+ modules: resolvedExtractModules
90
+ }).then((css) => {
91
+ devExtractCss = css;
92
+ return css;
93
+ }).finally(() => {
94
+ devExtractInFlight = null;
95
+ });
96
+ const css = await devExtractInFlight;
97
+ res.statusCode = 200;
98
+ res.setHeader("Content-Type", "text/css; charset=utf-8");
99
+ res.setHeader("Cache-Control", "no-cache");
100
+ res.end(css);
101
+ } catch (err) {
102
+ next(err);
103
+ }
104
+ });
105
+ },
106
+ transform(code, id) {
107
+ if (!/\.[jt]sx?$/.test(id)) return null;
108
+ if (id.includes("node_modules")) return null;
109
+ const { keys, prefixes } = extractNamespaces(code);
110
+ const overrideHmr = moduleNeedsOverrideHmr$1(code);
111
+ if (keys.length === 0 && prefixes.length === 0 && !overrideHmr) return null;
112
+ if (warnDuplicates && prefixes.length > 0) reportDuplicateNamespaces(moduleNamespaces, id, prefixes, this);
113
+ if (keys.length > 0 || prefixes.length > 0) moduleNamespaces.set(id, {
114
+ keys,
115
+ prefixes
116
+ });
117
+ if (!isServe) return null;
118
+ const keysJSON = JSON.stringify(keys);
119
+ const prefixesJSON = JSON.stringify(prefixes);
120
+ const hmrImports = overrideHmr ? `import { invalidateKeys as __typestylesInvalidateKeys, createOverrideHmrSlot as __tsCreateOvHmr } from 'typestyles/hmr';\n` : `import { invalidateKeys as __typestylesInvalidateKeys } from 'typestyles/hmr';\n`;
121
+ const overrideBootstrap = overrideHmr ? `const __tsOvHmr = __tsCreateOvHmr();\n__tsOvHmr.activate();\n` : "";
122
+ const hmrCode = `${overrideHmr ? `\n__tsOvHmr.deactivate();\n` : ""}
161
123
  if (import.meta.hot) {
162
124
  import.meta.hot.accept();
163
125
  import.meta.hot.dispose(() => {
164
- ${disposeBody}
126
+ ${[keys.length > 0 || prefixes.length > 0 ? `__typestylesInvalidateKeys(${keysJSON}, ${prefixesJSON});` : null, overrideHmr ? `__tsOvHmr.dispose();` : null].filter(Boolean).join("\n ")}
165
127
  });
166
128
  }`;
167
- return {
168
- code: hmrImports + overrideBootstrap + code + hmrCode,
169
- map: null
170
- };
171
- },
172
- transformIndexHtml: {
173
- order: "pre",
174
- handler(html) {
175
- if (resolvedExtractModules.length === 0) return;
176
- if (resolvedMode === "runtime") return;
177
- if (!resolvedConfig) return;
178
- const fileName = extract?.fileName ?? "typestyles.css";
179
- const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
180
- if (htmlLinksTypestylesCss(html, href, fileName)) {
181
- return;
182
- }
183
- return [
184
- {
185
- tag: "link",
186
- attrs: {
187
- rel: "stylesheet",
188
- href
189
- },
190
- injectTo: "head"
191
- }
192
- ];
193
- }
194
- },
195
- async generateBundle() {
196
- if (!isBuildCommand) return;
197
- if (resolvedMode === "runtime") return;
198
- if (!resolvedExtractModules.length) return;
199
- if (!resolvedConfig) return;
200
- const root = resolvedConfig.root ?? process.cwd();
201
- const fileName = extract?.fileName ?? "typestyles.css";
202
- try {
203
- const css = await runTypestylesBuild({
204
- root,
205
- modules: resolvedExtractModules
206
- });
207
- this.emitFile({
208
- type: "asset",
209
- fileName,
210
- source: css
211
- });
212
- } catch (err) {
213
- this.error(
214
- `[typestyles] Failed to extract CSS: ${err instanceof Error ? err.message : String(err)}`
215
- );
216
- }
217
- }
218
- };
129
+ return {
130
+ code: hmrImports + overrideBootstrap + code + hmrCode,
131
+ map: null
132
+ };
133
+ },
134
+ transformIndexHtml: {
135
+ order: "pre",
136
+ handler(html) {
137
+ if (resolvedExtractModules.length === 0) return;
138
+ if (resolvedMode === "runtime") return;
139
+ if (!resolvedConfig) return;
140
+ const fileName = extract?.fileName ?? "typestyles.css";
141
+ const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
142
+ if (htmlLinksTypestylesCss(html, href, fileName)) return;
143
+ return [{
144
+ tag: "link",
145
+ attrs: {
146
+ rel: "stylesheet",
147
+ href
148
+ },
149
+ injectTo: "head"
150
+ }];
151
+ }
152
+ },
153
+ async generateBundle() {
154
+ if (!isBuildCommand) return;
155
+ if (resolvedMode === "runtime") return;
156
+ if (!resolvedExtractModules.length) return;
157
+ if (!resolvedConfig) return;
158
+ const root = resolvedConfig.root ?? process.cwd();
159
+ const fileName = extract?.fileName ?? "typestyles.css";
160
+ try {
161
+ const css = await runTypestylesBuild({
162
+ root,
163
+ modules: resolvedExtractModules
164
+ });
165
+ this.emitFile({
166
+ type: "asset",
167
+ fileName,
168
+ source: css
169
+ });
170
+ } catch (err) {
171
+ this.error(`[typestyles] Failed to extract CSS: ${err instanceof Error ? err.message : String(err)}`);
172
+ }
173
+ }
174
+ };
219
175
  }
220
- export {
221
- DEFAULT_EXTRACT_MODULE_CANDIDATES,
222
- typestylesPlugin as default,
223
- discoverDefaultExtractModules,
224
- extractNamespaces,
225
- htmlLinksTypestylesCss,
226
- moduleNeedsOverrideHmr2 as moduleNeedsOverrideHmr,
227
- resolveTypestylesCssHref
228
- };
176
+ //#endregion
177
+ export { DEFAULT_EXTRACT_MODULE_CANDIDATES, typestylesPlugin as default, discoverDefaultExtractModules, extractNamespaces, htmlLinksTypestylesCss, moduleNeedsOverrideHmr, resolveTypestylesCssHref };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/vite",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Vite plugin for typestyles HMR support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -31,27 +31,24 @@
31
31
  "license": "Apache-2.0",
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/type-styles/typestyles",
34
+ "url": "https://github.com/phthalo-dev/typestyles",
35
35
  "directory": "packages/vite"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "vite": ">=5.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "eslint": "^9.39.2",
42
- "tsup": "^8.0.0",
43
- "typescript": "^5.4.0",
44
- "vite": "^6.0.0",
45
- "vitest": "^3.0.0",
46
- "typestyles": "0.32.0"
41
+ "typescript": "^6.0.0",
42
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
43
+ "vite-plus": "1.3.0",
44
+ "typestyles": "0.32.3"
47
45
  },
48
46
  "dependencies": {
49
- "@typestyles/build-runner": "0.6.1"
47
+ "@typestyles/build-runner": "0.6.3"
50
48
  },
51
49
  "scripts": {
52
- "build": "tsup src/index.ts --format esm,cjs --dts --clean --external typestyles,@typestyles/build-runner",
53
- "test": "vitest run",
54
- "lint": "eslint .",
50
+ "build": "vp pack",
51
+ "test": "vp test run",
55
52
  "typecheck": "tsc --noEmit"
56
53
  }
57
54
  }