@typestyles/rollup 0.5.6 → 0.5.7
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 +69 -82
- package/dist/index.d.cts +34 -36
- package/dist/index.d.ts +34 -36
- package/dist/index.js +49 -67
- package/package.json +7 -10
package/dist/index.cjs
CHANGED
|
@@ -1,86 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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: () => typestylesRollupPlugin,
|
|
25
|
-
discoverDefaultExtractModules: () => import_build_runner2.discoverDefaultExtractModules,
|
|
26
|
-
extractNamespaces: () => import_build_runner.extractNamespaces
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
27
4
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var import_build_runner2 = require("@typestyles/build-runner");
|
|
5
|
+
let _typestyles_build_runner = require("@typestyles/build-runner");
|
|
6
|
+
//#region src/index.ts
|
|
31
7
|
function typestylesRollupPlugin(options = {}) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
8
|
+
const { warnDuplicates = true, extract, root = process.cwd() } = options;
|
|
9
|
+
const moduleNamespaces = new Map();
|
|
10
|
+
let resolvedExtractModules = [];
|
|
11
|
+
let resolvedMode = "runtime";
|
|
12
|
+
return {
|
|
13
|
+
name: "typestyles-rollup",
|
|
14
|
+
buildStart() {
|
|
15
|
+
resolvedExtractModules = (0, _typestyles_build_runner.resolveExtractModules)(root, extract);
|
|
16
|
+
resolvedMode = (0, _typestyles_build_runner.resolveExtractMode)(options.mode, resolvedExtractModules);
|
|
17
|
+
},
|
|
18
|
+
transform(code, id) {
|
|
19
|
+
if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) return {
|
|
20
|
+
code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, "\"true\""),
|
|
21
|
+
map: null
|
|
22
|
+
};
|
|
23
|
+
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
24
|
+
if (id.includes("node_modules")) return null;
|
|
25
|
+
if (!_typestyles_build_runner.TYPESTYLES_IMPORT_RE.test(code)) return null;
|
|
26
|
+
const { keys, prefixes } = (0, _typestyles_build_runner.extractNamespaces)(code);
|
|
27
|
+
if (keys.length === 0 && prefixes.length === 0) return null;
|
|
28
|
+
if (warnDuplicates) (0, _typestyles_build_runner.reportDuplicateNamespaces)(moduleNamespaces, id, prefixes, this);
|
|
29
|
+
moduleNamespaces.set(id, {
|
|
30
|
+
keys,
|
|
31
|
+
prefixes
|
|
32
|
+
});
|
|
33
|
+
return null;
|
|
34
|
+
},
|
|
35
|
+
async generateBundle() {
|
|
36
|
+
if (resolvedMode === "runtime") return;
|
|
37
|
+
if (!resolvedExtractModules.length) return;
|
|
38
|
+
try {
|
|
39
|
+
const css = await (0, _typestyles_build_runner.runTypestylesBuild)({
|
|
40
|
+
root,
|
|
41
|
+
modules: resolvedExtractModules
|
|
42
|
+
});
|
|
43
|
+
this.emitFile({
|
|
44
|
+
type: "asset",
|
|
45
|
+
fileName: extract?.fileName ?? "typestyles.css",
|
|
46
|
+
source: css
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
this.error(`[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
80
53
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
Object.defineProperty(exports, "DEFAULT_EXTRACT_MODULE_CANDIDATES", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function() {
|
|
58
|
+
return _typestyles_build_runner.DEFAULT_EXTRACT_MODULE_CANDIDATES;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
exports.default = typestylesRollupPlugin;
|
|
62
|
+
Object.defineProperty(exports, "discoverDefaultExtractModules", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function() {
|
|
65
|
+
return _typestyles_build_runner.discoverDefaultExtractModules;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "extractNamespaces", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function() {
|
|
71
|
+
return _typestyles_build_runner.extractNamespaces;
|
|
72
|
+
}
|
|
86
73
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
root?: string;
|
|
1
|
+
import { Plugin } from "rollup";
|
|
2
|
+
import { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, TypestylesIntegrationMode, discoverDefaultExtractModules, extractNamespaces } from "@typestyles/build-runner";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
export interface TypestylesRollupPluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* When true (default), fail the build if the same logical `styles.component` / `styles.class`
|
|
7
|
+
* namespace appears in more than one module. Set to `false` to skip this check.
|
|
8
|
+
*/
|
|
9
|
+
warnDuplicates?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Integration mode:
|
|
12
|
+
* - `"runtime"` (default when no extraction modules resolve): no static extraction.
|
|
13
|
+
* - `"build"`: emit static CSS and disable runtime insertion.
|
|
14
|
+
* - `"hybrid"`: emit static CSS and keep runtime-compatible behavior.
|
|
15
|
+
*
|
|
16
|
+
* When omitted and at least one extraction module resolves (explicit `extract.modules` or a
|
|
17
|
+
* discovered convention entry), defaults to `"build"`.
|
|
18
|
+
*/
|
|
19
|
+
mode?: TypestylesIntegrationMode;
|
|
20
|
+
/**
|
|
21
|
+
* Build-time extraction options for `"build"` and `"hybrid"` modes.
|
|
22
|
+
*
|
|
23
|
+
* Omitted entirely: discover a convention entry under `root` (see
|
|
24
|
+
* {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
|
|
25
|
+
*/
|
|
26
|
+
extract?: TypestylesExtractOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Project root used to resolve extraction modules and convention discovery.
|
|
29
|
+
* Defaults to `process.cwd()`.
|
|
30
|
+
*/
|
|
31
|
+
root?: string;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
/**
|
|
36
34
|
* Rollup plugin for typestyles runtime + optional static extraction.
|
|
37
35
|
*
|
|
38
36
|
* Rolldown supports Rollup-compatible plugins, so this plugin also works
|
|
39
37
|
* as a starting integration there.
|
|
40
38
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export { type
|
|
39
|
+
export default function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
root?: string;
|
|
1
|
+
import { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, TypestylesIntegrationMode, discoverDefaultExtractModules, extractNamespaces } from "@typestyles/build-runner";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
export interface TypestylesRollupPluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* When true (default), fail the build if the same logical `styles.component` / `styles.class`
|
|
7
|
+
* namespace appears in more than one module. Set to `false` to skip this check.
|
|
8
|
+
*/
|
|
9
|
+
warnDuplicates?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Integration mode:
|
|
12
|
+
* - `"runtime"` (default when no extraction modules resolve): no static extraction.
|
|
13
|
+
* - `"build"`: emit static CSS and disable runtime insertion.
|
|
14
|
+
* - `"hybrid"`: emit static CSS and keep runtime-compatible behavior.
|
|
15
|
+
*
|
|
16
|
+
* When omitted and at least one extraction module resolves (explicit `extract.modules` or a
|
|
17
|
+
* discovered convention entry), defaults to `"build"`.
|
|
18
|
+
*/
|
|
19
|
+
mode?: TypestylesIntegrationMode;
|
|
20
|
+
/**
|
|
21
|
+
* Build-time extraction options for `"build"` and `"hybrid"` modes.
|
|
22
|
+
*
|
|
23
|
+
* Omitted entirely: discover a convention entry under `root` (see
|
|
24
|
+
* {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
|
|
25
|
+
*/
|
|
26
|
+
extract?: TypestylesExtractOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Project root used to resolve extraction modules and convention discovery.
|
|
29
|
+
* Defaults to `process.cwd()`.
|
|
30
|
+
*/
|
|
31
|
+
root?: string;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
/**
|
|
36
34
|
* Rollup plugin for typestyles runtime + optional static extraction.
|
|
37
35
|
*
|
|
38
36
|
* Rolldown supports Rollup-compatible plugins, so this plugin also works
|
|
39
37
|
* as a starting integration there.
|
|
40
38
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export { type
|
|
39
|
+
export default function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces };
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
extractNamespaces,
|
|
4
|
-
reportDuplicateNamespaces,
|
|
5
|
-
resolveExtractMode,
|
|
6
|
-
resolveExtractModules,
|
|
7
|
-
runTypestylesBuild,
|
|
8
|
-
TYPESTYLES_IMPORT_RE
|
|
9
|
-
} from "@typestyles/build-runner";
|
|
10
|
-
import {
|
|
11
|
-
DEFAULT_EXTRACT_MODULE_CANDIDATES,
|
|
12
|
-
discoverDefaultExtractModules
|
|
13
|
-
} from "@typestyles/build-runner";
|
|
1
|
+
import { DEFAULT_EXTRACT_MODULE_CANDIDATES, TYPESTYLES_IMPORT_RE, discoverDefaultExtractModules, extractNamespaces, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild } from "@typestyles/build-runner";
|
|
2
|
+
//#region src/index.ts
|
|
14
3
|
function typestylesRollupPlugin(options = {}) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
4
|
+
const { warnDuplicates = true, extract, root = process.cwd() } = options;
|
|
5
|
+
const moduleNamespaces = new Map();
|
|
6
|
+
let resolvedExtractModules = [];
|
|
7
|
+
let resolvedMode = "runtime";
|
|
8
|
+
return {
|
|
9
|
+
name: "typestyles-rollup",
|
|
10
|
+
buildStart() {
|
|
11
|
+
resolvedExtractModules = resolveExtractModules(root, extract);
|
|
12
|
+
resolvedMode = resolveExtractMode(options.mode, resolvedExtractModules);
|
|
13
|
+
},
|
|
14
|
+
transform(code, id) {
|
|
15
|
+
if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) return {
|
|
16
|
+
code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, "\"true\""),
|
|
17
|
+
map: null
|
|
18
|
+
};
|
|
19
|
+
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
20
|
+
if (id.includes("node_modules")) return null;
|
|
21
|
+
if (!TYPESTYLES_IMPORT_RE.test(code)) return null;
|
|
22
|
+
const { keys, prefixes } = extractNamespaces(code);
|
|
23
|
+
if (keys.length === 0 && prefixes.length === 0) return null;
|
|
24
|
+
if (warnDuplicates) reportDuplicateNamespaces(moduleNamespaces, id, prefixes, this);
|
|
25
|
+
moduleNamespaces.set(id, {
|
|
26
|
+
keys,
|
|
27
|
+
prefixes
|
|
28
|
+
});
|
|
29
|
+
return null;
|
|
30
|
+
},
|
|
31
|
+
async generateBundle() {
|
|
32
|
+
if (resolvedMode === "runtime") return;
|
|
33
|
+
if (!resolvedExtractModules.length) return;
|
|
34
|
+
try {
|
|
35
|
+
const css = await runTypestylesBuild({
|
|
36
|
+
root,
|
|
37
|
+
modules: resolvedExtractModules
|
|
38
|
+
});
|
|
39
|
+
this.emitFile({
|
|
40
|
+
type: "asset",
|
|
41
|
+
fileName: extract?.fileName ?? "typestyles.css",
|
|
42
|
+
source: css
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.error(`[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
63
49
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
typestylesRollupPlugin as default,
|
|
67
|
-
discoverDefaultExtractModules,
|
|
68
|
-
extractNamespaces
|
|
69
|
-
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { DEFAULT_EXTRACT_MODULE_CANDIDATES, typestylesRollupPlugin as default, discoverDefaultExtractModules, extractNamespaces };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typestyles/rollup",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "Rollup and Rolldown plugin for typestyles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -38,20 +38,17 @@
|
|
|
38
38
|
"rollup": ">=4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typestyles/build-runner": "0.6.
|
|
41
|
+
"@typestyles/build-runner": "0.6.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^25.2.1",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"vitest": "^3.0.0",
|
|
49
|
-
"rollup": "^4.0.0"
|
|
45
|
+
"rollup": "^4.0.0",
|
|
46
|
+
"typescript": "^6.0.0",
|
|
47
|
+
"vite-plus": "1.3.0"
|
|
50
48
|
},
|
|
51
49
|
"scripts": {
|
|
52
|
-
"build": "
|
|
53
|
-
"test": "
|
|
54
|
-
"lint": "eslint .",
|
|
50
|
+
"build": "vp pack",
|
|
51
|
+
"test": "vp test run",
|
|
55
52
|
"typecheck": "tsc --noEmit"
|
|
56
53
|
}
|
|
57
54
|
}
|