unplugin-essor 0.0.5-beta.5 → 0.0.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
3
+ Copyright (c) 2021-Present jiangxd <jiangxd2016@gmail.com>
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
6
6
  in the Software without restriction, including without limitation the rights
package/dist/index.cjs CHANGED
@@ -1,24 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __getProtoOf = Object.getPrototypeOf;
8
5
  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
6
  var __export = (target, all) => {
23
7
  for (var name in all)
24
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -31,99 +15,20 @@ var __copyProps = (to, from, except, desc) => {
31
15
  }
32
16
  return to;
33
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
19
 
44
20
  // src/index.ts
45
21
  var src_exports = {};
46
22
  __export(src_exports, {
47
- default: () => src_default,
48
- unplugin: () => unplugin,
49
- unpluginFactory: () => unpluginFactory
23
+ one: () => one,
24
+ two: () => two
50
25
  });
51
26
  module.exports = __toCommonJS(src_exports);
52
- var import_unplugin = require("unplugin");
53
- var babel = __toESM(require("@babel/core"), 1);
54
- var import_babel_plugin_essor = __toESM(require("babel-plugin-essor"), 1);
55
- var import_vite = require("vite");
56
- var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
57
- var DEFAULT_OPTIONS = {
58
- symbol: "$"
59
- };
60
- var unpluginFactory = (options = {}) => {
61
- const filter = (0, import_vite.createFilter)(options.include, options.exclude);
62
- return {
63
- name: "unplugin-essor",
64
- // enforce: 'pre',
65
- config() {
66
- return {
67
- esbuild: {
68
- jsx: "preserve"
69
- }
70
- };
71
- },
72
- transform(code, id) {
73
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
74
- return;
75
- }
76
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
77
- return null;
78
- }
79
- const result = babel.transformSync(code, {
80
- filename: id,
81
- sourceMaps: true,
82
- sourceType: "module",
83
- plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
84
- });
85
- if (result == null ? void 0 : result.code) {
86
- return {
87
- code: result.code,
88
- map: result.map
89
- };
90
- }
91
- return code;
92
- },
93
- handleHotUpdate(ctx) {
94
- var _a, _b;
95
- for (const mod of ctx.modules) {
96
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
97
- if (deps && deps.length > 0) {
98
- for (const dep of deps) {
99
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
100
- if (mod2) {
101
- ctx.server.moduleGraph.invalidateModule(mod2);
102
- }
103
- }
104
- } else if (mod.type === "js" && Array.from(mod.importers).every(
105
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
106
- var _a2;
107
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
108
- })
109
- )) {
110
- ctx.server.moduleGraph.invalidateAll();
111
- }
112
- }
113
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
114
- ctx.server.ws.send({
115
- type: "full-reload"
116
- });
117
- return [];
118
- }
119
- }
120
- };
121
- };
122
- var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
123
- var src_default = unplugin;
27
+ var one = 1;
28
+ var two = 2;
124
29
  // Annotate the CommonJS export names for ESM import in node:
125
30
  0 && (module.exports = {
126
- unplugin,
127
- unpluginFactory
31
+ one,
32
+ two
128
33
  });
129
- //# sourceMappingURL=index.cjs.mapexports.default = module.exports;
34
+ //# sourceMappingURL=index.cjs.map
@@ -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;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;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,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;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;AAEO,IAAM,WAA2B,oDAAe,eAAe;AAEtE,IAAO,cAAQ;","names":["essorBabelPlugin","mod","_a"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const one = 1;\nexport const two = 2;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,MAAM;AACZ,IAAM,MAAM;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- import * as _unplugin from 'unplugin';
2
- import { UnpluginFactory } from 'unplugin';
3
- import { Options } from './types.js';
4
- import 'vite';
1
+ declare const one = 1;
2
+ declare const two = 2;
5
3
 
6
- declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
8
-
9
- export { unplugin as default, unplugin, unpluginFactory };
4
+ export { one, two };
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
1
- import {
2
- src_default,
3
- unplugin,
4
- unpluginFactory
5
- } from "./chunk-JHCDFX62.js";
1
+ // src/index.ts
2
+ var one = 1;
3
+ var two = 2;
6
4
  export {
7
- src_default as default,
8
- unplugin,
9
- unpluginFactory
5
+ one,
6
+ two
10
7
  };
11
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const one = 1;\nexport const two = 2;\n"],"mappings":";AAAO,IAAM,MAAM;AACZ,IAAM,MAAM;","names":[]}
package/package.json CHANGED
@@ -1,102 +1,63 @@
1
1
  {
2
2
  "name": "unplugin-essor",
3
- "version": "0.0.5-beta.5",
4
- "packageManager": "pnpm@8.15.6",
5
- "description": "",
6
3
  "type": "module",
7
- "keywords": [
8
- "unplugin",
9
- "vite",
10
- "webpack",
11
- "rollup",
12
- "transform"
13
- ],
4
+ "version": "0.0.5",
5
+ "packageManager": "pnpm@7.2.1",
6
+ "description": "",
7
+ "author": "jiangxd <jiangxd2016@gmail.com>",
14
8
  "license": "MIT",
15
- "files": [
16
- "dist"
17
- ],
18
- "main": "dist/index.cjs",
19
- "module": "dist/index.js",
20
- "types": "dist/index.d.ts",
9
+ "funding": "https://github.com/sponsors/estjs",
10
+ "homepage": "https://github.com/estjs/vipassana#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/estjs/vipassana.git"
14
+ },
15
+ "bugs": "https://github.com/estjs/vipassana/issues",
16
+ "keywords": [],
17
+ "sideEffects": false,
21
18
  "exports": {
22
19
  ".": {
23
20
  "types": "./dist/index.d.ts",
24
- "require": "./dist/index.cjs",
25
- "import": "./dist/index.js"
26
- },
27
- "./vite": {
28
- "types": "./dist/vite.d.ts",
29
- "require": "./dist/vite.cjs",
30
- "import": "./dist/vite.js"
31
- },
32
- "./webpack": {
33
- "types": "./dist/webpack.d.ts",
34
- "require": "./dist/webpack.cjs",
35
- "import": "./dist/webpack.js"
36
- },
37
- "./rollup": {
38
- "types": "./dist/rollup.d.ts",
39
- "require": "./dist/rollup.cjs",
40
- "import": "./dist/rollup.js"
41
- },
42
- "./esbuild": {
43
- "types": "./dist/esbuild.d.ts",
44
- "require": "./dist/esbuild.cjs",
45
- "import": "./dist/esbuild.js"
46
- },
47
- "./types": {
48
- "types": "./dist/types.d.ts",
49
- "require": "./dist/types.cjs",
50
- "import": "./dist/types.js"
51
- },
52
- "./*": "./*"
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.cjs"
23
+ }
53
24
  },
25
+ "main": "./dist/index.mjs",
26
+ "module": "./dist/index.mjs",
27
+ "types": "./dist/index.d.ts",
54
28
  "typesVersions": {
55
29
  "*": {
56
30
  "*": [
57
31
  "./dist/*",
58
- "./*"
32
+ "./dist/index.d.ts"
59
33
  ]
60
34
  }
61
35
  },
62
- "peerDependencies": {
63
- "esbuild": "*",
64
- "rollup": "^4",
65
- "vite": ">=3",
66
- "webpack": "^4 || ^5"
67
- },
68
- "peerDependenciesMeta": {
69
- "esbuild": {
70
- "optional": true
71
- },
72
- "rollup": {
73
- "optional": true
74
- },
75
- "vite": {
76
- "optional": true
77
- },
78
- "webpack": {
79
- "optional": true
80
- }
81
- },
82
- "dependencies": {
83
- "@babel/core": "^7.24.4",
84
- "unplugin": "^1.10.1",
85
- "babel-plugin-essor": "0.0.5-beta.5"
86
- },
36
+ "files": [
37
+ "dist"
38
+ ],
87
39
  "devDependencies": {
88
- "fast-glob": "^3.3.2",
89
- "nodemon": "^3.1.0",
90
- "rimraf": "^5.0.5",
91
- "rollup": "^4.14.1",
92
- "tsup": "^8.0.2",
93
- "typescript": "^5.4.4",
94
- "vite": "^5.2.8",
95
- "webpack": "^5.91.0"
40
+ "@estjs/eslint-config": "^0.6.7",
41
+ "@vitest/coverage-v8": "^0.34.2",
42
+ "bumpp": "^9.1.0",
43
+ "dayjs": "^1.11.7",
44
+ "eslint": "^8.38.0",
45
+ "pnpm": "^8.2.0",
46
+ "tsup": "^6.7.0",
47
+ "typescript": "^5.0.4",
48
+ "vitest": "^0.30.1"
96
49
  },
97
50
  "scripts": {
51
+ "dev": "tsup --watch",
98
52
  "build": "tsup",
99
- "build:fix": "node ./scripts/postbuild.js",
100
- "dev": "cross-env NODE_ENV=production tsup --watch"
53
+ "lint": "eslint --cache --fix \"./src/*.{ts,tsx,js,vue}\"",
54
+ "test": "vitest -r test",
55
+ "play": "pnpm run -C playground dev",
56
+ "play:build": "pnpm run -C playground build",
57
+ "play:test": "pnpm run -C playground test -u",
58
+ "play:preview": "pnpm run -C playground preview",
59
+ "typecheck": "tsc --noEmit",
60
+ "coverage": "vitest run --coverage",
61
+ "release": " pnpm publish --access public"
101
62
  }
102
63
  }
@@ -1,97 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
-
18
- // src/index.ts
19
- import { createUnplugin } from "unplugin";
20
- import * as babel from "@babel/core";
21
- import essorBabelPlugin from "babel-plugin-essor";
22
- import { createFilter } from "vite";
23
- var CSS_EXTENSIONS = [".css", ".scss", ".sass"];
24
- var DEFAULT_OPTIONS = {
25
- symbol: "$"
26
- };
27
- var unpluginFactory = (options = {}) => {
28
- const filter = createFilter(options.include, options.exclude);
29
- return {
30
- name: "unplugin-essor",
31
- // enforce: 'pre',
32
- config() {
33
- return {
34
- esbuild: {
35
- jsx: "preserve"
36
- }
37
- };
38
- },
39
- transform(code, id) {
40
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
41
- return;
42
- }
43
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
44
- return null;
45
- }
46
- const result = babel.transformSync(code, {
47
- filename: id,
48
- sourceMaps: true,
49
- sourceType: "module",
50
- plugins: [[essorBabelPlugin, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
51
- });
52
- if (result == null ? void 0 : result.code) {
53
- return {
54
- code: result.code,
55
- map: result.map
56
- };
57
- }
58
- return code;
59
- },
60
- handleHotUpdate(ctx) {
61
- var _a, _b;
62
- for (const mod of ctx.modules) {
63
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
64
- if (deps && deps.length > 0) {
65
- for (const dep of deps) {
66
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
67
- if (mod2) {
68
- ctx.server.moduleGraph.invalidateModule(mod2);
69
- }
70
- }
71
- } else if (mod.type === "js" && Array.from(mod.importers).every(
72
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
73
- var _a2;
74
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
75
- })
76
- )) {
77
- ctx.server.moduleGraph.invalidateAll();
78
- }
79
- }
80
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
81
- ctx.server.ws.send({
82
- type: "full-reload"
83
- });
84
- return [];
85
- }
86
- }
87
- };
88
- };
89
- var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
90
- var src_default = unplugin;
91
-
92
- export {
93
- unpluginFactory,
94
- unplugin,
95
- src_default
96
- };
97
- //# sourceMappingURL=chunk-JHCDFX62.js.map
@@ -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,kBAAkB;AAAA,EACtB,QAAQ;AACV;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,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,kBAAkB,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,kBAAMA,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;AAEO,IAAM,WAA2B,+BAAe,eAAe;AAEtE,IAAO,cAAQ;","names":["mod","_a"]}
package/dist/esbuild.cjs DELETED
@@ -1,126 +0,0 @@
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/esbuild.ts
45
- var esbuild_exports = {};
46
- __export(esbuild_exports, {
47
- default: () => esbuild_default
48
- });
49
- module.exports = __toCommonJS(esbuild_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
- };
61
- var unpluginFactory = (options = {}) => {
62
- const filter = (0, import_vite.createFilter)(options.include, options.exclude);
63
- return {
64
- name: "unplugin-essor",
65
- // enforce: 'pre',
66
- config() {
67
- return {
68
- esbuild: {
69
- jsx: "preserve"
70
- }
71
- };
72
- },
73
- transform(code, id) {
74
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
75
- return;
76
- }
77
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
78
- return null;
79
- }
80
- const result = babel.transformSync(code, {
81
- filename: id,
82
- sourceMaps: true,
83
- sourceType: "module",
84
- plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
85
- });
86
- if (result == null ? void 0 : result.code) {
87
- return {
88
- code: result.code,
89
- map: result.map
90
- };
91
- }
92
- return code;
93
- },
94
- handleHotUpdate(ctx) {
95
- var _a, _b;
96
- for (const mod of ctx.modules) {
97
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
98
- if (deps && deps.length > 0) {
99
- for (const dep of deps) {
100
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
101
- if (mod2) {
102
- ctx.server.moduleGraph.invalidateModule(mod2);
103
- }
104
- }
105
- } else if (mod.type === "js" && Array.from(mod.importers).every(
106
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
107
- var _a2;
108
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
109
- })
110
- )) {
111
- ctx.server.moduleGraph.invalidateAll();
112
- }
113
- }
114
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
115
- ctx.server.ws.send({
116
- type: "full-reload"
117
- });
118
- return [];
119
- }
120
- }
121
- };
122
- };
123
-
124
- // src/esbuild.ts
125
- var esbuild_default = (0, import_unplugin2.createEsbuildPlugin)(unpluginFactory);
126
- //# sourceMappingURL=esbuild.cjs.mapexports.default = module.exports;
@@ -1 +0,0 @@
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;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,sBAAQ,sCAAoB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
@@ -1,7 +0,0 @@
1
- import * as esbuild from 'esbuild';
2
- import { Options } from './types.cjs';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => esbuild.Plugin;
6
-
7
- export { _default as default };
package/dist/esbuild.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as esbuild from 'esbuild';
2
- import { Options } from './types.js';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => esbuild.Plugin;
6
-
7
- export { _default as default };
package/dist/esbuild.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- unpluginFactory
3
- } from "./chunk-JHCDFX62.js";
4
-
5
- // src/esbuild.ts
6
- import { createEsbuildPlugin } from "unplugin";
7
- var esbuild_default = createEsbuildPlugin(unpluginFactory);
8
- export {
9
- esbuild_default as default
10
- };
11
- //# sourceMappingURL=esbuild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createEsbuildPlugin(unpluginFactory);\n"],"mappings":";;;;;AAAA,SAAS,2BAA2B;AAGpC,IAAO,kBAAQ,oBAAoB,eAAe;","names":[]}
package/dist/index.d.cts DELETED
@@ -1,9 +0,0 @@
1
- import * as _unplugin from 'unplugin';
2
- import { UnpluginFactory } from 'unplugin';
3
- import { Options } from './types.cjs';
4
- import 'vite';
5
-
6
- declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
8
-
9
- export { unplugin as default, unplugin, unpluginFactory };
package/dist/rollup.cjs DELETED
@@ -1,126 +0,0 @@
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/rollup.ts
45
- var rollup_exports = {};
46
- __export(rollup_exports, {
47
- default: () => rollup_default
48
- });
49
- module.exports = __toCommonJS(rollup_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
- };
61
- var unpluginFactory = (options = {}) => {
62
- const filter = (0, import_vite.createFilter)(options.include, options.exclude);
63
- return {
64
- name: "unplugin-essor",
65
- // enforce: 'pre',
66
- config() {
67
- return {
68
- esbuild: {
69
- jsx: "preserve"
70
- }
71
- };
72
- },
73
- transform(code, id) {
74
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
75
- return;
76
- }
77
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
78
- return null;
79
- }
80
- const result = babel.transformSync(code, {
81
- filename: id,
82
- sourceMaps: true,
83
- sourceType: "module",
84
- plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
85
- });
86
- if (result == null ? void 0 : result.code) {
87
- return {
88
- code: result.code,
89
- map: result.map
90
- };
91
- }
92
- return code;
93
- },
94
- handleHotUpdate(ctx) {
95
- var _a, _b;
96
- for (const mod of ctx.modules) {
97
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
98
- if (deps && deps.length > 0) {
99
- for (const dep of deps) {
100
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
101
- if (mod2) {
102
- ctx.server.moduleGraph.invalidateModule(mod2);
103
- }
104
- }
105
- } else if (mod.type === "js" && Array.from(mod.importers).every(
106
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
107
- var _a2;
108
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
109
- })
110
- )) {
111
- ctx.server.moduleGraph.invalidateAll();
112
- }
113
- }
114
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
115
- ctx.server.ws.send({
116
- type: "full-reload"
117
- });
118
- return [];
119
- }
120
- }
121
- };
122
- };
123
-
124
- // src/rollup.ts
125
- var rollup_default = (0, import_unplugin2.createRollupPlugin)(unpluginFactory);
126
- //# sourceMappingURL=rollup.cjs.mapexports.default = module.exports;
@@ -1 +0,0 @@
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;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,qBAAQ,qCAAmB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
package/dist/rollup.d.cts DELETED
@@ -1,7 +0,0 @@
1
- import * as rollup from 'rollup';
2
- import { Options } from './types.cjs';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
6
-
7
- export { _default as default };
package/dist/rollup.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as rollup from 'rollup';
2
- import { Options } from './types.js';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
6
-
7
- export { _default as default };
package/dist/rollup.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- unpluginFactory
3
- } from "./chunk-JHCDFX62.js";
4
-
5
- // src/rollup.ts
6
- import { createRollupPlugin } from "unplugin";
7
- var rollup_default = createRollupPlugin(unpluginFactory);
8
- export {
9
- rollup_default as default
10
- };
11
- //# sourceMappingURL=rollup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/rollup.ts"],"sourcesContent":["import { createRollupPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createRollupPlugin(unpluginFactory);\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B;AAGnC,IAAO,iBAAQ,mBAAmB,eAAe;","names":[]}
package/dist/types.cjs DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types.ts
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- //# sourceMappingURL=types.cjs.mapexports.default = module.exports;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { FilterPattern } from 'vite';\nexport interface Options {\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * the plugin should operate on.\n */\n include?: FilterPattern;\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * to be ignored by the plugin.\n */\n exclude?: FilterPattern;\n\n /**\n * This will force SSR code in the produced files. This is experiemental\n * and mostly not working yet.\n *\n * @default false\n */\n ssr?: boolean;\n\n /**\n * This will inject HMR runtime in dev mode. Has no effect in prod. If\n * set to `false`, it won't inject the runtime in dev.\n * @todo\n * @deprecated use `refresh` instead\n * @default true\n */\n hot?: boolean;\n\n symbol?: '$';\n shallowSymbol?: '$$';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/types.d.cts DELETED
@@ -1,33 +0,0 @@
1
- import { FilterPattern } from 'vite';
2
-
3
- interface Options {
4
- /**
5
- * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
6
- * the plugin should operate on.
7
- */
8
- include?: FilterPattern;
9
- /**
10
- * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
11
- * to be ignored by the plugin.
12
- */
13
- exclude?: FilterPattern;
14
- /**
15
- * This will force SSR code in the produced files. This is experiemental
16
- * and mostly not working yet.
17
- *
18
- * @default false
19
- */
20
- ssr?: boolean;
21
- /**
22
- * This will inject HMR runtime in dev mode. Has no effect in prod. If
23
- * set to `false`, it won't inject the runtime in dev.
24
- * @todo
25
- * @deprecated use `refresh` instead
26
- * @default true
27
- */
28
- hot?: boolean;
29
- symbol?: '$';
30
- shallowSymbol?: '$$';
31
- }
32
-
33
- export type { Options };
package/dist/types.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import { FilterPattern } from 'vite';
2
-
3
- interface Options {
4
- /**
5
- * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
6
- * the plugin should operate on.
7
- */
8
- include?: FilterPattern;
9
- /**
10
- * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files
11
- * to be ignored by the plugin.
12
- */
13
- exclude?: FilterPattern;
14
- /**
15
- * This will force SSR code in the produced files. This is experiemental
16
- * and mostly not working yet.
17
- *
18
- * @default false
19
- */
20
- ssr?: boolean;
21
- /**
22
- * This will inject HMR runtime in dev mode. Has no effect in prod. If
23
- * set to `false`, it won't inject the runtime in dev.
24
- * @todo
25
- * @deprecated use `refresh` instead
26
- * @default true
27
- */
28
- hot?: boolean;
29
- symbol?: '$';
30
- shallowSymbol?: '$$';
31
- }
32
-
33
- export type { Options };
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/vite.cjs DELETED
@@ -1,126 +0,0 @@
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/vite.ts
45
- var vite_exports = {};
46
- __export(vite_exports, {
47
- default: () => vite_default
48
- });
49
- module.exports = __toCommonJS(vite_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
- };
61
- var unpluginFactory = (options = {}) => {
62
- const filter = (0, import_vite.createFilter)(options.include, options.exclude);
63
- return {
64
- name: "unplugin-essor",
65
- // enforce: 'pre',
66
- config() {
67
- return {
68
- esbuild: {
69
- jsx: "preserve"
70
- }
71
- };
72
- },
73
- transform(code, id) {
74
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
75
- return;
76
- }
77
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
78
- return null;
79
- }
80
- const result = babel.transformSync(code, {
81
- filename: id,
82
- sourceMaps: true,
83
- sourceType: "module",
84
- plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
85
- });
86
- if (result == null ? void 0 : result.code) {
87
- return {
88
- code: result.code,
89
- map: result.map
90
- };
91
- }
92
- return code;
93
- },
94
- handleHotUpdate(ctx) {
95
- var _a, _b;
96
- for (const mod of ctx.modules) {
97
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
98
- if (deps && deps.length > 0) {
99
- for (const dep of deps) {
100
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
101
- if (mod2) {
102
- ctx.server.moduleGraph.invalidateModule(mod2);
103
- }
104
- }
105
- } else if (mod.type === "js" && Array.from(mod.importers).every(
106
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
107
- var _a2;
108
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
109
- })
110
- )) {
111
- ctx.server.moduleGraph.invalidateAll();
112
- }
113
- }
114
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
115
- ctx.server.ws.send({
116
- type: "full-reload"
117
- });
118
- return [];
119
- }
120
- }
121
- };
122
- };
123
-
124
- // src/vite.ts
125
- var vite_default = (0, import_unplugin2.createVitePlugin)(unpluginFactory);
126
- //# sourceMappingURL=vite.cjs.mapexports.default = module.exports;
package/dist/vite.cjs.map DELETED
@@ -1 +0,0 @@
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"]}
package/dist/vite.d.cts DELETED
@@ -1,6 +0,0 @@
1
- import * as vite from 'vite';
2
- import { Options } from './types.cjs';
3
-
4
- declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
-
6
- export { _default as default };
package/dist/vite.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import * as vite from 'vite';
2
- import { Options } from './types.js';
3
-
4
- declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
-
6
- export { _default as default };
package/dist/vite.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- unpluginFactory
3
- } from "./chunk-JHCDFX62.js";
4
-
5
- // src/vite.ts
6
- import { createVitePlugin } from "unplugin";
7
- var vite_default = createVitePlugin(unpluginFactory);
8
- export {
9
- vite_default as default
10
- };
11
- //# sourceMappingURL=vite.js.map
package/dist/vite.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createVitePlugin(unpluginFactory);\n"],"mappings":";;;;;AAAA,SAAS,wBAAwB;AAGjC,IAAO,eAAQ,iBAAiB,eAAe;","names":[]}
package/dist/webpack.cjs DELETED
@@ -1,126 +0,0 @@
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/webpack.ts
45
- var webpack_exports = {};
46
- __export(webpack_exports, {
47
- default: () => webpack_default
48
- });
49
- module.exports = __toCommonJS(webpack_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
- };
61
- var unpluginFactory = (options = {}) => {
62
- const filter = (0, import_vite.createFilter)(options.include, options.exclude);
63
- return {
64
- name: "unplugin-essor",
65
- // enforce: 'pre',
66
- config() {
67
- return {
68
- esbuild: {
69
- jsx: "preserve"
70
- }
71
- };
72
- },
73
- transform(code, id) {
74
- if (["node_modules", "dist", "public"].some((p) => id.includes(p))) {
75
- return;
76
- }
77
- if (!filter(id) || !/.[cm]?[jt]sx?$/i.test(id)) {
78
- return null;
79
- }
80
- const result = babel.transformSync(code, {
81
- filename: id,
82
- sourceMaps: true,
83
- sourceType: "module",
84
- plugins: [[import_babel_plugin_essor.default, __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options)]]
85
- });
86
- if (result == null ? void 0 : result.code) {
87
- return {
88
- code: result.code,
89
- map: result.map
90
- };
91
- }
92
- return code;
93
- },
94
- handleHotUpdate(ctx) {
95
- var _a, _b;
96
- for (const mod of ctx.modules) {
97
- const deps = (_b = (_a = mod.info) == null ? void 0 : _a.meta) == null ? void 0 : _b.deps;
98
- if (deps && deps.length > 0) {
99
- for (const dep of deps) {
100
- const mod2 = ctx.server.moduleGraph.getModuleById(dep);
101
- if (mod2) {
102
- ctx.server.moduleGraph.invalidateModule(mod2);
103
- }
104
- }
105
- } else if (mod.type === "js" && Array.from(mod.importers).every(
106
- (m) => m.type === "css" || CSS_EXTENSIONS.some((ext) => {
107
- var _a2;
108
- return (_a2 = m.file) == null ? void 0 : _a2.endsWith(ext);
109
- })
110
- )) {
111
- ctx.server.moduleGraph.invalidateAll();
112
- }
113
- }
114
- if (CSS_EXTENSIONS.some((ext) => ctx.file.endsWith(ext))) {
115
- ctx.server.ws.send({
116
- type: "full-reload"
117
- });
118
- return [];
119
- }
120
- }
121
- };
122
- };
123
-
124
- // src/webpack.ts
125
- var webpack_default = (0, import_unplugin2.createWebpackPlugin)(unpluginFactory);
126
- //# sourceMappingURL=webpack.cjs.mapexports.default = module.exports;
@@ -1 +0,0 @@
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,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,sBAAQ,sCAAoB,eAAe;","names":["import_unplugin","essorBabelPlugin","mod","_a"]}
@@ -1,7 +0,0 @@
1
- import * as webpack from 'webpack';
2
- import { Options } from './types.cjs';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => webpack.WebpackPluginInstance;
6
-
7
- export { _default as default };
package/dist/webpack.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as webpack from 'webpack';
2
- import { Options } from './types.js';
3
- import 'vite';
4
-
5
- declare const _default: (options?: Options | undefined) => webpack.WebpackPluginInstance;
6
-
7
- export { _default as default };
package/dist/webpack.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- unpluginFactory
3
- } from "./chunk-JHCDFX62.js";
4
-
5
- // src/webpack.ts
6
- import { createWebpackPlugin } from "unplugin";
7
- var webpack_default = createWebpackPlugin(unpluginFactory);
8
- export {
9
- webpack_default as default
10
- };
11
- //# sourceMappingURL=webpack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin';\nimport { unpluginFactory } from '.';\n\nexport default createWebpackPlugin(unpluginFactory);\n"],"mappings":";;;;;AAAA,SAAS,2BAA2B;AAGpC,IAAO,kBAAQ,oBAAoB,eAAe;","names":[]}