unplugin-solid-labels 0.16.0 → 0.17.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/dist/cjs/development/index.cjs +66 -60
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +1 -1
- package/dist/esm/development/index.mjs +66 -60
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +15 -17
|
@@ -33,11 +33,11 @@ __export(src_exports, {
|
|
|
33
33
|
default: () => src_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
var import_babel = __toESM(require("solid-labels/babel"), 1);
|
|
37
36
|
var babel = __toESM(require("@babel/core"), 1);
|
|
38
37
|
var import_pluginutils = require("@rollup/pluginutils");
|
|
38
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
39
|
+
var import_babel = __toESM(require("solid-labels/babel"), 1);
|
|
39
40
|
var import_unplugin = require("unplugin");
|
|
40
|
-
var import_path = __toESM(require("path"), 1);
|
|
41
41
|
function repushPlugin(plugins, pluginName, pluginNames) {
|
|
42
42
|
const namesSet = new Set(pluginNames);
|
|
43
43
|
let baseIndex = -1;
|
|
@@ -53,70 +53,76 @@ function repushPlugin(plugins, pluginName, pluginNames) {
|
|
|
53
53
|
targetPlugin = current;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
|
|
56
|
+
if (targetPlugin && baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
|
|
57
57
|
plugins.splice(targetIndex, 1);
|
|
58
58
|
plugins.splice(baseIndex, 0, targetPlugin);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
var DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
|
|
62
62
|
var DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
plugins
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
63
|
+
var FILE_FILTER = /\.[mc]?tsx?$/i;
|
|
64
|
+
var solidLabelsPlugin = (0, import_unplugin.createUnplugin)(
|
|
65
|
+
(options = {}) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const filter = (0, import_pluginutils.createFilter)(
|
|
68
|
+
((_a = options.filter) == null ? void 0 : _a.include) || DEFAULT_INCLUDE,
|
|
69
|
+
((_b = options.filter) == null ? void 0 : _b.exclude) || DEFAULT_EXCLUDE
|
|
70
|
+
);
|
|
71
|
+
let env;
|
|
72
|
+
return {
|
|
73
|
+
name: "solid-labels",
|
|
74
|
+
transformInclude(id) {
|
|
75
|
+
return filter(id);
|
|
76
|
+
},
|
|
77
|
+
async transform(code, id) {
|
|
78
|
+
const plugins = ["jsx"];
|
|
79
|
+
if (FILE_FILTER.test(id)) {
|
|
80
|
+
plugins.push("typescript");
|
|
81
|
+
}
|
|
82
|
+
const result = await babel.transformAsync(code, {
|
|
83
|
+
plugins: [
|
|
84
|
+
[
|
|
85
|
+
import_babel.default,
|
|
86
|
+
{
|
|
87
|
+
disabled: options.disabled,
|
|
88
|
+
dev: env === "development" || options.dev
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
],
|
|
92
|
+
parserOpts: {
|
|
93
|
+
plugins
|
|
94
|
+
},
|
|
95
|
+
filename: import_node_path.default.basename(id),
|
|
96
|
+
ast: false,
|
|
97
|
+
sourceMaps: true,
|
|
98
|
+
configFile: false,
|
|
99
|
+
babelrc: false,
|
|
100
|
+
sourceFileName: id
|
|
101
|
+
});
|
|
102
|
+
if (result) {
|
|
103
|
+
return {
|
|
104
|
+
code: result.code || "",
|
|
105
|
+
map: result.map
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return void 0;
|
|
109
|
+
},
|
|
110
|
+
vite: {
|
|
111
|
+
enforce: "pre",
|
|
112
|
+
configResolved(config) {
|
|
113
|
+
env = config.mode !== "production" ? "development" : "production";
|
|
114
|
+
repushPlugin(config.plugins, "solid-labels", [
|
|
115
|
+
// https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
|
|
116
|
+
"astro:jsx",
|
|
117
|
+
// https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
|
|
118
|
+
"solid",
|
|
119
|
+
// https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
|
|
120
|
+
"solid-start-file-system-router"
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
);
|
|
121
127
|
var src_default = solidLabelsPlugin;
|
|
122
128
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as babel from '@babel/core';\nimport type { FilterPattern } from '@rollup/pluginutils';\nimport { createFilter } from '@rollup/pluginutils';\nimport path from 'node:path';\nimport type { Options } from 'solid-labels/babel';\nimport solidLabelsBabel from 'solid-labels/babel';\nimport type { TransformResult } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport type { Plugin } from 'vite';\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(\n plugins: Plugin[],\n pluginName: string,\n pluginNames: string[],\n): void {\n const namesSet = new Set(pluginNames);\n\n let baseIndex = -1;\n let targetIndex = -1;\n let targetPlugin: Plugin | undefined;\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 (\n targetPlugin &&\n baseIndex !== -1 &&\n targetIndex !== -1 &&\n baseIndex < targetIndex\n ) {\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 FILE_FILTER = /\\.[mc]?tsx?$/i;\n\nconst solidLabelsPlugin = createUnplugin(\n (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<\n NonNullable<babel.TransformOptions['parserOpts']>['plugins']\n > = ['jsx'];\n if (FILE_FILTER.test(id)) {\n plugins.push('typescript');\n }\n const result = await babel.transformAsync(code, {\n plugins: [\n [\n solidLabelsBabel,\n {\n disabled: options.disabled,\n dev: env === 'development' || options.dev,\n },\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);\n\nexport default solidLabelsPlugin;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AAEvB,yBAA6B;AAC7B,uBAAiB;AAEjB,mBAA6B;AAE7B,sBAA+B;AAa/B,SAAS,aACP,SACA,YACA,aACM;AACN,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,CA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;AAAA,YACrB,KAAK,OAAO;AAAA,UACd;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,eAAe,QAAc;AAC3B,gBAAM,OAAO,SAAS,eAAe,gBAAgB;AAGrD,uBAAa,OAAO,SAAqB,gBAAgB;AAAA;AAAA,YAEvD;AAAA;AAAA,YAEA;AAAA;AAAA,YAEA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;",
|
|
6
6
|
"names": ["solidLabelsBabel", "path"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.create;var u=Object.defineProperty;var
|
|
1
|
+
"use strict";var P=Object.create;var u=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,v=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 L(t))!v.call(e,l)&&l!==s&&u(e,l,{get:()=>t[l],enumerable:!(n=F(t,l))||n.enumerable});return e};var p=(e,t,s)=>(s=e!=null?P(j(e)):{},d(t||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),E=e=>d(u({},"__esModule",{value:!0}),e);var U={};y(U,{default:()=>h});module.exports=E(U);var c=p(require("@babel/core"),1),f=require("@rollup/pluginutils"),b=p(require("node:path"),1),g=p(require("solid-labels/babel"),1),x=require("unplugin");function O(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 m=e[i];n.has(m.name)&&l===-1&&(l=i),m.name===t&&(r=i,o=m)}o&&l!==-1&&r!==-1&&l<r&&(e.splice(r,1),e.splice(l,0,o))}var I="src/**/*.{jsx,tsx,ts,js,mjs,cjs}",N="node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}",S=/\.[mc]?tsx?$/i,T=(0,x.createUnplugin)((e={})=>{var n,l;let t=(0,f.createFilter)(((n=e.filter)==null?void 0:n.include)||I,((l=e.filter)==null?void 0:l.exclude)||N),s;return{name:"solid-labels",transformInclude(r){return t(r)},async transform(r,o){let i=["jsx"];S.test(o)&&i.push("typescript");let a=await c.transformAsync(r,{plugins:[[g.default,{disabled:e.disabled,dev:s==="development"||e.dev}]],parserOpts:{plugins:i},filename:b.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",O(r.plugins,"solid-labels",["astro:jsx","solid","solid-start-file-system-router"])}}}}),h=T;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import solidLabelsBabel from "solid-labels/babel";
|
|
3
2
|
import * as babel from "@babel/core";
|
|
4
3
|
import { createFilter } from "@rollup/pluginutils";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import solidLabelsBabel from "solid-labels/babel";
|
|
5
6
|
import { createUnplugin } from "unplugin";
|
|
6
|
-
import path from "path";
|
|
7
7
|
function repushPlugin(plugins, pluginName, pluginNames) {
|
|
8
8
|
const namesSet = new Set(pluginNames);
|
|
9
9
|
let baseIndex = -1;
|
|
@@ -19,71 +19,77 @@ function repushPlugin(plugins, pluginName, pluginNames) {
|
|
|
19
19
|
targetPlugin = current;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
if (baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
|
|
22
|
+
if (targetPlugin && baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
|
|
23
23
|
plugins.splice(targetIndex, 1);
|
|
24
24
|
plugins.splice(baseIndex, 0, targetPlugin);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
var DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
|
|
28
28
|
var DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
plugins
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
29
|
+
var FILE_FILTER = /\.[mc]?tsx?$/i;
|
|
30
|
+
var solidLabelsPlugin = createUnplugin(
|
|
31
|
+
(options = {}) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const filter = createFilter(
|
|
34
|
+
((_a = options.filter) == null ? void 0 : _a.include) || DEFAULT_INCLUDE,
|
|
35
|
+
((_b = options.filter) == null ? void 0 : _b.exclude) || DEFAULT_EXCLUDE
|
|
36
|
+
);
|
|
37
|
+
let env;
|
|
38
|
+
return {
|
|
39
|
+
name: "solid-labels",
|
|
40
|
+
transformInclude(id) {
|
|
41
|
+
return filter(id);
|
|
42
|
+
},
|
|
43
|
+
async transform(code, id) {
|
|
44
|
+
const plugins = ["jsx"];
|
|
45
|
+
if (FILE_FILTER.test(id)) {
|
|
46
|
+
plugins.push("typescript");
|
|
47
|
+
}
|
|
48
|
+
const result = await babel.transformAsync(code, {
|
|
49
|
+
plugins: [
|
|
50
|
+
[
|
|
51
|
+
solidLabelsBabel,
|
|
52
|
+
{
|
|
53
|
+
disabled: options.disabled,
|
|
54
|
+
dev: env === "development" || options.dev
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
],
|
|
58
|
+
parserOpts: {
|
|
59
|
+
plugins
|
|
60
|
+
},
|
|
61
|
+
filename: path.basename(id),
|
|
62
|
+
ast: false,
|
|
63
|
+
sourceMaps: true,
|
|
64
|
+
configFile: false,
|
|
65
|
+
babelrc: false,
|
|
66
|
+
sourceFileName: id
|
|
67
|
+
});
|
|
68
|
+
if (result) {
|
|
69
|
+
return {
|
|
70
|
+
code: result.code || "",
|
|
71
|
+
map: result.map
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
},
|
|
76
|
+
vite: {
|
|
77
|
+
enforce: "pre",
|
|
78
|
+
configResolved(config) {
|
|
79
|
+
env = config.mode !== "production" ? "development" : "production";
|
|
80
|
+
repushPlugin(config.plugins, "solid-labels", [
|
|
81
|
+
// https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
|
|
82
|
+
"astro:jsx",
|
|
83
|
+
// https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
|
|
84
|
+
"solid",
|
|
85
|
+
// https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
|
|
86
|
+
"solid-start-file-system-router"
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
68
89
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
});
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
);
|
|
87
93
|
var src_default = solidLabelsPlugin;
|
|
88
94
|
export {
|
|
89
95
|
src_default as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import * as babel from '@babel/core';\nimport type { FilterPattern } from '@rollup/pluginutils';\nimport { createFilter } from '@rollup/pluginutils';\nimport path from 'node:path';\nimport type { Options } from 'solid-labels/babel';\nimport solidLabelsBabel from 'solid-labels/babel';\nimport type { TransformResult } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport type { Plugin } from 'vite';\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(\n plugins: Plugin[],\n pluginName: string,\n pluginNames: string[],\n): void {\n const namesSet = new Set(pluginNames);\n\n let baseIndex = -1;\n let targetIndex = -1;\n let targetPlugin: Plugin | undefined;\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 (\n targetPlugin &&\n baseIndex !== -1 &&\n targetIndex !== -1 &&\n baseIndex < targetIndex\n ) {\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 FILE_FILTER = /\\.[mc]?tsx?$/i;\n\nconst solidLabelsPlugin = createUnplugin(\n (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<\n NonNullable<babel.TransformOptions['parserOpts']>['plugins']\n > = ['jsx'];\n if (FILE_FILTER.test(id)) {\n plugins.push('typescript');\n }\n const result = await babel.transformAsync(code, {\n plugins: [\n [\n solidLabelsBabel,\n {\n disabled: options.disabled,\n dev: env === 'development' || options.dev,\n },\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);\n\nexport default solidLabelsPlugin;\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AAEvB,SAAS,oBAAoB;AAC7B,OAAO,UAAU;AAEjB,OAAO,sBAAsB;AAE7B,SAAS,sBAAsB;AAa/B,SAAS,aACP,SACA,YACA,aACM;AACN,QAAM,WAAW,IAAI,IAAI,WAAW;AAEp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ACZ,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,gBAAgB;AAAA,QAClB,CAAC;AAED,YAAI,QAAQ;AACV,iBAAO;AAAA,YACL,MAAM,OAAO,QAAQ;AAAA,YACrB,KAAK,OAAO;AAAA,UACd;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,eAAe,QAAc;AAC3B,gBAAM,OAAO,SAAS,eAAe,gBAAgB;AAGrD,uBAAa,OAAO,SAAqB,gBAAgB;AAAA;AAAA,YAEvD;AAAA;AAAA,YAEA;AAAA;AAAA,YAEA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import*as m from"@babel/core";import{createFilter as p}from"@rollup/pluginutils";import d from"node:path";import c from"solid-labels/babel";import{createUnplugin as f}from"unplugin";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)}r&&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=/\.[mc]?tsx?$/i,F=f((t={})=>{var o,l;let a=p(((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"];P.test(r)&&s.push("typescript");let i=await m.transformAsync(e,{plugins:[[c,{disabled:t.disabled,dev:n==="development"||t.dev}]],parserOpts:{plugins:s},filename:d.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"])}}}}),E=F;export{E as default};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlD,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,wBAAyB,SAAQ,OAAO;IACvD,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC;AAuCD,QAAA,MAAM,iBAAiB,wEAoEtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-solid-labels",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -15,26 +15,24 @@
|
|
|
15
15
|
"pridepack"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/babel__core": "^7.20.
|
|
19
|
-
"@types/node": "^
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"typescript": "^5.2.2",
|
|
27
|
-
"vite": "^4.5.0"
|
|
18
|
+
"@types/babel__core": "^7.20.5",
|
|
19
|
+
"@types/node": "^22.13.4",
|
|
20
|
+
"pridepack": "2.6.1",
|
|
21
|
+
"rollup": "^4.34.8",
|
|
22
|
+
"solid-labels": "0.17.0",
|
|
23
|
+
"tslib": "^2.8.1",
|
|
24
|
+
"typescript": "^5.8.2",
|
|
25
|
+
"vite": "^6.1.1"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@babel/core": "^7.
|
|
31
|
-
"@rollup/pluginutils": "^5.
|
|
32
|
-
"unplugin": "^
|
|
28
|
+
"@babel/core": "^7.26.9",
|
|
29
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
30
|
+
"unplugin": "^2.2.0"
|
|
33
31
|
},
|
|
34
32
|
"peerDependencies": {
|
|
35
33
|
"rollup": "^3 || 4",
|
|
36
|
-
"solid-labels": "^0.
|
|
37
|
-
"vite": "^3 || ^4"
|
|
34
|
+
"solid-labels": "^0.16",
|
|
35
|
+
"vite": "^3 || ^4 || ^5"
|
|
38
36
|
},
|
|
39
37
|
"peerDependenciesMeta": {
|
|
40
38
|
"vite": {
|
|
@@ -85,5 +83,5 @@
|
|
|
85
83
|
"typesVersions": {
|
|
86
84
|
"*": {}
|
|
87
85
|
},
|
|
88
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "0a0a153d092072f2ee2ad017831c68addf698f70"
|
|
89
87
|
}
|