@tailwind-styled/rspack 2.0.0

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.
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
+ }) : x)(function(x) {
23
+ if (typeof require !== "undefined") return require.apply(this, arguments);
24
+ throw Error('Dynamic require of "' + x + '" is not supported');
25
+ });
26
+
27
+ export {
28
+ __spreadValues,
29
+ __spreadProps,
30
+ __require
31
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ TailwindStyledRspackPlugin: () => TailwindStyledRspackPlugin,
34
+ default: () => index_default,
35
+ tailwindStyledRspackPlugin: () => tailwindStyledRspackPlugin
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_node_path = __toESM(require("path"), 1);
39
+ var LOADER_PATH = import_node_path.default.resolve(__dirname, "loader.js");
40
+ var TailwindStyledRspackPlugin = class {
41
+ constructor(opts = {}) {
42
+ this.opts = opts;
43
+ }
44
+ apply(compiler) {
45
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
46
+ const isDev = compiler.options.mode !== "production";
47
+ const loaderOpts = {
48
+ addDataAttr: (_a = this.opts.addDataAttr) != null ? _a : isDev,
49
+ routeCss: (_b = this.opts.routeCss) != null ? _b : false,
50
+ incremental: (_c = this.opts.incremental) != null ? _c : true,
51
+ verbose: (_d = this.opts.verbose) != null ? _d : false,
52
+ atomic: (_e = this.opts.atomic) != null ? _e : false,
53
+ hoist: (_f = this.opts.hoist) != null ? _f : true
54
+ };
55
+ const include = (_g = this.opts.include) != null ? _g : /\.[jt]sx?$/;
56
+ const exclude = (_h = this.opts.exclude) != null ? _h : /node_modules/;
57
+ const existing = (_j = (_i = compiler.options.module) == null ? void 0 : _i.rules) != null ? _j : [];
58
+ const alreadyRegistered = existing.some((r) => r._tailwindStyledRspackMarker === true);
59
+ if (alreadyRegistered) return;
60
+ const rule = {
61
+ _tailwindStyledRspackMarker: true,
62
+ test: include,
63
+ exclude,
64
+ use: [
65
+ {
66
+ loader: LOADER_PATH,
67
+ options: loaderOpts
68
+ }
69
+ ]
70
+ };
71
+ compiler.options.module.rules = [rule, ...existing];
72
+ }
73
+ };
74
+ function tailwindStyledRspackPlugin(opts = {}) {
75
+ return new TailwindStyledRspackPlugin(opts);
76
+ }
77
+ var index_default = tailwindStyledRspackPlugin;
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ TailwindStyledRspackPlugin,
81
+ tailwindStyledRspackPlugin
82
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * tailwind-styled-v4 — Rspack Plugin
3
+ *
4
+ * Rspack plugin yang menambahkan loader secara otomatis ke config.
5
+ * Mirip withTailwindStyled() untuk Next.js, tapi untuk Rspack/Webpack.
6
+ *
7
+ * Usage:
8
+ * import { tailwindStyledRspackPlugin } from "@tailwind-styled/rspack"
9
+ *
10
+ * export default defineConfig({
11
+ * plugins: [tailwindStyledRspackPlugin()],
12
+ * })
13
+ *
14
+ * Atau manual:
15
+ * import loaderPath from "@tailwind-styled/rspack/loader"
16
+ * // loader: loaderPath
17
+ */
18
+ interface RspackPluginOptions {
19
+ /** File patterns to transform (default: /\.[jt]sx?$/) */
20
+ include?: RegExp;
21
+ /** File patterns to exclude (default: /node_modules/) */
22
+ exclude?: RegExp;
23
+ /** Collect per-route CSS (default: false) */
24
+ routeCss?: boolean;
25
+ /** Skip unchanged files via hash (default: true) */
26
+ incremental?: boolean;
27
+ /** Log per-file transform info (default: false) */
28
+ verbose?: boolean;
29
+ /** Atomic CSS mode (default: false) */
30
+ atomic?: boolean;
31
+ /** Auto-hoist tw() outside render (default: true) */
32
+ hoist?: boolean;
33
+ /** Add data-tw debug attributes in dev (default: NODE_ENV !== production) */
34
+ addDataAttr?: boolean;
35
+ }
36
+ /**
37
+ * Rspack plugin — auto-registers the tailwind-styled loader.
38
+ *
39
+ * @example
40
+ * // rspack.config.ts
41
+ * import { tailwindStyledRspackPlugin } from "@tailwind-styled/rspack"
42
+ *
43
+ * export default {
44
+ * plugins: [tailwindStyledRspackPlugin()],
45
+ * }
46
+ */
47
+ declare class TailwindStyledRspackPlugin {
48
+ private opts;
49
+ constructor(opts?: RspackPluginOptions);
50
+ apply(compiler: any): void;
51
+ }
52
+ /**
53
+ * Functional factory — same as `new TailwindStyledRspackPlugin(opts).apply(...)` but
54
+ * works wherever Rspack/webpack expects a plugin object.
55
+ */
56
+ declare function tailwindStyledRspackPlugin(opts?: RspackPluginOptions): TailwindStyledRspackPlugin;
57
+
58
+ export { type RspackPluginOptions, TailwindStyledRspackPlugin, tailwindStyledRspackPlugin as default, tailwindStyledRspackPlugin };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * tailwind-styled-v4 — Rspack Plugin
3
+ *
4
+ * Rspack plugin yang menambahkan loader secara otomatis ke config.
5
+ * Mirip withTailwindStyled() untuk Next.js, tapi untuk Rspack/Webpack.
6
+ *
7
+ * Usage:
8
+ * import { tailwindStyledRspackPlugin } from "@tailwind-styled/rspack"
9
+ *
10
+ * export default defineConfig({
11
+ * plugins: [tailwindStyledRspackPlugin()],
12
+ * })
13
+ *
14
+ * Atau manual:
15
+ * import loaderPath from "@tailwind-styled/rspack/loader"
16
+ * // loader: loaderPath
17
+ */
18
+ interface RspackPluginOptions {
19
+ /** File patterns to transform (default: /\.[jt]sx?$/) */
20
+ include?: RegExp;
21
+ /** File patterns to exclude (default: /node_modules/) */
22
+ exclude?: RegExp;
23
+ /** Collect per-route CSS (default: false) */
24
+ routeCss?: boolean;
25
+ /** Skip unchanged files via hash (default: true) */
26
+ incremental?: boolean;
27
+ /** Log per-file transform info (default: false) */
28
+ verbose?: boolean;
29
+ /** Atomic CSS mode (default: false) */
30
+ atomic?: boolean;
31
+ /** Auto-hoist tw() outside render (default: true) */
32
+ hoist?: boolean;
33
+ /** Add data-tw debug attributes in dev (default: NODE_ENV !== production) */
34
+ addDataAttr?: boolean;
35
+ }
36
+ /**
37
+ * Rspack plugin — auto-registers the tailwind-styled loader.
38
+ *
39
+ * @example
40
+ * // rspack.config.ts
41
+ * import { tailwindStyledRspackPlugin } from "@tailwind-styled/rspack"
42
+ *
43
+ * export default {
44
+ * plugins: [tailwindStyledRspackPlugin()],
45
+ * }
46
+ */
47
+ declare class TailwindStyledRspackPlugin {
48
+ private opts;
49
+ constructor(opts?: RspackPluginOptions);
50
+ apply(compiler: any): void;
51
+ }
52
+ /**
53
+ * Functional factory — same as `new TailwindStyledRspackPlugin(opts).apply(...)` but
54
+ * works wherever Rspack/webpack expects a plugin object.
55
+ */
56
+ declare function tailwindStyledRspackPlugin(opts?: RspackPluginOptions): TailwindStyledRspackPlugin;
57
+
58
+ export { type RspackPluginOptions, TailwindStyledRspackPlugin, tailwindStyledRspackPlugin as default, tailwindStyledRspackPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import "./chunk-HMX3D6IV.js";
2
+
3
+ // src/index.ts
4
+ import path from "path";
5
+ var LOADER_PATH = path.resolve(__dirname, "loader.js");
6
+ var TailwindStyledRspackPlugin = class {
7
+ constructor(opts = {}) {
8
+ this.opts = opts;
9
+ }
10
+ apply(compiler) {
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12
+ const isDev = compiler.options.mode !== "production";
13
+ const loaderOpts = {
14
+ addDataAttr: (_a = this.opts.addDataAttr) != null ? _a : isDev,
15
+ routeCss: (_b = this.opts.routeCss) != null ? _b : false,
16
+ incremental: (_c = this.opts.incremental) != null ? _c : true,
17
+ verbose: (_d = this.opts.verbose) != null ? _d : false,
18
+ atomic: (_e = this.opts.atomic) != null ? _e : false,
19
+ hoist: (_f = this.opts.hoist) != null ? _f : true
20
+ };
21
+ const include = (_g = this.opts.include) != null ? _g : /\.[jt]sx?$/;
22
+ const exclude = (_h = this.opts.exclude) != null ? _h : /node_modules/;
23
+ const existing = (_j = (_i = compiler.options.module) == null ? void 0 : _i.rules) != null ? _j : [];
24
+ const alreadyRegistered = existing.some((r) => r._tailwindStyledRspackMarker === true);
25
+ if (alreadyRegistered) return;
26
+ const rule = {
27
+ _tailwindStyledRspackMarker: true,
28
+ test: include,
29
+ exclude,
30
+ use: [
31
+ {
32
+ loader: LOADER_PATH,
33
+ options: loaderOpts
34
+ }
35
+ ]
36
+ };
37
+ compiler.options.module.rules = [rule, ...existing];
38
+ }
39
+ };
40
+ function tailwindStyledRspackPlugin(opts = {}) {
41
+ return new TailwindStyledRspackPlugin(opts);
42
+ }
43
+ var index_default = tailwindStyledRspackPlugin;
44
+ export {
45
+ TailwindStyledRspackPlugin,
46
+ index_default as default,
47
+ tailwindStyledRspackPlugin
48
+ };
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/loader.ts
38
+ var loader_exports = {};
39
+ __export(loader_exports, {
40
+ default: () => rspackLoader
41
+ });
42
+ module.exports = __toCommonJS(loader_exports);
43
+ var import_compiler = require("@tailwind-styled/compiler");
44
+ function rspackLoader(source) {
45
+ var _a;
46
+ const callback = this.async();
47
+ const filepath = this.resourcePath;
48
+ if (filepath.includes("node_modules") || filepath.includes(".rspack-dist") || !/\.[jt]sx?$/.test(filepath)) {
49
+ callback(null, source);
50
+ return;
51
+ }
52
+ try {
53
+ const options = this.getOptions();
54
+ if (options.incremental !== false) {
55
+ try {
56
+ const { getIncrementalEngine, parseClassesToNodes } = require("@tailwind-styled/compiler");
57
+ if (typeof getIncrementalEngine === "function") {
58
+ const engine = getIncrementalEngine({ verbose: options.verbose });
59
+ const quickResult = engine.processFile(filepath, source, []);
60
+ if (!quickResult.changed) {
61
+ callback(null, source);
62
+ return;
63
+ }
64
+ const result2 = (0, import_compiler.transformSource)(source, __spreadProps(__spreadValues({}, options), { filename: filepath }));
65
+ if (options.routeCss && result2.changed && result2.classes.length > 0) {
66
+ const { registerFileClasses } = require("@tailwind-styled/compiler");
67
+ if (typeof registerFileClasses === "function") {
68
+ registerFileClasses(filepath, result2.classes);
69
+ }
70
+ }
71
+ const nodes = parseClassesToNodes(result2.classes);
72
+ engine.processFile(filepath, source, nodes);
73
+ if (options.verbose && result2.changed) {
74
+ const env = ((_a = result2.rsc) == null ? void 0 : _a.isServer) ? "server" : "client";
75
+ console.log(
76
+ `[tailwind-styled/rspack] ${filepath.split(/[\\/]/).pop()} \u2192 ${result2.classes.length} classes, ${env} component`
77
+ );
78
+ }
79
+ callback(null, result2.code);
80
+ return;
81
+ }
82
+ } catch (e) {
83
+ }
84
+ }
85
+ const result = (0, import_compiler.transformSource)(source, __spreadProps(__spreadValues({}, options), { filename: filepath }));
86
+ if (options.routeCss && result.changed && result.classes.length > 0) {
87
+ try {
88
+ const { registerFileClasses } = require("@tailwind-styled/compiler");
89
+ if (typeof registerFileClasses === "function") {
90
+ registerFileClasses(filepath, result.classes);
91
+ }
92
+ } catch (e) {
93
+ }
94
+ }
95
+ callback(null, result.code);
96
+ } catch (err) {
97
+ if (process.env.NODE_ENV !== "production") {
98
+ console.warn(`[tailwind-styled/rspack] Transform failed for ${filepath}:`, err);
99
+ }
100
+ callback(null, source);
101
+ }
102
+ }
@@ -0,0 +1,60 @@
1
+ import { TransformOptions } from '@tailwind-styled/compiler';
2
+
3
+ /**
4
+ * tailwind-styled-v4 — Rspack Loader
5
+ *
6
+ * Rspack is 100% webpack-loader-compatible. This loader follows the same
7
+ * contract as webpackLoader.ts — async callback, getOptions(), resourcePath.
8
+ *
9
+ * Usage in rspack.config.js / rspack.config.ts:
10
+ *
11
+ * import { defineConfig } from "@rspack/cli"
12
+ * import { rspackLoader } from "@tailwind-styled/rspack/loader"
13
+ *
14
+ * export default defineConfig({
15
+ * module: {
16
+ * rules: [
17
+ * {
18
+ * test: /\.[jt]sx?$/,
19
+ * exclude: /node_modules/,
20
+ * use: [
21
+ * {
22
+ * loader: "@tailwind-styled/rspack/loader",
23
+ * options: {
24
+ * routeCss: false,
25
+ * incremental: true,
26
+ * verbose: false,
27
+ * },
28
+ * },
29
+ * ],
30
+ * },
31
+ * ],
32
+ * },
33
+ * })
34
+ *
35
+ * Options:
36
+ * routeCss — collect per-route CSS (default: false in dev)
37
+ * incremental — skip unchanged files via hash (default: true)
38
+ * verbose — log transform info per file (default: false)
39
+ * atomic — use atomic CSS mode (default: false)
40
+ * hoist — auto-hoist tw() outside render (default: true)
41
+ * addDataAttr — add data-tw debug attrs in dev (default: true in dev)
42
+ */
43
+
44
+ interface RspackLoaderOptions extends TransformOptions {
45
+ routeCss?: boolean;
46
+ incremental?: boolean;
47
+ verbose?: boolean;
48
+ }
49
+ interface RspackLoaderContext {
50
+ resourcePath: string;
51
+ getOptions(): RspackLoaderOptions;
52
+ async(): (err: Error | null, result?: string) => void;
53
+ }
54
+ /**
55
+ * Rspack webpack-compatible loader.
56
+ * Export as default for `loader: require.resolve(...)` usage.
57
+ */
58
+ declare function rspackLoader(this: RspackLoaderContext, source: string): void;
59
+
60
+ export { rspackLoader as default };
@@ -0,0 +1,60 @@
1
+ import { TransformOptions } from '@tailwind-styled/compiler';
2
+
3
+ /**
4
+ * tailwind-styled-v4 — Rspack Loader
5
+ *
6
+ * Rspack is 100% webpack-loader-compatible. This loader follows the same
7
+ * contract as webpackLoader.ts — async callback, getOptions(), resourcePath.
8
+ *
9
+ * Usage in rspack.config.js / rspack.config.ts:
10
+ *
11
+ * import { defineConfig } from "@rspack/cli"
12
+ * import { rspackLoader } from "@tailwind-styled/rspack/loader"
13
+ *
14
+ * export default defineConfig({
15
+ * module: {
16
+ * rules: [
17
+ * {
18
+ * test: /\.[jt]sx?$/,
19
+ * exclude: /node_modules/,
20
+ * use: [
21
+ * {
22
+ * loader: "@tailwind-styled/rspack/loader",
23
+ * options: {
24
+ * routeCss: false,
25
+ * incremental: true,
26
+ * verbose: false,
27
+ * },
28
+ * },
29
+ * ],
30
+ * },
31
+ * ],
32
+ * },
33
+ * })
34
+ *
35
+ * Options:
36
+ * routeCss — collect per-route CSS (default: false in dev)
37
+ * incremental — skip unchanged files via hash (default: true)
38
+ * verbose — log transform info per file (default: false)
39
+ * atomic — use atomic CSS mode (default: false)
40
+ * hoist — auto-hoist tw() outside render (default: true)
41
+ * addDataAttr — add data-tw debug attrs in dev (default: true in dev)
42
+ */
43
+
44
+ interface RspackLoaderOptions extends TransformOptions {
45
+ routeCss?: boolean;
46
+ incremental?: boolean;
47
+ verbose?: boolean;
48
+ }
49
+ interface RspackLoaderContext {
50
+ resourcePath: string;
51
+ getOptions(): RspackLoaderOptions;
52
+ async(): (err: Error | null, result?: string) => void;
53
+ }
54
+ /**
55
+ * Rspack webpack-compatible loader.
56
+ * Export as default for `loader: require.resolve(...)` usage.
57
+ */
58
+ declare function rspackLoader(this: RspackLoaderContext, source: string): void;
59
+
60
+ export { rspackLoader as default };
package/dist/loader.js ADDED
@@ -0,0 +1,70 @@
1
+ import {
2
+ __require,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-HMX3D6IV.js";
6
+
7
+ // src/loader.ts
8
+ import { transformSource } from "@tailwind-styled/compiler";
9
+ function rspackLoader(source) {
10
+ var _a;
11
+ const callback = this.async();
12
+ const filepath = this.resourcePath;
13
+ if (filepath.includes("node_modules") || filepath.includes(".rspack-dist") || !/\.[jt]sx?$/.test(filepath)) {
14
+ callback(null, source);
15
+ return;
16
+ }
17
+ try {
18
+ const options = this.getOptions();
19
+ if (options.incremental !== false) {
20
+ try {
21
+ const { getIncrementalEngine, parseClassesToNodes } = __require("@tailwind-styled/compiler");
22
+ if (typeof getIncrementalEngine === "function") {
23
+ const engine = getIncrementalEngine({ verbose: options.verbose });
24
+ const quickResult = engine.processFile(filepath, source, []);
25
+ if (!quickResult.changed) {
26
+ callback(null, source);
27
+ return;
28
+ }
29
+ const result2 = transformSource(source, __spreadProps(__spreadValues({}, options), { filename: filepath }));
30
+ if (options.routeCss && result2.changed && result2.classes.length > 0) {
31
+ const { registerFileClasses } = __require("@tailwind-styled/compiler");
32
+ if (typeof registerFileClasses === "function") {
33
+ registerFileClasses(filepath, result2.classes);
34
+ }
35
+ }
36
+ const nodes = parseClassesToNodes(result2.classes);
37
+ engine.processFile(filepath, source, nodes);
38
+ if (options.verbose && result2.changed) {
39
+ const env = ((_a = result2.rsc) == null ? void 0 : _a.isServer) ? "server" : "client";
40
+ console.log(
41
+ `[tailwind-styled/rspack] ${filepath.split(/[\\/]/).pop()} \u2192 ${result2.classes.length} classes, ${env} component`
42
+ );
43
+ }
44
+ callback(null, result2.code);
45
+ return;
46
+ }
47
+ } catch (e) {
48
+ }
49
+ }
50
+ const result = transformSource(source, __spreadProps(__spreadValues({}, options), { filename: filepath }));
51
+ if (options.routeCss && result.changed && result.classes.length > 0) {
52
+ try {
53
+ const { registerFileClasses } = __require("@tailwind-styled/compiler");
54
+ if (typeof registerFileClasses === "function") {
55
+ registerFileClasses(filepath, result.classes);
56
+ }
57
+ } catch (e) {
58
+ }
59
+ }
60
+ callback(null, result.code);
61
+ } catch (err) {
62
+ if (process.env.NODE_ENV !== "production") {
63
+ console.warn(`[tailwind-styled/rspack] Transform failed for ${filepath}:`, err);
64
+ }
65
+ callback(null, source);
66
+ }
67
+ }
68
+ export {
69
+ rspackLoader as default
70
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@tailwind-styled/rspack",
3
+ "version": "2.0.0",
4
+ "description": "Rspack adapter for tailwind-styled-v4 — loader + plugin",
5
+ "author": "Dictionar32",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ },
17
+ "./loader": {
18
+ "types": "./dist/loader.d.ts",
19
+ "import": "./dist/loader.js",
20
+ "require": "./dist/loader.cjs"
21
+ }
22
+ },
23
+ "files": ["dist"],
24
+ "sideEffects": false,
25
+ "engines": { "node": ">=18" },
26
+ "peerDependencies": {
27
+ "@rspack/core": ">=1.0.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@rspack/core": { "optional": true }
31
+ },
32
+ "dependencies": {
33
+ "@tailwind-styled/compiler": "*"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "^5",
37
+ "tsup": "^8"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup src/index.ts src/loader.ts --format cjs,esm --dts --out-dir dist --clean",
41
+ "dev": "tsup src/index.ts src/loader.ts --format cjs,esm --dts --out-dir dist --watch",
42
+ "clean": "rm -rf dist"
43
+ }
44
+ }