@typestyles/vite 0.0.0-unstable.6c696fbd20ce → 0.0.0-unstable.6fa3e9bf6d93
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 +5 -7
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +5 -7
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,6 @@ __export(index_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
var import_build_runner = require("@typestyles/build-runner");
|
|
28
|
-
var STYLES_CREATE_RE = /styles\.create\(\s*['"]([^'"]+)['"]/g;
|
|
29
28
|
var STYLES_COMPONENT_RE = /styles\.component\(\s*['"]([^'"]+)['"]/g;
|
|
30
29
|
var TOKENS_CREATE_RE = /tokens\.create\(\s*['"]([^'"]+)['"]/g;
|
|
31
30
|
var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
|
|
@@ -36,9 +35,6 @@ var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles[
|
|
|
36
35
|
function extractNamespaces(code) {
|
|
37
36
|
const keys = [];
|
|
38
37
|
const prefixes = [];
|
|
39
|
-
for (const match of code.matchAll(STYLES_CREATE_RE)) {
|
|
40
|
-
prefixes.push(`.${match[1]}-`);
|
|
41
|
-
}
|
|
42
38
|
for (const match of code.matchAll(STYLES_COMPONENT_RE)) {
|
|
43
39
|
prefixes.push(`.${match[1]}-`);
|
|
44
40
|
}
|
|
@@ -60,7 +56,9 @@ function extractNamespaces(code) {
|
|
|
60
56
|
return { keys, prefixes };
|
|
61
57
|
}
|
|
62
58
|
function typestylesPlugin(options = {}) {
|
|
63
|
-
const { warnDuplicates = true,
|
|
59
|
+
const { warnDuplicates = true, extract } = options;
|
|
60
|
+
const extractModules = extract?.modules ?? [];
|
|
61
|
+
const mode = options.mode ?? (extractModules.length > 0 ? "build" : "runtime");
|
|
64
62
|
const moduleNamespaces = /* @__PURE__ */ new Map();
|
|
65
63
|
let resolvedConfig = null;
|
|
66
64
|
let isBuildCommand = false;
|
|
@@ -120,14 +118,14 @@ if (import.meta.hot) {
|
|
|
120
118
|
async generateBundle() {
|
|
121
119
|
if (!isBuildCommand) return;
|
|
122
120
|
if (mode === "runtime") return;
|
|
123
|
-
if (!extract || !
|
|
121
|
+
if (!extract || !extractModules.length) return;
|
|
124
122
|
if (!resolvedConfig) return;
|
|
125
123
|
const root = resolvedConfig.root ?? process.cwd();
|
|
126
124
|
const fileName = extract.fileName ?? "typestyles.css";
|
|
127
125
|
try {
|
|
128
126
|
const css = await (0, import_build_runner.runTypestylesBuild)({
|
|
129
127
|
root,
|
|
130
|
-
modules:
|
|
128
|
+
modules: extractModules
|
|
131
129
|
});
|
|
132
130
|
this.emitFile({
|
|
133
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"
|
|
20
|
-
* - "build"
|
|
21
|
-
* - "hybrid"
|
|
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"
|
|
20
|
-
* - "build"
|
|
21
|
-
* - "hybrid"
|
|
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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { runTypestylesBuild } from "@typestyles/build-runner";
|
|
3
|
-
var STYLES_CREATE_RE = /styles\.create\(\s*['"]([^'"]+)['"]/g;
|
|
4
3
|
var STYLES_COMPONENT_RE = /styles\.component\(\s*['"]([^'"]+)['"]/g;
|
|
5
4
|
var TOKENS_CREATE_RE = /tokens\.create\(\s*['"]([^'"]+)['"]/g;
|
|
6
5
|
var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
|
|
@@ -11,9 +10,6 @@ var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles[
|
|
|
11
10
|
function extractNamespaces(code) {
|
|
12
11
|
const keys = [];
|
|
13
12
|
const prefixes = [];
|
|
14
|
-
for (const match of code.matchAll(STYLES_CREATE_RE)) {
|
|
15
|
-
prefixes.push(`.${match[1]}-`);
|
|
16
|
-
}
|
|
17
13
|
for (const match of code.matchAll(STYLES_COMPONENT_RE)) {
|
|
18
14
|
prefixes.push(`.${match[1]}-`);
|
|
19
15
|
}
|
|
@@ -35,7 +31,9 @@ function extractNamespaces(code) {
|
|
|
35
31
|
return { keys, prefixes };
|
|
36
32
|
}
|
|
37
33
|
function typestylesPlugin(options = {}) {
|
|
38
|
-
const { warnDuplicates = true,
|
|
34
|
+
const { warnDuplicates = true, extract } = options;
|
|
35
|
+
const extractModules = extract?.modules ?? [];
|
|
36
|
+
const mode = options.mode ?? (extractModules.length > 0 ? "build" : "runtime");
|
|
39
37
|
const moduleNamespaces = /* @__PURE__ */ new Map();
|
|
40
38
|
let resolvedConfig = null;
|
|
41
39
|
let isBuildCommand = false;
|
|
@@ -95,14 +93,14 @@ if (import.meta.hot) {
|
|
|
95
93
|
async generateBundle() {
|
|
96
94
|
if (!isBuildCommand) return;
|
|
97
95
|
if (mode === "runtime") return;
|
|
98
|
-
if (!extract || !
|
|
96
|
+
if (!extract || !extractModules.length) return;
|
|
99
97
|
if (!resolvedConfig) return;
|
|
100
98
|
const root = resolvedConfig.root ?? process.cwd();
|
|
101
99
|
const fileName = extract.fileName ?? "typestyles.css";
|
|
102
100
|
try {
|
|
103
101
|
const css = await runTypestylesBuild({
|
|
104
102
|
root,
|
|
105
|
-
modules:
|
|
103
|
+
modules: extractModules
|
|
106
104
|
});
|
|
107
105
|
this.emitFile({
|
|
108
106
|
type: "asset",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typestyles/vite",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.6fa3e9bf6d93",
|
|
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.
|
|
44
|
+
"typestyles": "0.0.0-unstable.6fa3e9bf6d93",
|
|
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.
|
|
49
|
+
"@typestyles/build-runner": "0.0.0-unstable.6fa3e9bf6d93"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external typestyles,@typestyles/build-runner",
|