unplugin-essor 0.0.7-beta.6 → 0.0.10-beta.21

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/astro.cjs ADDED
@@ -0,0 +1,159 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
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 __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
+ // If the importer is in node compatibility mode or this is not an ESM
36
+ // file that has been converted to a CommonJS file using a Babel-
37
+ // compatible transform (i.e. "__esModule" has not been set), then set
38
+ // "default" to the CommonJS "module.exports" for node compatibility.
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ var __async = (__this, __arguments, generator) => {
44
+ return new Promise((resolve, reject) => {
45
+ var fulfilled = (value) => {
46
+ try {
47
+ step(generator.next(value));
48
+ } catch (e) {
49
+ reject(e);
50
+ }
51
+ };
52
+ var rejected = (value) => {
53
+ try {
54
+ step(generator.throw(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ };
59
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
60
+ step((generator = generator.apply(__this, __arguments)).next());
61
+ });
62
+ };
63
+
64
+ // src/astro.ts
65
+ var astro_exports = {};
66
+ __export(astro_exports, {
67
+ default: () => astro_default
68
+ });
69
+ module.exports = __toCommonJS(astro_exports);
70
+
71
+ // src/index.ts
72
+ var import_unplugin = require("unplugin");
73
+ var babel = __toESM(require("@babel/core"), 1);
74
+ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
75
+ var import_vite = require("vite");
76
+ var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
77
+ var DEFAULT_OPTIONS = {
78
+ symbol: "$",
79
+ props: true,
80
+ ssg: false
81
+ };
82
+ var unpluginFactory = (options = {}) => {
83
+ const filter = (0, import_vite.createFilter)(options.include, options.exclude);
84
+ return {
85
+ name: "unplugin-essor",
86
+ // enforce: 'pre',
87
+ config() {
88
+ return {
89
+ esbuild: {
90
+ jsx: "preserve"
91
+ }
92
+ };
93
+ },
94
+ transform(code, id) {
95
+ if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
96
+ return;
97
+ }
98
+ if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
99
+ return null;
100
+ }
101
+ const result = babel.transformSync(code, {
102
+ filename: id,
103
+ sourceMaps: true,
104
+ sourceType: "module",
105
+ plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
106
+ });
107
+ if (result == null ? void 0 : result.code) {
108
+ return {
109
+ code: result.code,
110
+ map: result.map
111
+ };
112
+ }
113
+ return code;
114
+ },
115
+ handleHotUpdate(ctx) {
116
+ var _a, _b;
117
+ for (const mod of ctx.modules) {
118
+ const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
119
+ if (deps && deps.length > 0) {
120
+ for (const dep of deps) {
121
+ const mod2 = ctx.server.moduleGraph.getModuleById(dep);
122
+ if (mod2) {
123
+ ctx.server.moduleGraph.invalidateModule(mod2);
124
+ }
125
+ }
126
+ } else if (mod.type === "js" && Array.from(mod.importers).every(
127
+ (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
128
+ var _a2;
129
+ return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
130
+ })
131
+ )) {
132
+ ctx.server.moduleGraph.invalidateAll();
133
+ }
134
+ }
135
+ if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
136
+ ctx.server.ws.send({
137
+ type: "full-reload"
138
+ });
139
+ return [];
140
+ }
141
+ }
142
+ };
143
+ };
144
+ var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
145
+ var src_default = unplugin;
146
+
147
+ // src/astro.ts
148
+ var astro_default = (options) => ({
149
+ name: "unplugin-essor-astro",
150
+ hooks: {
151
+ // eslint-disable-next-line require-await
152
+ "astro:config:setup": (astro) => __async(void 0, null, function* () {
153
+ var _a;
154
+ (_a = astro.config.vite).plugins || (_a.plugins = []);
155
+ astro.config.vite.plugins.push(src_default.vite(options));
156
+ })
157
+ }
158
+ });
159
+ //# sourceMappingURL=astro.cjs.mapexports.default = module.exports;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/astro.ts","../src/index.ts"],"sourcesContent":["import unplugin from '.';\nimport type { Options } from './types';\n\nexport default (options: Options) => ({\n name: 'unplugin-essor-astro',\n hooks: {\n // eslint-disable-next-line require-await\n 'astro:config:setup': async (astro: any) => {\n astro.config.vite.plugins ||= [];\n astro.config.vite.plugins.push(unplugin.vite(options));\n },\n },\n});\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,SAAe,oBAAc,MAAM;AAAA,QACvC,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS,CAAC,CAAC,0BAAAA,SAAkB,kCAAK,kBAAoB,QAAS,CAAC;AAAA,MAClE,CAAC;AACD,UAAI,iCAAQ,MAAM;AAChB,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,KAAU;AApD9B;AAqDM,iBAAW,OAAO,IAAI,SAAS;AAC7B,cAAM,QAAO,eAAI,SAAJ,mBAAU,SAAV,mBAAgB;AAC7B,YAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AAjEpE,gBAAAC;AAiEuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,WAA2B,oDAAe,eAAe;AAEtE,IAAO,cAAQ;;;ADlFf,IAAO,gBAAQ,CAAC,aAAsB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,IAEL,sBAAsB,CAAO,UAAe;AAPhD;AAQM,kBAAM,OAAO,MAAK,YAAlB,GAAkB,UAAY,CAAC;AAC/B,YAAM,OAAO,KAAK,QAAQ,KAAK,YAAS,KAAK,OAAO,CAAC;AAAA,IACvD;AAAA,EACF;AACF;","names":["essorBabelPlugin","mod","_a"]}
@@ -0,0 +1,11 @@
1
+ import { Options } from './types.cjs';
2
+ import 'vite';
3
+
4
+ declare const _default: (options: Options) => {
5
+ name: string;
6
+ hooks: {
7
+ 'astro:config:setup': (astro: any) => Promise<void>;
8
+ };
9
+ };
10
+
11
+ export { _default as default };
@@ -0,0 +1,11 @@
1
+ import { Options } from './types.js';
2
+ import 'vite';
3
+
4
+ declare const _default: (options: Options) => {
5
+ name: string;
6
+ hooks: {
7
+ 'astro:config:setup': (astro: any) => Promise<void>;
8
+ };
9
+ };
10
+
11
+ export { _default as default };
package/dist/astro.js ADDED
@@ -0,0 +1,21 @@
1
+ import {
2
+ __async,
3
+ src_default
4
+ } from "./chunk-J2ETW346.js";
5
+
6
+ // src/astro.ts
7
+ var astro_default = (options) => ({
8
+ name: "unplugin-essor-astro",
9
+ hooks: {
10
+ // eslint-disable-next-line require-await
11
+ "astro:config:setup": (astro) => __async(void 0, null, function* () {
12
+ var _a;
13
+ (_a = astro.config.vite).plugins || (_a.plugins = []);
14
+ astro.config.vite.plugins.push(src_default.vite(options));
15
+ })
16
+ }
17
+ });
18
+ export {
19
+ astro_default as default
20
+ };
21
+ //# sourceMappingURL=astro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/astro.ts"],"sourcesContent":["import unplugin from '.';\nimport type { Options } from './types';\n\nexport default (options: Options) => ({\n name: 'unplugin-essor-astro',\n hooks: {\n // eslint-disable-next-line require-await\n 'astro:config:setup': async (astro: any) => {\n astro.config.vite.plugins ||= [];\n astro.config.vite.plugins.push(unplugin.vite(options));\n },\n },\n});\n"],"mappings":";;;;;;AAGA,IAAO,gBAAQ,CAAC,aAAsB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,IAEL,sBAAsB,CAAO,UAAe;AAPhD;AAQM,kBAAM,OAAO,MAAK,YAAlB,GAAkB,UAAY,CAAC;AAC/B,YAAM,OAAO,KAAK,QAAQ,KAAK,YAAS,KAAK,OAAO,CAAC;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
@@ -14,6 +14,26 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
17
37
 
18
38
  // src/index.ts
19
39
  import { createUnplugin } from "unplugin";
@@ -22,7 +42,9 @@ import essorBabelPlugin from "babel-plugin-essor";
22
42
  import { createFilter } from "vite";
23
43
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
24
44
  var DEFAULT_OPTIONS = {
25
- symbol: "$"
45
+ symbol: "$",
46
+ props: true,
47
+ ssg: false
26
48
  };
27
49
  var unpluginFactory = (options = {}) => {
28
50
  const filter = createFilter(options.include, options.exclude);
@@ -90,8 +112,9 @@ var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
90
112
  var src_default = unplugin;
91
113
 
92
114
  export {
115
+ __async,
93
116
  unpluginFactory,
94
117
  unplugin,
95
118
  src_default
96
119
  };
97
- //# sourceMappingURL=chunk-IVXV4IDU.js.map
120
+ //# sourceMappingURL=chunk-J2ETW346.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AACvB,OAAO,sBAAsB;AAC7B,SAAS,oBAAoB;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,SAAS,aAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,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AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,WAA2B,+BAAe,eAAe;AAEtE,IAAO,cAAQ;","names":["mod","_a"]}
package/dist/esbuild.cjs CHANGED
@@ -56,7 +56,9 @@ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
56
56
  var import_vite = require("vite");
57
57
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
58
58
  var DEFAULT_OPTIONS = {
59
- symbol: "$"
59
+ symbol: "$",
60
+ props: true,
61
+ ssg: false
60
62
  };
61
63
  var unpluginFactory = (options = {}) => {
62
64
  const filter = (0, import_vite.createFilter)(options.include, options.exclude);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/esbuild.ts","../src/index.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createEsbuildPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAoC;;;ACApC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AACV;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG;AAC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["import { createEsbuildPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createEsbuildPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unplu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,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AAjEpE,gBAAAC;AAiEuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD9EA,IAAO,sBAAQ,sCAAoB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-IVXV4IDU.js";
3
+ } from "./chunk-J2ETW346.js";
4
4
 
5
5
  // src/esbuild.ts
6
6
  import { createEsbuildPlugin } from "unplugin";
package/dist/index.cjs CHANGED
@@ -55,7 +55,9 @@ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
55
55
  var import_vite = require("vite");
56
56
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
57
57
  var DEFAULT_OPTIONS = {
58
- symbol: "$"
58
+ symbol: "$",
59
+ props: true,
60
+ ssg: false
59
61
  };
60
62
  var unpluginFactory = (options = {}) => {
61
63
  const filter = (0, import_vite.createFilter)(options.include, options.exclude);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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G;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AA/DpE,gBAAAC;AA+DuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,WAA2B,oDAAe,eAAe;AAEtE,IAAO,cAAQ;","names":["essorBabelPlugin","mod","_a"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE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ist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  src_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-IVXV4IDU.js";
5
+ } from "./chunk-J2ETW346.js";
6
6
  export {
7
7
  src_default as default,
8
8
  unplugin,
package/dist/rollup.cjs CHANGED
@@ -56,7 +56,9 @@ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
56
56
  var import_vite = require("vite");
57
57
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
58
58
  var DEFAULT_OPTIONS = {
59
- symbol: "$"
59
+ symbol: "$",
60
+ props: true,
61
+ ssg: false
60
62
  };
61
63
  var unpluginFactory = (options = {}) => {
62
64
  const filter = (0, import_vite.createFilter)(options.include, options.exclude);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rollup.ts","../src/index.ts"],"sourcesContent":["import { createRollupPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createRollupPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAmC;;;ACAnC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AACV;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG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Content":["import { createRollupPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createRollupPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unplugin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,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AAjEpE,gBAAAC;AAiEuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD9EA,IAAO,qBAAQ,qCAAmB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-IVXV4IDU.js";
3
+ } from "./chunk-J2ETW346.js";
4
4
 
5
5
  // src/rollup.ts
6
6
  import { createRollupPlugin } from "unplugin";
@@ -0,0 +1,128 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
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 __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
+ // If the importer is in node compatibility mode or this is not an ESM
36
+ // file that has been converted to a CommonJS file using a Babel-
37
+ // compatible transform (i.e. "__esModule" has not been set), then set
38
+ // "default" to the CommonJS "module.exports" for node compatibility.
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+
44
+ // src/rspack.ts
45
+ var rspack_exports = {};
46
+ __export(rspack_exports, {
47
+ default: () => rspack_default
48
+ });
49
+ module.exports = __toCommonJS(rspack_exports);
50
+ var import_unplugin2 = require("unplugin");
51
+
52
+ // src/index.ts
53
+ var import_unplugin = require("unplugin");
54
+ var babel = __toESM(require("@babel/core"), 1);
55
+ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
56
+ var import_vite = require("vite");
57
+ var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
58
+ var DEFAULT_OPTIONS = {
59
+ symbol: "$",
60
+ props: true,
61
+ ssg: false
62
+ };
63
+ var unpluginFactory = (options = {}) => {
64
+ const filter = (0, import_vite.createFilter)(options.include, options.exclude);
65
+ return {
66
+ name: "unplugin-essor",
67
+ // enforce: 'pre',
68
+ config() {
69
+ return {
70
+ esbuild: {
71
+ jsx: "preserve"
72
+ }
73
+ };
74
+ },
75
+ transform(code, id) {
76
+ if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
77
+ return;
78
+ }
79
+ if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
80
+ return null;
81
+ }
82
+ const result = babel.transformSync(code, {
83
+ filename: id,
84
+ sourceMaps: true,
85
+ sourceType: "module",
86
+ plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
87
+ });
88
+ if (result == null ? void 0 : result.code) {
89
+ return {
90
+ code: result.code,
91
+ map: result.map
92
+ };
93
+ }
94
+ return code;
95
+ },
96
+ handleHotUpdate(ctx) {
97
+ var _a, _b;
98
+ for (const mod of ctx.modules) {
99
+ const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
100
+ if (deps && deps.length > 0) {
101
+ for (const dep of deps) {
102
+ const mod2 = ctx.server.moduleGraph.getModuleById(dep);
103
+ if (mod2) {
104
+ ctx.server.moduleGraph.invalidateModule(mod2);
105
+ }
106
+ }
107
+ } else if (mod.type === "js" && Array.from(mod.importers).every(
108
+ (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
109
+ var _a2;
110
+ return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
111
+ })
112
+ )) {
113
+ ctx.server.moduleGraph.invalidateAll();
114
+ }
115
+ }
116
+ if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
117
+ ctx.server.ws.send({
118
+ type: "full-reload"
119
+ });
120
+ return [];
121
+ }
122
+ }
123
+ };
124
+ };
125
+
126
+ // src/rspack.ts
127
+ var rspack_default = (0, import_unplugin2.createRspackPlugin)(unpluginFactory);
128
+ //# sourceMappingURL=rspack.cjs.mapexports.default = module.exports;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rspack.ts","../src/index.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createRspackPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAmC;;;ACAnC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,SAAe,oBAAc,MAAM;AAAA,QACvC,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS,CAAC,CAAC,0BAAAC,SAAkB,kCAAK,kBAAoB,QAAS,CAAC;AAAA,MAClE,CAAC;AACD,UAAI,iCAAQ,MAAM;AAChB,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,KAAU;AApD9B;AAqDM,iBAAW,OAAO,IAAI,SAAS;AAC7B,cAAM,QAAO,eAAI,SAAJ,mBAAU,SAAV,mBAAgB;AAC7B,YAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AAjEpE,gBAAAC;AAiEuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD9EA,IAAO,qBAAQ,qCAAmB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
@@ -0,0 +1,6 @@
1
+ import { Options } from './types.cjs';
2
+ import 'vite';
3
+
4
+ declare const _default: (options?: Options | undefined) => _rspack_core_dist_config_zod.RspackPluginInstance;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import { Options } from './types.js';
2
+ import 'vite';
3
+
4
+ declare const _default: (options?: Options | undefined) => _rspack_core_dist_config_zod.RspackPluginInstance;
5
+
6
+ export { _default as default };
package/dist/rspack.js ADDED
@@ -0,0 +1,11 @@
1
+ import {
2
+ unpluginFactory
3
+ } from "./chunk-J2ETW346.js";
4
+
5
+ // src/rspack.ts
6
+ import { createRspackPlugin } from "unplugin";
7
+ var rspack_default = createRspackPlugin(unpluginFactory);
8
+ export {
9
+ rspack_default as default
10
+ };
11
+ //# sourceMappingURL=rspack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createRspackPlugin(unpluginFactory);\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B;AAGnC,IAAO,iBAAQ,mBAAmB,eAAe;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { FilterPattern } from 'vite';\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n ssg?: boolean;\n symbol?: '$';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { FilterPattern } from 'vite';\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n ssg?: boolean;\n props?: boolean;\n symbol?: '$';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/types.d.cts CHANGED
@@ -4,6 +4,7 @@ interface Options {
4
4
  include?: FilterPattern;
5
5
  exclude?: FilterPattern;
6
6
  ssg?: boolean;
7
+ props?: boolean;
7
8
  symbol?: '$';
8
9
  }
9
10
 
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ interface Options {
4
4
  include?: FilterPattern;
5
5
  exclude?: FilterPattern;
6
6
  ssg?: boolean;
7
+ props?: boolean;
7
8
  symbol?: '$';
8
9
  }
9
10
 
package/dist/vite.cjs CHANGED
@@ -56,7 +56,9 @@ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
56
56
  var import_vite = require("vite");
57
57
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
58
58
  var DEFAULT_OPTIONS = {
59
- symbol: "$"
59
+ symbol: "$",
60
+ props: true,
61
+ ssg: false
60
62
  };
61
63
  var unpluginFactory = (options = {}) => {
62
64
  const filter = (0, import_vite.createFilter)(options.include, options.exclude);
package/dist/vite.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite.ts","../src/index.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createVitePlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAiC;;;ACAjC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AACV;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,SAAe,oBAAc,MAAM;AAAA,QACvC,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS,CAAC,CAAC,0BAAAC,SAAkB,kCAAK,kBAAoB,QAAS,CAAC;AAAA,MAClE,CAAC;AACD,UAAI,iCAAQ,MAAM;AAChB,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,KAAU;AAlD9B;AAmDM,iBAAW,OAAO,IAAI,SAAS;AAC7B,cAAM,QAAO,eAAI,SAAJ,mBAAU,SAAV,mBAAgB;AAC7B,YAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AA/DpE,gBAAAC;AA+DuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD5EA,IAAO,mBAAQ,mCAAiB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
1
+ {"version":3,"sources":["../src/vite.ts","../src/index.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createVitePlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAiC;;;ACAjC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAA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AQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD9EA,IAAO,mBAAQ,mCAAiB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-IVXV4IDU.js";
3
+ } from "./chunk-J2ETW346.js";
4
4
 
5
5
  // src/vite.ts
6
6
  import { createVitePlugin } from "unplugin";
package/dist/webpack.cjs CHANGED
@@ -56,7 +56,9 @@ var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
56
56
  var import_vite = require("vite");
57
57
  var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
58
58
  var DEFAULT_OPTIONS = {
59
- symbol: "$"
59
+ symbol: "$",
60
+ props: true,
61
+ ssg: false
60
62
  };
61
63
  var unpluginFactory = (options = {}) => {
62
64
  const filter = (0, import_vite.createFilter)(options.include, options.exclude);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack.ts","../src/index.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createWebpackPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAoC;;;ACApC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AACV;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,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cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD5EA,IAAO,sBAAQ,sCAAoB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
1
+ {"version":3,"sources":["../src/webpack.ts","../src/index.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createWebpackPlugin(unpluginFactory);\n","import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n props: true,\n ssg: false,\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAoC;;;ACApC,sBAA+B;AAC/B,YAAuB;AACvB,gCAA6B;AAC7B,kBAA6B;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AACP;AAEO,IAAM,kBAAwD,CAAC,UAAU,CAAC,MAAM;AACrF,QAAM,aAAS,0BAAa,QAAQ,SAAS,QAAQ,OAAO;AAE5D,SAAO;AAAA,IACL,MAAM;AAAA;AAAA,IAEN,SAAS;AACP,aAAO;AAAA,QACL,SAAS;AAAA,UACP,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU,MAAM,IAAI;AAClB,UAAI,CAAC,gBAAgB,QAAQ,QAAQ,EAAE,KAAK,OAAK,GAAG,SAAS,CAAC,CAAC,GAAG;AAChE;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,KAAK,EAAE,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,SAAe,oBAAc,MAAM;AAAA,QACvC,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS,CAAC,CAAC,0BAAAC,SAAkB,kCAAK,kBAAoB,QAAS,CAAC;AAAA,MAClE,CAAC;AACD,UAAI,iCAAQ,MAAM;AAChB,eAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,KAAU;AApD9B;AAqDM,iBAAW,OAAO,IAAI,SAAS;AAC7B,cAAM,QAAO,eAAI,SAAJ,mBAAU,SAAV,mBAAgB;AAC7B,YAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,qBAAW,OAAO,MAAM;AACtB,kBAAMC,OAAM,IAAI,OAAO,YAAY,cAAc,GAAG;AACpD,gBAAIA,MAAK;AACP,kBAAI,OAAO,YAAY,iBAAiBA,IAAG;AAAA,YAC7C;AAAA,UACF;AAAA,QACF,WACE,IAAI,SAAS,QACb,MAAM,KAAK,IAAI,SAAS,EAAE;AAAA,UACxB,CAAC,MAAW,EAAE,SAAS,SAAS,eAAe,KAAK,SAAI;AAjEpE,gBAAAC;AAiEuE,oBAAAA,MAAA,EAAE,SAAF,gBAAAA,IAAQ,SAAS;AAAA,WAAI;AAAA,QAClF,GACA;AAEA,cAAI,OAAO,YAAY,cAAc;AAAA,QACvC;AAAA,MACF;AAEA,UAAI,eAAe,KAAK,SAAO,IAAI,KAAK,SAAS,GAAG,CAAC,GAAG;AACtD,YAAI,OAAO,GAAG,KAAK;AAAA,UACjB,MAAM;AAAA,QACR,CAAC;AACD,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;;;AD9EA,IAAO,sBAAQ,sCAAoB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-IVXV4IDU.js";
3
+ } from "./chunk-J2ETW346.js";
4
4
 
5
5
  // src/webpack.ts
6
6
  import { createWebpackPlugin } from "unplugin";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-essor",
3
- "version": "0.0.7-beta.6",
3
+ "version": "0.0.10-beta.21",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -23,6 +23,16 @@
23
23
  "require": "./dist/index.cjs",
24
24
  "import": "./dist/index.js"
25
25
  },
26
+ "./astro": {
27
+ "types": "./dist/astro.d.ts",
28
+ "require": "./dist/astro.cjs",
29
+ "import": "./dist/astro.js"
30
+ },
31
+ "./rspack": {
32
+ "types": "./dist/rspack.d.ts",
33
+ "require": "./dist/rspack.cjs",
34
+ "import": "./dist/rspack.js"
35
+ },
26
36
  "./vite": {
27
37
  "types": "./dist/vite.d.ts",
28
38
  "require": "./dist/vite.cjs",
@@ -79,19 +89,19 @@
79
89
  }
80
90
  },
81
91
  "dependencies": {
82
- "@babel/core": "^7.24.7",
83
- "unplugin": "^1.11.0",
84
- "babel-plugin-essor": "0.0.7-beta.6"
92
+ "@babel/core": "^7.25.2",
93
+ "unplugin": "^1.12.3",
94
+ "babel-plugin-essor": "0.0.10-beta.21"
85
95
  },
86
96
  "devDependencies": {
97
+ "@types/node": "^22.5.1",
98
+ "chalk": "^5.3.0",
87
99
  "fast-glob": "^3.3.2",
88
- "nodemon": "^3.1.4",
89
- "rimraf": "^6.0.0",
90
- "rollup": "^4.18.1",
91
- "tsup": "^8.1.0",
92
- "typescript": "^5.5.3",
93
- "vite": "^5.3.3",
94
- "webpack": "^5.92.1"
100
+ "rollup": "^4.21.2",
101
+ "tsup": "^8.2.4",
102
+ "typescript": "^5.5.4",
103
+ "vite": "^5.4.2",
104
+ "webpack": "^5.94.0"
95
105
  },
96
106
  "scripts": {
97
107
  "build": "tsup",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin';\nimport * as babel from '@babel/core';\nimport essorBabelPlugin from 'babel-plugin-essor';\nimport { createFilter } from 'vite';\nimport type { UnpluginFactory } from 'unplugin';\nimport type { Options } from './types';\n\nconst CSS_EXTENSIONS = ['.css', '.scss', '.sass'];\n\nconst DEFAULT_OPTIONS = {\n symbol: '$',\n};\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const filter = createFilter(options.include, options.exclude);\n\n return {\n name: 'unplugin-essor',\n // enforce: 'pre',\n config() {\n return {\n esbuild: {\n jsx: 'preserve',\n },\n };\n },\n\n transform(code, id) {\n if (['node_modules', 'dist', 'public'].some(p => id.includes(p))) {\n return;\n }\n //\n if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {\n return null;\n }\n\n const result = babel.transformSync(code, {\n filename: id,\n sourceMaps: true,\n sourceType: 'module',\n plugins: [[essorBabelPlugin, { ...DEFAULT_OPTIONS, ...options }]],\n });\n if (result?.code) {\n return {\n code: result.code,\n map: result.map,\n };\n }\n return code;\n },\n handleHotUpdate(ctx: any) {\n for (const mod of ctx.modules) {\n const deps = mod.info?.meta?.deps;\n if (deps && deps.length > 0) {\n for (const dep of deps) {\n const mod = ctx.server.moduleGraph.getModuleById(dep);\n if (mod) {\n ctx.server.moduleGraph.invalidateModule(mod);\n }\n }\n } else if (\n mod.type === 'js' &&\n Array.from(mod.importers).every(\n (m: any) => m.type === 'css' || CSS_EXTENSIONS.some(ext => m.file?.endsWith(ext)),\n )\n ) {\n // invalidate all modules that import this module\n ctx.server.moduleGraph.invalidateAll();\n }\n }\n\n if (CSS_EXTENSIONS.some(ext => ctx.file.endsWith(ext))) {\n ctx.server.ws.send({\n type: 'full-reload',\n });\n return [];\n }\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AACvB,OAAO,sBAAsB;AAC7B,SAAS,oBAAoB;AAI7B,IAAM,iBAAiB,CAAC,QAAQ,SAAS,OAAO;AAEhD,IAAM,kBA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