@typestyles/rollup 0.0.0-unstable.fb509f91ba06 → 0.0.0-unstable.ff74983e3aa5
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 +112 -82
- package/dist/index.d.cts +41 -36
- package/dist/index.d.ts +41 -36
- package/dist/index.js +92 -67
- package/package.json +9 -12
package/dist/index.cjs
CHANGED
|
@@ -1,86 +1,116 @@
|
|
|
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(), compile = false } = options;
|
|
9
|
+
const moduleNamespaces = new Map();
|
|
10
|
+
let resolvedExtractModules = [];
|
|
11
|
+
let resolvedMode = "runtime";
|
|
12
|
+
let extraction = null;
|
|
13
|
+
let planIndex = null;
|
|
14
|
+
const extractOnce = () => extraction ??= (0, _typestyles_build_runner.runTypestylesExtract)({
|
|
15
|
+
root,
|
|
16
|
+
modules: resolvedExtractModules
|
|
17
|
+
});
|
|
18
|
+
const compileEnabled = () => compile && resolvedMode === "build" && resolvedExtractModules.length > 0;
|
|
19
|
+
function finishTransform(source, id, compiled) {
|
|
20
|
+
const code = compiled?.code ?? source;
|
|
21
|
+
if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) return {
|
|
22
|
+
code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, "\"true\""),
|
|
23
|
+
map: compiled?.map ?? null
|
|
24
|
+
};
|
|
25
|
+
trackNamespaces.call(this, source, id);
|
|
26
|
+
return compiled ? {
|
|
27
|
+
code: compiled.code,
|
|
28
|
+
map: compiled.map
|
|
29
|
+
} : null;
|
|
30
|
+
}
|
|
31
|
+
function trackNamespaces(code, id) {
|
|
32
|
+
if (!/\.[jt]sx?$/.test(id)) return;
|
|
33
|
+
if (id.includes("node_modules")) return;
|
|
34
|
+
if (!_typestyles_build_runner.TYPESTYLES_IMPORT_RE.test(code)) return;
|
|
35
|
+
const { keys, prefixes } = (0, _typestyles_build_runner.extractNamespaces)(code);
|
|
36
|
+
if (keys.length === 0 && prefixes.length === 0) return;
|
|
37
|
+
if (warnDuplicates) (0, _typestyles_build_runner.reportDuplicateNamespaces)(moduleNamespaces, id, prefixes, this);
|
|
38
|
+
moduleNamespaces.set(id, {
|
|
39
|
+
keys,
|
|
40
|
+
prefixes
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
name: "typestyles-rollup",
|
|
45
|
+
async buildStart() {
|
|
46
|
+
resolvedExtractModules = (0, _typestyles_build_runner.resolveExtractModules)(root, extract);
|
|
47
|
+
resolvedMode = (0, _typestyles_build_runner.resolveExtractMode)(options.mode, resolvedExtractModules);
|
|
48
|
+
extraction = null;
|
|
49
|
+
planIndex = null;
|
|
50
|
+
if (compileEnabled()) await extractOnce();
|
|
51
|
+
},
|
|
52
|
+
async resolveId(source, importer) {
|
|
53
|
+
if (resolvedMode !== "build" || !(0, _typestyles_build_runner.isSheetRequest)(source)) return null;
|
|
54
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
55
|
+
if (!resolved) return null;
|
|
56
|
+
const noop = (0, _typestyles_build_runner.toZeroRuntimeSheetId)(resolved.id);
|
|
57
|
+
return noop ? {
|
|
58
|
+
...resolved,
|
|
59
|
+
id: noop
|
|
60
|
+
} : null;
|
|
61
|
+
},
|
|
62
|
+
transform(source, id) {
|
|
63
|
+
if (!(compileEnabled() && (0, _typestyles_build_runner.isTransformableId)(id))) return finishTransform.call(this, source, id, null);
|
|
64
|
+
return extractOnce().then(({ plans }) => {
|
|
65
|
+
planIndex ??= (0, _typestyles_build_runner.indexPlans)(plans);
|
|
66
|
+
const compiled = (0, _typestyles_build_runner.transformRecipeCalls)(source, planIndex, (text) => this.parse(text), id);
|
|
67
|
+
return finishTransform.call(this, source, id, compiled);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
shouldTransformCachedModule({ code }) {
|
|
71
|
+
return compileEnabled() && (0, _typestyles_build_runner.mayNeedRecompile)(code);
|
|
72
|
+
},
|
|
73
|
+
async generateBundle(_options, bundle) {
|
|
74
|
+
if (resolvedMode === "build") {
|
|
75
|
+
const leaked = (0, _typestyles_build_runner.findRealSheetModules)(Object.values(bundle ?? {}).flatMap((chunk) => chunk.type === "chunk" ? Object.keys(chunk.modules) : []));
|
|
76
|
+
if (leaked.length > 0) this.warn((0, _typestyles_build_runner.zeroRuntimeLeakMessage)(leaked));
|
|
77
|
+
if (compileEnabled()) {
|
|
78
|
+
const warning = (0, _typestyles_build_runner.lingeringRuntimeWarning)(bundle ?? {}, (id) => this.getModuleInfo(id)?.importers, root);
|
|
79
|
+
if (warning) this.warn(warning);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (resolvedMode === "runtime") return;
|
|
83
|
+
if (!resolvedExtractModules.length) return;
|
|
84
|
+
try {
|
|
85
|
+
const { css } = await extractOnce();
|
|
86
|
+
this.emitFile({
|
|
87
|
+
type: "asset",
|
|
88
|
+
fileName: extract?.fileName ?? "typestyles.css",
|
|
89
|
+
source: css
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
this.error(`[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
80
96
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
Object.defineProperty(exports, "DEFAULT_EXTRACT_MODULE_CANDIDATES", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function() {
|
|
101
|
+
return _typestyles_build_runner.DEFAULT_EXTRACT_MODULE_CANDIDATES;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
exports.default = typestylesRollupPlugin;
|
|
105
|
+
Object.defineProperty(exports, "discoverDefaultExtractModules", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function() {
|
|
108
|
+
return _typestyles_build_runner.discoverDefaultExtractModules;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "extractNamespaces", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function() {
|
|
114
|
+
return _typestyles_build_runner.extractNamespaces;
|
|
115
|
+
}
|
|
86
116
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
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
|
-
|
|
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;
|
|
32
|
+
/**
|
|
33
|
+
* Experimental. In `"build"` mode, replace `recipe()` definitions with the small call-behavior
|
|
34
|
+
* plans recorded during extraction, so style configs and CSS machinery tree-shake out of the
|
|
35
|
+
* bundle. Rollup applies `transform` hooks in plugin order, so list this plugin **after** any
|
|
36
|
+
* TypeScript/JSX plugin: only plain-JS modules are rewritten.
|
|
37
|
+
*/
|
|
38
|
+
compile?: boolean;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
40
|
/**
|
|
36
41
|
* Rollup plugin for typestyles runtime + optional static extraction.
|
|
37
42
|
*
|
|
38
43
|
* Rolldown supports Rollup-compatible plugins, so this plugin also works
|
|
39
44
|
* as a starting integration there.
|
|
40
45
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export { type
|
|
46
|
+
export default function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
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
|
-
|
|
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;
|
|
32
|
+
/**
|
|
33
|
+
* Experimental. In `"build"` mode, replace `recipe()` definitions with the small call-behavior
|
|
34
|
+
* plans recorded during extraction, so style configs and CSS machinery tree-shake out of the
|
|
35
|
+
* bundle. Rollup applies `transform` hooks in plugin order, so list this plugin **after** any
|
|
36
|
+
* TypeScript/JSX plugin: only plain-JS modules are rewritten.
|
|
37
|
+
*/
|
|
38
|
+
compile?: boolean;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
40
|
/**
|
|
36
41
|
* Rollup plugin for typestyles runtime + optional static extraction.
|
|
37
42
|
*
|
|
38
43
|
* Rolldown supports Rollup-compatible plugins, so this plugin also works
|
|
39
44
|
* as a starting integration there.
|
|
40
45
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export { type
|
|
46
|
+
export default function typestylesRollupPlugin(options?: TypestylesRollupPluginOptions): Plugin;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_EXTRACT_MODULE_CANDIDATES, type TypestylesExtractOptions, discoverDefaultExtractModules, extractNamespaces };
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,94 @@
|
|
|
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, findRealSheetModules, indexPlans, isSheetRequest, isTransformableId, lingeringRuntimeWarning, mayNeedRecompile, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesExtract, toZeroRuntimeSheetId, transformRecipeCalls, zeroRuntimeLeakMessage } 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(), compile = false } = options;
|
|
5
|
+
const moduleNamespaces = new Map();
|
|
6
|
+
let resolvedExtractModules = [];
|
|
7
|
+
let resolvedMode = "runtime";
|
|
8
|
+
let extraction = null;
|
|
9
|
+
let planIndex = null;
|
|
10
|
+
const extractOnce = () => extraction ??= runTypestylesExtract({
|
|
11
|
+
root,
|
|
12
|
+
modules: resolvedExtractModules
|
|
13
|
+
});
|
|
14
|
+
const compileEnabled = () => compile && resolvedMode === "build" && resolvedExtractModules.length > 0;
|
|
15
|
+
function finishTransform(source, id, compiled) {
|
|
16
|
+
const code = compiled?.code ?? source;
|
|
17
|
+
if ((resolvedMode === "build" || resolvedMode === "hybrid") && code.includes("__TYPESTYLES_RUNTIME_DISABLED__")) return {
|
|
18
|
+
code: code.replace(/__TYPESTYLES_RUNTIME_DISABLED__/g, "\"true\""),
|
|
19
|
+
map: compiled?.map ?? null
|
|
20
|
+
};
|
|
21
|
+
trackNamespaces.call(this, source, id);
|
|
22
|
+
return compiled ? {
|
|
23
|
+
code: compiled.code,
|
|
24
|
+
map: compiled.map
|
|
25
|
+
} : null;
|
|
26
|
+
}
|
|
27
|
+
function trackNamespaces(code, id) {
|
|
28
|
+
if (!/\.[jt]sx?$/.test(id)) return;
|
|
29
|
+
if (id.includes("node_modules")) return;
|
|
30
|
+
if (!TYPESTYLES_IMPORT_RE.test(code)) return;
|
|
31
|
+
const { keys, prefixes } = extractNamespaces(code);
|
|
32
|
+
if (keys.length === 0 && prefixes.length === 0) return;
|
|
33
|
+
if (warnDuplicates) reportDuplicateNamespaces(moduleNamespaces, id, prefixes, this);
|
|
34
|
+
moduleNamespaces.set(id, {
|
|
35
|
+
keys,
|
|
36
|
+
prefixes
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
name: "typestyles-rollup",
|
|
41
|
+
async buildStart() {
|
|
42
|
+
resolvedExtractModules = resolveExtractModules(root, extract);
|
|
43
|
+
resolvedMode = resolveExtractMode(options.mode, resolvedExtractModules);
|
|
44
|
+
extraction = null;
|
|
45
|
+
planIndex = null;
|
|
46
|
+
if (compileEnabled()) await extractOnce();
|
|
47
|
+
},
|
|
48
|
+
async resolveId(source, importer) {
|
|
49
|
+
if (resolvedMode !== "build" || !isSheetRequest(source)) return null;
|
|
50
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
51
|
+
if (!resolved) return null;
|
|
52
|
+
const noop = toZeroRuntimeSheetId(resolved.id);
|
|
53
|
+
return noop ? {
|
|
54
|
+
...resolved,
|
|
55
|
+
id: noop
|
|
56
|
+
} : null;
|
|
57
|
+
},
|
|
58
|
+
transform(source, id) {
|
|
59
|
+
if (!(compileEnabled() && isTransformableId(id))) return finishTransform.call(this, source, id, null);
|
|
60
|
+
return extractOnce().then(({ plans }) => {
|
|
61
|
+
planIndex ??= indexPlans(plans);
|
|
62
|
+
const compiled = transformRecipeCalls(source, planIndex, (text) => this.parse(text), id);
|
|
63
|
+
return finishTransform.call(this, source, id, compiled);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
shouldTransformCachedModule({ code }) {
|
|
67
|
+
return compileEnabled() && mayNeedRecompile(code);
|
|
68
|
+
},
|
|
69
|
+
async generateBundle(_options, bundle) {
|
|
70
|
+
if (resolvedMode === "build") {
|
|
71
|
+
const leaked = findRealSheetModules(Object.values(bundle ?? {}).flatMap((chunk) => chunk.type === "chunk" ? Object.keys(chunk.modules) : []));
|
|
72
|
+
if (leaked.length > 0) this.warn(zeroRuntimeLeakMessage(leaked));
|
|
73
|
+
if (compileEnabled()) {
|
|
74
|
+
const warning = lingeringRuntimeWarning(bundle ?? {}, (id) => this.getModuleInfo(id)?.importers, root);
|
|
75
|
+
if (warning) this.warn(warning);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (resolvedMode === "runtime") return;
|
|
79
|
+
if (!resolvedExtractModules.length) return;
|
|
80
|
+
try {
|
|
81
|
+
const { css } = await extractOnce();
|
|
82
|
+
this.emitFile({
|
|
83
|
+
type: "asset",
|
|
84
|
+
fileName: extract?.fileName ?? "typestyles.css",
|
|
85
|
+
source: css
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
this.error(`[typestyles] Failed to extract CSS: ${error instanceof Error ? error.message : String(error)}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
63
92
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
typestylesRollupPlugin as default,
|
|
67
|
-
discoverDefaultExtractModules,
|
|
68
|
-
extractNamespaces
|
|
69
|
-
};
|
|
93
|
+
//#endregion
|
|
94
|
+
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.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.ff74983e3aa5",
|
|
4
4
|
"description": "Rollup and Rolldown plugin for typestyles",
|
|
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/
|
|
34
|
+
"url": "https://github.com/phthalo-dev/typestyles",
|
|
35
35
|
"directory": "packages/rollup"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"rollup": ">=4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typestyles/build-runner": "0.0.0-unstable.
|
|
41
|
+
"@typestyles/build-runner": "0.0.0-unstable.ff74983e3aa5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
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": "
|
|
53
|
-
"test": "
|
|
54
|
-
"lint": "eslint .",
|
|
50
|
+
"build": "vp pack",
|
|
51
|
+
"test": "vp test run",
|
|
55
52
|
"typecheck": "tsc --noEmit"
|
|
56
53
|
}
|
|
57
54
|
}
|