@typestyles/rollup 0.5.6 → 0.5.8

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
@@ -1,86 +1,73 @@
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: () => 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
- module.exports = __toCommonJS(index_exports);
29
- var import_build_runner = require("@typestyles/build-runner");
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
- const { warnDuplicates = true, extract, root = process.cwd() } = options;
33
- const moduleNamespaces = /* @__PURE__ */ new Map();
34
- let resolvedExtractModules = [];
35
- let resolvedMode = "runtime";
36
- return {
37
- name: "typestyles-rollup",
38
- buildStart() {
39
- resolvedExtractModules = (0, import_build_runner.resolveExtractModules)(root, extract);
40
- resolvedMode = (0, import_build_runner.resolveExtractMode)(options.mode, resolvedExtractModules);
41
- },
42
- transform(code, id) {
43
- if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) {
44
- return {
45
- code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, '"true"'),
46
- map: null
47
- };
48
- }
49
- if (!/\.[jt]sx?$/.test(id)) return null;
50
- if (id.includes("node_modules")) return null;
51
- if (!import_build_runner.TYPESTYLES_IMPORT_RE.test(code)) return null;
52
- const { keys, prefixes } = (0, import_build_runner.extractNamespaces)(code);
53
- if (keys.length === 0 && prefixes.length === 0) return null;
54
- if (warnDuplicates) {
55
- (0, import_build_runner.reportDuplicateNamespaces)(moduleNamespaces, id, prefixes, this);
56
- }
57
- moduleNamespaces.set(id, { keys, prefixes });
58
- return null;
59
- },
60
- async generateBundle() {
61
- if (resolvedMode === "runtime") return;
62
- if (!resolvedExtractModules.length) return;
63
- try {
64
- const css = await (0, import_build_runner.runTypestylesBuild)({
65
- root,
66
- modules: resolvedExtractModules
67
- });
68
- this.emitFile({
69
- type: "asset",
70
- fileName: extract?.fileName ?? "typestyles.css",
71
- source: css
72
- });
73
- } catch (error) {
74
- this.error(
75
- `[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`
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
- // Annotate the CommonJS export names for ESM import in node:
82
- 0 && (module.exports = {
83
- DEFAULT_EXTRACT_MODULE_CANDIDATES,
84
- discoverDefaultExtractModules,
85
- extractNamespaces
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 'rollup';
2
- import { TypestylesIntegrationMode, TypestylesExtractOptions } from '@typestyles/build-runner';
3
- export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces } from '@typestyles/build-runner';
4
-
5
- interface TypestylesRollupPluginOptions {
6
- /**
7
- * When true (default), fail the build if the same logical `styles.component` / `styles.class`
8
- * namespace appears in more than one module. Set to `false` to skip this check.
9
- */
10
- warnDuplicates?: boolean;
11
- /**
12
- * Integration mode:
13
- * - `"runtime"` (default when no extraction modules resolve): no static extraction.
14
- * - `"build"`: emit static CSS and disable runtime insertion.
15
- * - `"hybrid"`: emit static CSS and keep runtime-compatible behavior.
16
- *
17
- * When omitted and at least one extraction module resolves (explicit `extract.modules` or a
18
- * discovered convention entry), defaults to `"build"`.
19
- */
20
- mode?: TypestylesIntegrationMode;
21
- /**
22
- * Build-time extraction options for `"build"` and `"hybrid"` modes.
23
- *
24
- * Omitted entirely: discover a convention entry under `root` (see
25
- * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
26
- */
27
- extract?: TypestylesExtractOptions;
28
- /**
29
- * Project root used to resolve extraction modules and convention discovery.
30
- * Defaults to `process.cwd()`.
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
- declare function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
42
-
43
- export { type TypestylesRollupPluginOptions, typestylesRollupPlugin as default };
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 { Plugin } from 'rollup';
2
- import { TypestylesIntegrationMode, TypestylesExtractOptions } from '@typestyles/build-runner';
3
- export { DEFAULT_EXTRACT_MODULE_CANDIDATES, TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces } from '@typestyles/build-runner';
4
-
5
- interface TypestylesRollupPluginOptions {
6
- /**
7
- * When true (default), fail the build if the same logical `styles.component` / `styles.class`
8
- * namespace appears in more than one module. Set to `false` to skip this check.
9
- */
10
- warnDuplicates?: boolean;
11
- /**
12
- * Integration mode:
13
- * - `"runtime"` (default when no extraction modules resolve): no static extraction.
14
- * - `"build"`: emit static CSS and disable runtime insertion.
15
- * - `"hybrid"`: emit static CSS and keep runtime-compatible behavior.
16
- *
17
- * When omitted and at least one extraction module resolves (explicit `extract.modules` or a
18
- * discovered convention entry), defaults to `"build"`.
19
- */
20
- mode?: TypestylesIntegrationMode;
21
- /**
22
- * Build-time extraction options for `"build"` and `"hybrid"` modes.
23
- *
24
- * Omitted entirely: discover a convention entry under `root` (see
25
- * {@link discoverDefaultExtractModules}); if none exist, stays in runtime-only mode.
26
- */
27
- extract?: TypestylesExtractOptions;
28
- /**
29
- * Project root used to resolve extraction modules and convention discovery.
30
- * Defaults to `process.cwd()`.
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
- declare function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
42
-
43
- export { type TypestylesRollupPluginOptions, typestylesRollupPlugin as default };
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
- // src/index.ts
2
- import {
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
- const { warnDuplicates = true, extract, root = process.cwd() } = options;
16
- const moduleNamespaces = /* @__PURE__ */ new Map();
17
- let resolvedExtractModules = [];
18
- let resolvedMode = "runtime";
19
- return {
20
- name: "typestyles-rollup",
21
- buildStart() {
22
- resolvedExtractModules = resolveExtractModules(root, extract);
23
- resolvedMode = resolveExtractMode(options.mode, resolvedExtractModules);
24
- },
25
- transform(code, id) {
26
- if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) {
27
- return {
28
- code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, '"true"'),
29
- map: null
30
- };
31
- }
32
- if (!/\.[jt]sx?$/.test(id)) return null;
33
- if (id.includes("node_modules")) return null;
34
- if (!TYPESTYLES_IMPORT_RE.test(code)) return null;
35
- const { keys, prefixes } = extractNamespaces(code);
36
- if (keys.length === 0 && prefixes.length === 0) return null;
37
- if (warnDuplicates) {
38
- reportDuplicateNamespaces(moduleNamespaces, id, prefixes, this);
39
- }
40
- moduleNamespaces.set(id, { keys, prefixes });
41
- return null;
42
- },
43
- async generateBundle() {
44
- if (resolvedMode === "runtime") return;
45
- if (!resolvedExtractModules.length) return;
46
- try {
47
- const css = await runTypestylesBuild({
48
- root,
49
- modules: resolvedExtractModules
50
- });
51
- this.emitFile({
52
- type: "asset",
53
- fileName: extract?.fileName ?? "typestyles.css",
54
- source: css
55
- });
56
- } catch (error) {
57
- this.error(
58
- `[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`
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
- export {
65
- DEFAULT_EXTRACT_MODULE_CANDIDATES,
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.6",
3
+ "version": "0.5.8",
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.2"
41
+ "@typestyles/build-runner": "0.6.4"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^25.2.1",
45
- "eslint": "^9.39.2",
46
- "tsup": "^8.0.0",
47
- "typescript": "^5.4.0",
48
- "vitest": "^3.0.0",
49
- "rollup": "^4.0.0"
44
+ "@types/node": "^24.13.0",
45
+ "rollup": "^4.0.0",
46
+ "typescript": "^6.0.0",
47
+ "vite-plus": "1.3.0"
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
  }