unplugin-solid-labels 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT License Copyright (c) 2023 Alexis Munsayac
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # unplugin-solid-labels
2
+
3
+ > [Unplugin](https://github.com/unjs/unplugin) for [`solid-labels`](https://github.com/lxsmnsyc/solid-labels)
4
+
5
+ [![NPM](https://img.shields.io/npm/v/unplugin-solid-labels.svg)](https://www.npmjs.com/package/unplugin-solid-labels) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install --D unplugin-solid-labels
11
+ ```
12
+
13
+ ```bash
14
+ yarn add -D unplugin-solid-labels
15
+ ```
16
+
17
+ ```bash
18
+ pnpm add -D unplugin-solid-labels
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```js
24
+ import solidLabels from 'unplugin-solid-labels';
25
+
26
+ ///...
27
+ solidLabels.vite({
28
+ dev: true, // defaults to false
29
+ disabled: {
30
+ labels: {
31
+ signal: true,
32
+ },
33
+ pragma: {
34
+ '@signal': true,
35
+ },
36
+ ctf: {
37
+ $signal: true,
38
+ },
39
+ },
40
+ filter: {
41
+ include: 'src/**/*.{ts,js,tsx,jsx}',
42
+ exclude: 'node_modules/**/*.{ts,js,tsx,jsx}',
43
+ },
44
+ })
45
+ ```
46
+
47
+ ## Sponsors
48
+
49
+ ![Sponsors](https://github.com/lxsmnsyc/sponsors/blob/main/sponsors.svg?raw=true)
50
+
51
+ ## License
52
+
53
+ MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => src_default
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_babel_plugin_solid_labels = __toESM(require("babel-plugin-solid-labels"), 1);
37
+ var babel = __toESM(require("@babel/core"), 1);
38
+ var import_pluginutils = require("@rollup/pluginutils");
39
+ var import_unplugin = require("unplugin");
40
+ var import_path = __toESM(require("path"), 1);
41
+ function repushPlugin(plugins, pluginName, pluginNames) {
42
+ const namesSet = new Set(pluginNames);
43
+ let baseIndex = -1;
44
+ let targetIndex = -1;
45
+ let targetPlugin;
46
+ for (let i = 0, len = plugins.length; i < len; i += 1) {
47
+ const current = plugins[i];
48
+ if (namesSet.has(current.name) && baseIndex === -1) {
49
+ baseIndex = i;
50
+ }
51
+ if (current.name === pluginName) {
52
+ targetIndex = i;
53
+ targetPlugin = current;
54
+ }
55
+ }
56
+ if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
57
+ plugins.splice(targetIndex, 1);
58
+ plugins.splice(baseIndex, 0, targetPlugin);
59
+ }
60
+ }
61
+ var DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
62
+ var DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
63
+ var solidLabelsPlugin = (0, import_unplugin.createUnplugin)((options = {}) => {
64
+ var _a, _b;
65
+ const filter = (0, import_pluginutils.createFilter)(
66
+ ((_a = options.filter) == null ? void 0 : _a.include) || DEFAULT_INCLUDE,
67
+ ((_b = options.filter) == null ? void 0 : _b.exclude) || DEFAULT_EXCLUDE
68
+ );
69
+ let env;
70
+ return {
71
+ name: "solid-labels",
72
+ transformInclude(id) {
73
+ return filter(id);
74
+ },
75
+ async transform(code, id) {
76
+ const plugins = ["jsx"];
77
+ if (/\.[mc]?tsx?$/i.test(id)) {
78
+ plugins.push("typescript");
79
+ }
80
+ const result = await babel.transformAsync(code, {
81
+ plugins: [
82
+ [import_babel_plugin_solid_labels.default, {
83
+ disabled: options.disabled,
84
+ dev: env === "development" || options.dev
85
+ }]
86
+ ],
87
+ parserOpts: {
88
+ plugins
89
+ },
90
+ filename: import_path.default.basename(id),
91
+ ast: false,
92
+ sourceMaps: true,
93
+ configFile: false,
94
+ babelrc: false,
95
+ sourceFileName: id
96
+ });
97
+ if (result) {
98
+ return {
99
+ code: result.code || "",
100
+ map: result.map
101
+ };
102
+ }
103
+ return void 0;
104
+ },
105
+ vite: {
106
+ enforce: "pre",
107
+ configResolved(config) {
108
+ env = config.mode !== "production" ? "development" : "production";
109
+ repushPlugin(config.plugins, "solid-labels", [
110
+ // https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
111
+ "astro:jsx",
112
+ // https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
113
+ "solid",
114
+ // https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
115
+ "solid-start-file-system-router"
116
+ ]);
117
+ }
118
+ }
119
+ };
120
+ });
121
+ var src_default = solidLabelsPlugin;
122
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts"],
4
+ "sourcesContent": ["import type { Options } from 'babel-plugin-solid-labels';\nimport solidLabelsBabel from 'babel-plugin-solid-labels';\nimport * as babel from '@babel/core';\nimport type { Plugin } from 'vite';\nimport type { FilterPattern } from '@rollup/pluginutils';\nimport { createFilter } from '@rollup/pluginutils';\nimport type { TransformResult } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport path from 'path';\n\nexport interface SolidLabelsPluginFilter {\n include?: FilterPattern;\n exclude?: FilterPattern;\n}\n\nexport interface SolidLabelsPluginOptions extends Options {\n filter?: SolidLabelsPluginFilter;\n}\n\n// From: https://github.com/bluwy/whyframe/blob/master/packages/jsx/src/index.js#L27-L37\nfunction repushPlugin(plugins: Plugin[], pluginName: string, pluginNames: string[]): void {\n const namesSet = new Set(pluginNames);\n\n let baseIndex = -1;\n let targetIndex = -1;\n let targetPlugin: Plugin;\n for (let i = 0, len = plugins.length; i < len; i += 1) {\n const current = plugins[i];\n if (namesSet.has(current.name) && baseIndex === -1) {\n baseIndex = i;\n }\n if (current.name === pluginName) {\n targetIndex = i;\n targetPlugin = current;\n }\n }\n if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {\n plugins.splice(targetIndex, 1);\n plugins.splice(baseIndex, 0, targetPlugin!);\n }\n}\n\nconst DEFAULT_INCLUDE = 'src/**/*.{jsx,tsx,ts,js,mjs,cjs}';\nconst DEFAULT_EXCLUDE = 'node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}';\n\nconst solidLabelsPlugin = createUnplugin((options: SolidLabelsPluginOptions = {}) => {\n const filter = createFilter(\n options.filter?.include || DEFAULT_INCLUDE,\n options.filter?.exclude || DEFAULT_EXCLUDE,\n );\n\n let env: string;\n\n return {\n name: 'solid-labels',\n transformInclude(id): boolean {\n return filter(id);\n },\n async transform(code, id): Promise<TransformResult> {\n const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = ['jsx'];\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n const result = await babel.transformAsync(code, {\n plugins: [\n [solidLabelsBabel, {\n disabled: options.disabled,\n dev: env === 'development' || options.dev,\n }],\n ],\n parserOpts: {\n plugins,\n },\n filename: path.basename(id),\n ast: false,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n sourceFileName: id,\n });\n\n if (result) {\n return {\n code: result.code || '',\n map: result.map,\n };\n }\n return undefined;\n },\n vite: {\n enforce: 'pre',\n configResolved(config): void {\n env = config.mode !== 'production' ? 'development' : 'production';\n\n // run our plugin before the following plugins:\n repushPlugin(config.plugins as Plugin[], 'solid-labels', [\n // https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173\n 'astro:jsx',\n // https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305\n 'solid',\n // https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118\n 'solid-start-file-system-router',\n ]);\n },\n },\n };\n});\n\nexport default solidLabelsPlugin;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAA6B;AAC7B,YAAuB;AAGvB,yBAA6B;AAE7B,sBAA+B;AAC/B,kBAAiB;AAYjB,SAAS,aAAa,SAAmB,YAAoB,aAA6B;AACxF,QAAM,WAAW,IAAI,IAAI,WAAW;AAEpC,MAAI,YAAY;AAChB,MAAI,cAAc;AAClB,MAAI;AACJ,WAAS,IAAI,GAAG,MAAM,QAAQ,QAAQ,IAAI,KAAK,KAAK,GAAG;AACrD,UAAM,UAAU,QAAQ,CAAC;AACzB,QAAI,SAAS,IAAI,QAAQ,IAAI,KAAK,cAAc,IAAI;AAClD,kBAAY;AAAA,IACd;AACA,QAAI,QAAQ,SAAS,YAAY;AAC/B,oBAAc;AACd,qBAAe;AAAA,IACjB;AAAA,EACF;AACA,MAAI,cAAc,MAAM,gBAAgB,MAAM,YAAY,aAAa;AACrE,YAAQ,OAAO,aAAa,CAAC;AAC7B,YAAQ,OAAO,WAAW,GAAG,YAAa;AAAA,EAC5C;AACF;AAEA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAExB,IAAM,wBAAoB,gCAAe,CAAC,UAAoC,CAAC,MAAM;AA7CrF;AA8CE,QAAM,aAAS;AAAA,MACb,aAAQ,WAAR,mBAAgB,YAAW;AAAA,MAC3B,aAAQ,WAAR,mBAAgB,YAAW;AAAA,EAC7B;AAEA,MAAI;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,IAAa;AAC5B,aAAO,OAAO,EAAE;AAAA,IAClB;AAAA,IACA,MAAM,UAAU,MAAM,IAA8B;AAClD,YAAM,UAAqF,CAAC,KAAK;AACjG,UAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,gBAAQ,KAAK,YAAY;AAAA,MAC3B;AACA,YAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,QAC9C,SAAS;AAAA,UACP,CAAC,iCAAAA,SAAkB;AAAA,YACjB,UAAU,QAAQ;AAAA,YAClB,KAAK,QAAQ,iBAAiB,QAAQ;AAAA,UACxC,CAAC;AAAA,QACH;AAAA,QACA,YAAY;AAAA,UACV;AAAA,QACF;AAAA,QACA,UAAU,YAAAC,QAAK,SAAS,EAAE;AAAA,QAC1B,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,gBAAgB;AAAA,MAClB,CAAC;AAED,UAAI,QAAQ;AACV,eAAO;AAAA,UACL,MAAM,OAAO,QAAQ;AAAA,UACrB,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,eAAe,QAAc;AAC3B,cAAM,OAAO,SAAS,eAAe,gBAAgB;AAGrD,qBAAa,OAAO,SAAqB,gBAAgB;AAAA;AAAA,UAEvD;AAAA;AAAA,UAEA;AAAA;AAAA,UAEA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAO,cAAQ;",
6
+ "names": ["solidLabelsBabel", "path"]
7
+ }
@@ -0,0 +1 @@
1
+ "use strict";var P=Object.create;var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var s in t)u(e,s,{get:t[s],enumerable:!0})},d=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of v(t))!L.call(e,l)&&l!==s&&u(e,l,{get:()=>t[l],enumerable:!(n=j(t,l))||n.enumerable});return e};var m=(e,t,s)=>(s=e!=null?P(F(e)):{},d(t||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),O=e=>d(u({},"__esModule",{value:!0}),e);var U={};y(U,{default:()=>T});module.exports=O(U);var c=m(require("babel-plugin-solid-labels"),1),f=m(require("@babel/core"),1),b=require("@rollup/pluginutils"),g=require("unplugin"),x=m(require("path"),1);function N(e,t,s){let n=new Set(s),l=-1,r=-1,o;for(let i=0,a=e.length;i<a;i+=1){let p=e[i];n.has(p.name)&&l===-1&&(l=i),p.name===t&&(r=i,o=p)}l!==-1&&r!==-1&&l<r&&(e.splice(r,1),e.splice(l,0,o))}var S="src/**/*.{jsx,tsx,ts,js,mjs,cjs}",h="node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}",E=(0,g.createUnplugin)((e={})=>{var n,l;let t=(0,b.createFilter)(((n=e.filter)==null?void 0:n.include)||S,((l=e.filter)==null?void 0:l.exclude)||h),s;return{name:"solid-labels",transformInclude(r){return t(r)},async transform(r,o){let i=["jsx"];/\.[mc]?tsx?$/i.test(o)&&i.push("typescript");let a=await f.transformAsync(r,{plugins:[[c.default,{disabled:e.disabled,dev:s==="development"||e.dev}]],parserOpts:{plugins:i},filename:x.default.basename(o),ast:!1,sourceMaps:!0,configFile:!1,babelrc:!1,sourceFileName:o});if(a)return{code:a.code||"",map:a.map}},vite:{enforce:"pre",configResolved(r){s=r.mode!=="production"?"development":"production",N(r.plugins,"solid-labels",["astro:jsx","solid","solid-start-file-system-router"])}}}}),T=E;
@@ -0,0 +1,91 @@
1
+ // src/index.ts
2
+ import solidLabelsBabel from "babel-plugin-solid-labels";
3
+ import * as babel from "@babel/core";
4
+ import { createFilter } from "@rollup/pluginutils";
5
+ import { createUnplugin } from "unplugin";
6
+ import path from "path";
7
+ function repushPlugin(plugins, pluginName, pluginNames) {
8
+ const namesSet = new Set(pluginNames);
9
+ let baseIndex = -1;
10
+ let targetIndex = -1;
11
+ let targetPlugin;
12
+ for (let i = 0, len = plugins.length; i < len; i += 1) {
13
+ const current = plugins[i];
14
+ if (namesSet.has(current.name) && baseIndex === -1) {
15
+ baseIndex = i;
16
+ }
17
+ if (current.name === pluginName) {
18
+ targetIndex = i;
19
+ targetPlugin = current;
20
+ }
21
+ }
22
+ if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
23
+ plugins.splice(targetIndex, 1);
24
+ plugins.splice(baseIndex, 0, targetPlugin);
25
+ }
26
+ }
27
+ var DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
28
+ var DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
29
+ var solidLabelsPlugin = createUnplugin((options = {}) => {
30
+ var _a, _b;
31
+ const filter = createFilter(
32
+ ((_a = options.filter) == null ? void 0 : _a.include) || DEFAULT_INCLUDE,
33
+ ((_b = options.filter) == null ? void 0 : _b.exclude) || DEFAULT_EXCLUDE
34
+ );
35
+ let env;
36
+ return {
37
+ name: "solid-labels",
38
+ transformInclude(id) {
39
+ return filter(id);
40
+ },
41
+ async transform(code, id) {
42
+ const plugins = ["jsx"];
43
+ if (/\.[mc]?tsx?$/i.test(id)) {
44
+ plugins.push("typescript");
45
+ }
46
+ const result = await babel.transformAsync(code, {
47
+ plugins: [
48
+ [solidLabelsBabel, {
49
+ disabled: options.disabled,
50
+ dev: env === "development" || options.dev
51
+ }]
52
+ ],
53
+ parserOpts: {
54
+ plugins
55
+ },
56
+ filename: path.basename(id),
57
+ ast: false,
58
+ sourceMaps: true,
59
+ configFile: false,
60
+ babelrc: false,
61
+ sourceFileName: id
62
+ });
63
+ if (result) {
64
+ return {
65
+ code: result.code || "",
66
+ map: result.map
67
+ };
68
+ }
69
+ return void 0;
70
+ },
71
+ vite: {
72
+ enforce: "pre",
73
+ configResolved(config) {
74
+ env = config.mode !== "production" ? "development" : "production";
75
+ repushPlugin(config.plugins, "solid-labels", [
76
+ // https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
77
+ "astro:jsx",
78
+ // https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
79
+ "solid",
80
+ // https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
81
+ "solid-start-file-system-router"
82
+ ]);
83
+ }
84
+ }
85
+ };
86
+ });
87
+ var src_default = solidLabelsPlugin;
88
+ export {
89
+ src_default as default
90
+ };
91
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts"],
4
+ "sourcesContent": ["import type { Options } from 'babel-plugin-solid-labels';\nimport solidLabelsBabel from 'babel-plugin-solid-labels';\nimport * as babel from '@babel/core';\nimport type { Plugin } from 'vite';\nimport type { FilterPattern } from '@rollup/pluginutils';\nimport { createFilter } from '@rollup/pluginutils';\nimport type { TransformResult } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport path from 'path';\n\nexport interface SolidLabelsPluginFilter {\n include?: FilterPattern;\n exclude?: FilterPattern;\n}\n\nexport interface SolidLabelsPluginOptions extends Options {\n filter?: SolidLabelsPluginFilter;\n}\n\n// From: https://github.com/bluwy/whyframe/blob/master/packages/jsx/src/index.js#L27-L37\nfunction repushPlugin(plugins: Plugin[], pluginName: string, pluginNames: string[]): void {\n const namesSet = new Set(pluginNames);\n\n let baseIndex = -1;\n let targetIndex = -1;\n let targetPlugin: Plugin;\n for (let i = 0, len = plugins.length; i < len; i += 1) {\n const current = plugins[i];\n if (namesSet.has(current.name) && baseIndex === -1) {\n baseIndex = i;\n }\n if (current.name === pluginName) {\n targetIndex = i;\n targetPlugin = current;\n }\n }\n if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {\n plugins.splice(targetIndex, 1);\n plugins.splice(baseIndex, 0, targetPlugin!);\n }\n}\n\nconst DEFAULT_INCLUDE = 'src/**/*.{jsx,tsx,ts,js,mjs,cjs}';\nconst DEFAULT_EXCLUDE = 'node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}';\n\nconst solidLabelsPlugin = createUnplugin((options: SolidLabelsPluginOptions = {}) => {\n const filter = createFilter(\n options.filter?.include || DEFAULT_INCLUDE,\n options.filter?.exclude || DEFAULT_EXCLUDE,\n );\n\n let env: string;\n\n return {\n name: 'solid-labels',\n transformInclude(id): boolean {\n return filter(id);\n },\n async transform(code, id): Promise<TransformResult> {\n const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = ['jsx'];\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n const result = await babel.transformAsync(code, {\n plugins: [\n [solidLabelsBabel, {\n disabled: options.disabled,\n dev: env === 'development' || options.dev,\n }],\n ],\n parserOpts: {\n plugins,\n },\n filename: path.basename(id),\n ast: false,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n sourceFileName: id,\n });\n\n if (result) {\n return {\n code: result.code || '',\n map: result.map,\n };\n }\n return undefined;\n },\n vite: {\n enforce: 'pre',\n configResolved(config): void {\n env = config.mode !== 'production' ? 'development' : 'production';\n\n // run our plugin before the following plugins:\n repushPlugin(config.plugins as Plugin[], 'solid-labels', [\n // https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173\n 'astro:jsx',\n // https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305\n 'solid',\n // https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118\n 'solid-start-file-system-router',\n ]);\n },\n },\n };\n});\n\nexport default solidLabelsPlugin;\n"],
5
+ "mappings": ";AACA,OAAO,sBAAsB;AAC7B,YAAY,WAAW;AAGvB,SAAS,oBAAoB;AAE7B,SAAS,sBAAsB;AAC/B,OAAO,UAAU;AAYjB,SAAS,aAAa,SAAmB,YAAoB,aAA6B;AACxF,QAAM,WAAW,IAAI,IAAI,WAAW;AAEpC,MAAI,YAAY;AAChB,MAAI,cAAc;AAClB,MAAI;AACJ,WAAS,IAAI,GAAG,MAAM,QAAQ,QAAQ,IAAI,KAAK,KAAK,GAAG;AACrD,UAAM,UAAU,QAAQ,CAAC;AACzB,QAAI,SAAS,IAAI,QAAQ,IAAI,KAAK,cAAc,IAAI;AAClD,kBAAY;AAAA,IACd;AACA,QAAI,QAAQ,SAAS,YAAY;AAC/B,oBAAc;AACd,qBAAe;AAAA,IACjB;AAAA,EACF;AACA,MAAI,cAAc,MAAM,gBAAgB,MAAM,YAAY,aAAa;AACrE,YAAQ,OAAO,aAAa,CAAC;AAC7B,YAAQ,OAAO,WAAW,GAAG,YAAa;AAAA,EAC5C;AACF;AAEA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAExB,IAAM,oBAAoB,eAAe,CAAC,UAAoC,CAAC,MAAM;AA7CrF;AA8CE,QAAM,SAAS;AAAA,MACb,aAAQ,WAAR,mBAAgB,YAAW;AAAA,MAC3B,aAAQ,WAAR,mBAAgB,YAAW;AAAA,EAC7B;AAEA,MAAI;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,IAAa;AAC5B,aAAO,OAAO,EAAE;AAAA,IAClB;AAAA,IACA,MAAM,UAAU,MAAM,IAA8B;AAClD,YAAM,UAAqF,CAAC,KAAK;AACjG,UAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,gBAAQ,KAAK,YAAY;AAAA,MAC3B;AACA,YAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,QAC9C,SAAS;AAAA,UACP,CAAC,kBAAkB;AAAA,YACjB,UAAU,QAAQ;AAAA,YAClB,KAAK,QAAQ,iBAAiB,QAAQ;AAAA,UACxC,CAAC;AAAA,QACH;AAAA,QACA,YAAY;AAAA,UACV;AAAA,QACF;AAAA,QACA,UAAU,KAAK,SAAS,EAAE;AAAA,QAC1B,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,gBAAgB;AAAA,MAClB,CAAC;AAED,UAAI,QAAQ;AACV,eAAO;AAAA,UACL,MAAM,OAAO,QAAQ;AAAA,UACrB,KAAK,OAAO;AAAA,QACd;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,eAAe,QAAc;AAC3B,cAAM,OAAO,SAAS,eAAe,gBAAgB;AAGrD,qBAAa,OAAO,SAAqB,gBAAgB;AAAA;AAAA,UAEvD;AAAA;AAAA,UAEA;AAAA;AAAA,UAEA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,IAAO,cAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ import m from"babel-plugin-solid-labels";import*as p from"@babel/core";import{createFilter as d}from"@rollup/pluginutils";import{createUnplugin as c}from"unplugin";import f from"path";function b(t,a,n){let o=new Set(n),l=-1,e=-1,r;for(let s=0,i=t.length;s<i;s+=1){let u=t[s];o.has(u.name)&&l===-1&&(l=s),u.name===a&&(e=s,r=u)}l!==-1&&e!==-1&&l<e&&(t.splice(e,1),t.splice(l,0,r))}var g="src/**/*.{jsx,tsx,ts,js,mjs,cjs}",x="node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}",P=c((t={})=>{var o,l;let a=d(((o=t.filter)==null?void 0:o.include)||g,((l=t.filter)==null?void 0:l.exclude)||x),n;return{name:"solid-labels",transformInclude(e){return a(e)},async transform(e,r){let s=["jsx"];/\.[mc]?tsx?$/i.test(r)&&s.push("typescript");let i=await p.transformAsync(e,{plugins:[[m,{disabled:t.disabled,dev:n==="development"||t.dev}]],parserOpts:{plugins:s},filename:f.basename(r),ast:!1,sourceMaps:!0,configFile:!1,babelrc:!1,sourceFileName:r});if(i)return{code:i.code||"",map:i.map}},vite:{enforce:"pre",configResolved(e){n=e.mode!=="production"?"development":"production",b(e.plugins,"solid-labels",["astro:jsx","solid","solid-start-file-system-router"])}}}}),y=P;export{y as default};
@@ -0,0 +1,11 @@
1
+ import type { Options } from 'babel-plugin-solid-labels';
2
+ import type { FilterPattern } from '@rollup/pluginutils';
3
+ export interface SolidLabelsPluginFilter {
4
+ include?: FilterPattern;
5
+ exclude?: FilterPattern;
6
+ }
7
+ export interface SolidLabelsPluginOptions extends Options {
8
+ filter?: SolidLabelsPluginFilter;
9
+ }
10
+ declare const solidLabelsPlugin: import("unplugin").UnpluginInstance<SolidLabelsPluginOptions, boolean>;
11
+ export default solidLabelsPlugin;
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "unplugin-solid-labels",
3
+ "version": "0.15.0",
4
+ "type": "module",
5
+ "files": [
6
+ "dist",
7
+ "babel",
8
+ "core"
9
+ ],
10
+ "engines": {
11
+ "node": ">=10"
12
+ },
13
+ "license": "MIT",
14
+ "keywords": [
15
+ "pridepack"
16
+ ],
17
+ "devDependencies": {
18
+ "@types/babel__core": "^7.20.2",
19
+ "@types/node": "^20.8.2",
20
+ "eslint": "^8.51.0",
21
+ "eslint-config-lxsmnsyc": "^0.6.5",
22
+ "pridepack": "2.5.0",
23
+ "rollup": "^4.0.2",
24
+ "tslib": "^2.6.2",
25
+ "typescript": "^5.2.2",
26
+ "vite": "^4.4.10"
27
+ },
28
+ "dependencies": {
29
+ "@babel/core": "^7.23.0",
30
+ "@rollup/pluginutils": "^5.0.2",
31
+ "babel-plugin-solid-labels": "0.15.0",
32
+ "unplugin": "^1.3.1"
33
+ },
34
+ "peerDependencies": {
35
+ "rollup": "^3 || 4",
36
+ "vite": "^3 || ^4"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "vite": {
40
+ "optional": true
41
+ },
42
+ "rollup": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "scripts": {
47
+ "prepublishOnly": "pridepack clean && pridepack build",
48
+ "build": "pridepack build",
49
+ "type-check": "pridepack check",
50
+ "lint": "pridepack lint",
51
+ "clean": "pridepack clean",
52
+ "watch": "pridepack watch",
53
+ "start": "pridepack start",
54
+ "dev": "pridepack dev"
55
+ },
56
+ "description": "Rollup plugin for solid-styled",
57
+ "repository": {
58
+ "url": "https://github.com/lxsmnsyc/solid-styled.git",
59
+ "type": "git"
60
+ },
61
+ "homepage": "https://github.com/lxsmnsyc/solid-styled/packages/rollup",
62
+ "bugs": {
63
+ "url": "https://github.com/lxsmnsyc/solid-styled/issues"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "author": "Alexis Munsayac",
69
+ "private": false,
70
+ "types": "./dist/types/index.d.ts",
71
+ "main": "./dist/cjs/production/index.cjs",
72
+ "module": "./dist/esm/production/index.mjs",
73
+ "exports": {
74
+ ".": {
75
+ "development": {
76
+ "require": "./dist/cjs/development/index.cjs",
77
+ "import": "./dist/esm/development/index.mjs"
78
+ },
79
+ "require": "./dist/cjs/production/index.cjs",
80
+ "import": "./dist/esm/production/index.mjs",
81
+ "types": "./dist/types/index.d.ts"
82
+ }
83
+ },
84
+ "typesVersions": {
85
+ "*": {}
86
+ },
87
+ "gitHead": "849890c3dc2a1a05f73414b54509489d6ad34e25"
88
+ }