@typestyles/vite 0.0.0-unstable.eee07e5f0c37 → 0.0.0-unstable.f7b9ed22e456

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.cjs CHANGED
@@ -56,7 +56,9 @@ function extractNamespaces(code) {
56
56
  return { keys, prefixes };
57
57
  }
58
58
  function typestylesPlugin(options = {}) {
59
- const { warnDuplicates = true, mode = "runtime", extract } = options;
59
+ const { warnDuplicates = true, extract } = options;
60
+ const extractModules = extract?.modules ?? [];
61
+ const mode = options.mode ?? (extractModules.length > 0 ? "build" : "runtime");
60
62
  const moduleNamespaces = /* @__PURE__ */ new Map();
61
63
  let resolvedConfig = null;
62
64
  let isBuildCommand = false;
@@ -116,14 +118,14 @@ if (import.meta.hot) {
116
118
  async generateBundle() {
117
119
  if (!isBuildCommand) return;
118
120
  if (mode === "runtime") return;
119
- if (!extract || !extract.modules.length) return;
121
+ if (!extract || !extractModules.length) return;
120
122
  if (!resolvedConfig) return;
121
123
  const root = resolvedConfig.root ?? process.cwd();
122
124
  const fileName = extract.fileName ?? "typestyles.css";
123
125
  try {
124
126
  const css = await (0, import_build_runner.runTypestylesBuild)({
125
127
  root,
126
- modules: extract.modules
128
+ modules: extractModules
127
129
  });
128
130
  this.emitFile({
129
131
  type: "asset",
package/dist/index.d.cts CHANGED
@@ -16,9 +16,13 @@ interface TypestylesPluginOptions {
16
16
  warnDuplicates?: boolean;
17
17
  /**
18
18
  * Mode for typestyles integration:
19
- * - "runtime" (default): HMR only, no build-time extraction.
20
- * - "build": emit a static CSS asset during build using typestyles/build.
21
- * - "hybrid": both runtime injection and build-time CSS asset.
19
+ * - `"runtime"`: HMR only, no build-time extraction.
20
+ * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
21
+ * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
22
+ *
23
+ * When omitted and `extract.modules` is non-empty, defaults to `"build"`: `vite dev` keeps
24
+ * runtime injection + HMR (runtime is only disabled during `vite build`), and production emits
25
+ * the CSS file. With no `extract` config, defaults to `"runtime"`.
22
26
  */
23
27
  mode?: 'runtime' | 'build' | 'hybrid';
24
28
  /**
package/dist/index.d.ts CHANGED
@@ -16,9 +16,13 @@ interface TypestylesPluginOptions {
16
16
  warnDuplicates?: boolean;
17
17
  /**
18
18
  * Mode for typestyles integration:
19
- * - "runtime" (default): HMR only, no build-time extraction.
20
- * - "build": emit a static CSS asset during build using typestyles/build.
21
- * - "hybrid": both runtime injection and build-time CSS asset.
19
+ * - `"runtime"`: HMR only, no build-time extraction.
20
+ * - `"build"`: emit a static CSS asset on `vite build` and disable client injection there.
21
+ * - `"hybrid"`: extract on build and keep runtime-compatible behavior.
22
+ *
23
+ * When omitted and `extract.modules` is non-empty, defaults to `"build"`: `vite dev` keeps
24
+ * runtime injection + HMR (runtime is only disabled during `vite build`), and production emits
25
+ * the CSS file. With no `extract` config, defaults to `"runtime"`.
22
26
  */
23
27
  mode?: 'runtime' | 'build' | 'hybrid';
24
28
  /**
package/dist/index.js CHANGED
@@ -31,7 +31,9 @@ function extractNamespaces(code) {
31
31
  return { keys, prefixes };
32
32
  }
33
33
  function typestylesPlugin(options = {}) {
34
- const { warnDuplicates = true, mode = "runtime", extract } = options;
34
+ const { warnDuplicates = true, extract } = options;
35
+ const extractModules = extract?.modules ?? [];
36
+ const mode = options.mode ?? (extractModules.length > 0 ? "build" : "runtime");
35
37
  const moduleNamespaces = /* @__PURE__ */ new Map();
36
38
  let resolvedConfig = null;
37
39
  let isBuildCommand = false;
@@ -91,14 +93,14 @@ if (import.meta.hot) {
91
93
  async generateBundle() {
92
94
  if (!isBuildCommand) return;
93
95
  if (mode === "runtime") return;
94
- if (!extract || !extract.modules.length) return;
96
+ if (!extract || !extractModules.length) return;
95
97
  if (!resolvedConfig) return;
96
98
  const root = resolvedConfig.root ?? process.cwd();
97
99
  const fileName = extract.fileName ?? "typestyles.css";
98
100
  try {
99
101
  const css = await runTypestylesBuild({
100
102
  root,
101
- modules: extract.modules
103
+ modules: extractModules
102
104
  });
103
105
  this.emitFile({
104
106
  type: "asset",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/vite",
3
- "version": "0.0.0-unstable.eee07e5f0c37",
3
+ "version": "0.0.0-unstable.f7b9ed22e456",
4
4
  "description": "Vite plugin for typestyles HMR support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -41,12 +41,12 @@
41
41
  "eslint": "^9.39.2",
42
42
  "tsup": "^8.0.0",
43
43
  "typescript": "^5.4.0",
44
- "typestyles": "0.0.0-unstable.eee07e5f0c37",
44
+ "typestyles": "0.0.0-unstable.f7b9ed22e456",
45
45
  "vite": "^6.0.0",
46
46
  "vitest": "^3.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@typestyles/build-runner": "0.0.0-unstable.eee07e5f0c37"
49
+ "@typestyles/build-runner": "0.0.0-unstable.f7b9ed22e456"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --external typestyles,@typestyles/build-runner",