unplugin-solid-labels 0.17.0 → 0.17.1

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,7 +1,21 @@
1
- MIT License Copyright (c) 2023 Alexis Munsayac
1
+ MIT License
2
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:
3
+ Copyright (c) 2025 Alexis Munsayac
4
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.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
6
11
 
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.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -41,7 +41,7 @@ solidLabels.vite({
41
41
  include: 'src/**/*.{ts,js,tsx,jsx}',
42
42
  exclude: 'node_modules/**/*.{ts,js,tsx,jsx}',
43
43
  },
44
- })
44
+ });
45
45
  ```
46
46
 
47
47
  ## Sponsors
package/dist/index.cjs ADDED
@@ -0,0 +1,97 @@
1
+ //#region \0rolldown/runtime.js
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let _babel_core = require("@babel/core");
24
+ _babel_core = __toESM(_babel_core, 1);
25
+ let _rollup_pluginutils = require("@rollup/pluginutils");
26
+ let node_path = require("node:path");
27
+ node_path = __toESM(node_path, 1);
28
+ let solid_labels_babel = require("solid-labels/babel");
29
+ solid_labels_babel = __toESM(solid_labels_babel, 1);
30
+ let unplugin = require("unplugin");
31
+ //#region src/index.ts
32
+ function repushPlugin(plugins, pluginName, pluginNames) {
33
+ const namesSet = new Set(pluginNames);
34
+ let baseIndex = -1;
35
+ let targetIndex = -1;
36
+ let targetPlugin;
37
+ for (let i = 0, len = plugins.length; i < len; i += 1) {
38
+ const current = plugins[i];
39
+ if (namesSet.has(current.name) && baseIndex === -1) baseIndex = i;
40
+ if (current.name === pluginName) {
41
+ targetIndex = i;
42
+ targetPlugin = current;
43
+ }
44
+ }
45
+ if (targetPlugin && baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
46
+ plugins.splice(targetIndex, 1);
47
+ plugins.splice(baseIndex, 0, targetPlugin);
48
+ }
49
+ }
50
+ const DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
51
+ const DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
52
+ const FILE_FILTER = /\.[mc]?tsx?$/i;
53
+ const solidLabelsPlugin = (0, unplugin.createUnplugin)((rawOptions) => {
54
+ const options = rawOptions ?? {};
55
+ const filter = (0, _rollup_pluginutils.createFilter)(options.filter?.include ?? DEFAULT_INCLUDE, options.filter?.exclude ?? DEFAULT_EXCLUDE);
56
+ let env;
57
+ return {
58
+ name: "solid-labels",
59
+ transformInclude(id) {
60
+ return filter(id);
61
+ },
62
+ async transform(code, id) {
63
+ const plugins = ["jsx"];
64
+ if (FILE_FILTER.test(id)) plugins.push("typescript");
65
+ const result = await _babel_core.transformAsync(code, {
66
+ plugins: [[solid_labels_babel.default, {
67
+ disabled: options.disabled,
68
+ dev: env === "development" || options.dev
69
+ }]],
70
+ parserOpts: { plugins },
71
+ filename: node_path.default.basename(id),
72
+ ast: false,
73
+ sourceMaps: true,
74
+ configFile: false,
75
+ babelrc: false,
76
+ sourceFileName: id
77
+ });
78
+ if (result) return {
79
+ code: result.code ?? "",
80
+ map: result.map
81
+ };
82
+ },
83
+ vite: {
84
+ enforce: "pre",
85
+ configResolved(config) {
86
+ env = config.mode === "production" ? "production" : "development";
87
+ repushPlugin(config.plugins, "solid-labels", [
88
+ "astro:jsx",
89
+ "solid",
90
+ "solid-start-file-system-router"
91
+ ]);
92
+ }
93
+ }
94
+ };
95
+ });
96
+ //#endregion
97
+ module.exports = solidLabelsPlugin;
@@ -0,0 +1,14 @@
1
+ import { FilterPattern } from "@rollup/pluginutils";
2
+ import { Options } from "solid-labels/babel";
3
+ //#region src/index.d.ts
4
+ export interface SolidLabelsPluginFilter {
5
+ include?: FilterPattern;
6
+ exclude?: FilterPattern;
7
+ }
8
+ export interface SolidLabelsPluginOptions extends Options {
9
+ filter?: SolidLabelsPluginFilter;
10
+ }
11
+ declare const solidLabelsPlugin: import("unplugin").UnpluginInstance<SolidLabelsPluginOptions | undefined, boolean>;
12
+ //#endregion
13
+ export { solidLabelsPlugin as default };
14
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;iBAUiB;EACf,UAAU;EACV,UAAU;;iBAGK,iCAAiC;EAChD,SAAS;;cA+BL,sCAAiB,iBAAA"}
@@ -0,0 +1,14 @@
1
+ import { FilterPattern } from "@rollup/pluginutils";
2
+ import { Options } from "solid-labels/babel";
3
+ //#region src/index.d.ts
4
+ export interface SolidLabelsPluginFilter {
5
+ include?: FilterPattern;
6
+ exclude?: FilterPattern;
7
+ }
8
+ export interface SolidLabelsPluginOptions extends Options {
9
+ filter?: SolidLabelsPluginFilter;
10
+ }
11
+ declare const solidLabelsPlugin: import("unplugin").UnpluginInstance<SolidLabelsPluginOptions | undefined, boolean>;
12
+ //#endregion
13
+ export { solidLabelsPlugin as default };
14
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;iBAUiB;EACf,UAAU;EACV,UAAU;;iBAGK,iCAAiC;EAChD,SAAS;;cA+BL,sCAAiB,iBAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,74 @@
1
+ import * as babel from "@babel/core";
2
+ import { createFilter } from "@rollup/pluginutils";
3
+ import path from "node:path";
4
+ import solidLabelsBabel from "solid-labels/babel";
5
+ import { createUnplugin } from "unplugin";
6
+ //#region src/index.ts
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) baseIndex = i;
15
+ if (current.name === pluginName) {
16
+ targetIndex = i;
17
+ targetPlugin = current;
18
+ }
19
+ }
20
+ if (targetPlugin && baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
21
+ plugins.splice(targetIndex, 1);
22
+ plugins.splice(baseIndex, 0, targetPlugin);
23
+ }
24
+ }
25
+ const DEFAULT_INCLUDE = "src/**/*.{jsx,tsx,ts,js,mjs,cjs}";
26
+ const DEFAULT_EXCLUDE = "node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}";
27
+ const FILE_FILTER = /\.[mc]?tsx?$/i;
28
+ const solidLabelsPlugin = createUnplugin((rawOptions) => {
29
+ const options = rawOptions ?? {};
30
+ const filter = createFilter(options.filter?.include ?? DEFAULT_INCLUDE, options.filter?.exclude ?? DEFAULT_EXCLUDE);
31
+ let env;
32
+ return {
33
+ name: "solid-labels",
34
+ transformInclude(id) {
35
+ return filter(id);
36
+ },
37
+ async transform(code, id) {
38
+ const plugins = ["jsx"];
39
+ if (FILE_FILTER.test(id)) plugins.push("typescript");
40
+ const result = await babel.transformAsync(code, {
41
+ plugins: [[solidLabelsBabel, {
42
+ disabled: options.disabled,
43
+ dev: env === "development" || options.dev
44
+ }]],
45
+ parserOpts: { plugins },
46
+ filename: path.basename(id),
47
+ ast: false,
48
+ sourceMaps: true,
49
+ configFile: false,
50
+ babelrc: false,
51
+ sourceFileName: id
52
+ });
53
+ if (result) return {
54
+ code: result.code ?? "",
55
+ map: result.map
56
+ };
57
+ },
58
+ vite: {
59
+ enforce: "pre",
60
+ configResolved(config) {
61
+ env = config.mode === "production" ? "production" : "development";
62
+ repushPlugin(config.plugins, "solid-labels", [
63
+ "astro:jsx",
64
+ "solid",
65
+ "solid-start-file-system-router"
66
+ ]);
67
+ }
68
+ }
69
+ };
70
+ });
71
+ //#endregion
72
+ export { solidLabelsPlugin as default };
73
+
74
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"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(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 | 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 (targetPlugin && 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 FILE_FILTER = /\\.[mc]?tsx?$/i;\n\nconst solidLabelsPlugin = createUnplugin((rawOptions?: SolidLabelsPluginOptions) => {\n const options = rawOptions ?? {};\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']> = [\n 'jsx',\n ];\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' ? 'production' : 'development';\n\n // run our plugin before the following plugins:\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\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});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MAAM,OAAO,QAAQ;IACrB,KAAK,OAAO;GACd;EAGJ;EACA,MAAM;GACJ,SAAS;GACT,eAAe,QAAc;IAC3B,MAAM,OAAO,SAAS,eAAe,eAAe;IAIpD,aAAa,OAAO,SAAqB,gBAAgB;KAEvD;KAEA;KAEA;IACF,CAAC;GACH;EACF;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,38 +1,61 @@
1
1
  {
2
2
  "name": "unplugin-solid-labels",
3
- "version": "0.17.0",
4
- "type": "module",
5
- "files": [
6
- "dist",
7
- "babel",
8
- "core"
3
+ "version": "0.17.1",
4
+ "private": false,
5
+ "description": "Unplugin for solid-labels",
6
+ "keywords": [
7
+ "rollup",
8
+ "solid-js",
9
+ "solid-labels",
10
+ "unplugin",
11
+ "vite"
9
12
  ],
10
- "engines": {
11
- "node": ">=10"
13
+ "homepage": "https://github.com/lxsmnsyc/solid-labels/tree/main/packages/unplugin",
14
+ "bugs": {
15
+ "url": "https://github.com/lxsmnsyc/solid-labels/issues"
12
16
  },
13
17
  "license": "MIT",
14
- "keywords": [
15
- "pridepack"
18
+ "author": "Alexis Munsayac",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/lxsmnsyc/solid-labels.git"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "src"
16
26
  ],
17
- "devDependencies": {
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"
27
+ "type": "module",
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.mjs",
30
+ "types": "./dist/index.d.cts",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.mjs",
34
+ "require": "./dist/index.cjs"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
26
40
  },
27
41
  "dependencies": {
28
- "@babel/core": "^7.26.9",
29
- "@rollup/pluginutils": "^5.1.4",
30
- "unplugin": "^2.2.0"
42
+ "@babel/core": "^7.29.7",
43
+ "@rollup/pluginutils": "^5.4.0",
44
+ "unplugin": "^2.3.11"
45
+ },
46
+ "devDependencies": {
47
+ "@types/babel__core": "^7.20.5",
48
+ "@types/node": "^26.6.5",
49
+ "rollup": "^4.64.6",
50
+ "solid-labels": "0.17.1",
51
+ "tsdown": "^0.23.1",
52
+ "typescript": "^7.0.2",
53
+ "vite": "^8.3.4"
31
54
  },
32
55
  "peerDependencies": {
33
- "rollup": "^3 || 4",
34
- "solid-labels": "^0.16",
35
- "vite": "^3 || ^4 || ^5"
56
+ "rollup": "^3 || ^4",
57
+ "solid-labels": "^0.17.1",
58
+ "vite": "^3 || ^4 || ^5 || ^6 || ^7 || ^8"
36
59
  },
37
60
  "peerDependenciesMeta": {
38
61
  "vite": {
@@ -42,46 +65,11 @@
42
65
  "optional": true
43
66
  }
44
67
  },
45
- "scripts": {
46
- "prepublishOnly": "pridepack clean && pridepack build",
47
- "build": "pridepack build",
48
- "type-check": "pridepack check",
49
- "lint": "pridepack lint",
50
- "clean": "pridepack clean",
51
- "watch": "pridepack watch",
52
- "start": "pridepack start",
53
- "dev": "pridepack dev"
54
- },
55
- "description": "Rollup plugin for solid-styled",
56
- "repository": {
57
- "url": "https://github.com/lxsmnsyc/solid-styled.git",
58
- "type": "git"
59
- },
60
- "homepage": "https://github.com/lxsmnsyc/solid-styled/packages/rollup",
61
- "bugs": {
62
- "url": "https://github.com/lxsmnsyc/solid-styled/issues"
63
- },
64
- "publishConfig": {
65
- "access": "public"
66
- },
67
- "author": "Alexis Munsayac",
68
- "private": false,
69
- "types": "./dist/types/index.d.ts",
70
- "main": "./dist/cjs/production/index.cjs",
71
- "module": "./dist/esm/production/index.mjs",
72
- "exports": {
73
- ".": {
74
- "development": {
75
- "require": "./dist/cjs/development/index.cjs",
76
- "import": "./dist/esm/development/index.mjs"
77
- },
78
- "require": "./dist/cjs/production/index.cjs",
79
- "import": "./dist/esm/production/index.mjs",
80
- "types": "./dist/types/index.d.ts"
81
- }
82
- },
83
- "typesVersions": {
84
- "*": {}
68
+ "engines": {
69
+ "node": ">=18"
85
70
  },
86
- "gitHead": "0a0a153d092072f2ee2ad017831c68addf698f70"
87
- }
71
+ "scripts": {
72
+ "build": "tsdown",
73
+ "watch": "tsdown --watch"
74
+ }
75
+ }
package/src/index.ts ADDED
@@ -0,0 +1,118 @@
1
+ import * as babel from '@babel/core';
2
+ import type { FilterPattern } from '@rollup/pluginutils';
3
+ import { createFilter } from '@rollup/pluginutils';
4
+ import path from 'node:path';
5
+ import type { Options } from 'solid-labels/babel';
6
+ import solidLabelsBabel from 'solid-labels/babel';
7
+ import type { TransformResult } from 'unplugin';
8
+ import { createUnplugin } from 'unplugin';
9
+ import type { Plugin } from 'vite';
10
+
11
+ export interface SolidLabelsPluginFilter {
12
+ include?: FilterPattern;
13
+ exclude?: FilterPattern;
14
+ }
15
+
16
+ export interface SolidLabelsPluginOptions extends Options {
17
+ filter?: SolidLabelsPluginFilter;
18
+ }
19
+
20
+ // From: https://github.com/bluwy/whyframe/blob/master/packages/jsx/src/index.js#L27-L37
21
+ function repushPlugin(plugins: Plugin[], pluginName: string, pluginNames: string[]): void {
22
+ const namesSet = new Set(pluginNames);
23
+
24
+ let baseIndex = -1;
25
+ let targetIndex = -1;
26
+ let targetPlugin: Plugin | undefined;
27
+ for (let i = 0, len = plugins.length; i < len; i += 1) {
28
+ const current = plugins[i];
29
+ if (namesSet.has(current.name) && baseIndex === -1) {
30
+ baseIndex = i;
31
+ }
32
+ if (current.name === pluginName) {
33
+ targetIndex = i;
34
+ targetPlugin = current;
35
+ }
36
+ }
37
+ if (targetPlugin && baseIndex !== -1 && targetIndex !== -1 && baseIndex < targetIndex) {
38
+ plugins.splice(targetIndex, 1);
39
+ plugins.splice(baseIndex, 0, targetPlugin);
40
+ }
41
+ }
42
+
43
+ const DEFAULT_INCLUDE = 'src/**/*.{jsx,tsx,ts,js,mjs,cjs}';
44
+ const DEFAULT_EXCLUDE = 'node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}';
45
+
46
+ const FILE_FILTER = /\.[mc]?tsx?$/i;
47
+
48
+ const solidLabelsPlugin = createUnplugin((rawOptions?: SolidLabelsPluginOptions) => {
49
+ const options = rawOptions ?? {};
50
+ const filter = createFilter(
51
+ options.filter?.include ?? DEFAULT_INCLUDE,
52
+ options.filter?.exclude ?? DEFAULT_EXCLUDE,
53
+ );
54
+
55
+ let env: string;
56
+
57
+ return {
58
+ name: 'solid-labels',
59
+ transformInclude(id): boolean {
60
+ return filter(id);
61
+ },
62
+ async transform(code, id): Promise<TransformResult> {
63
+ const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = [
64
+ 'jsx',
65
+ ];
66
+ if (FILE_FILTER.test(id)) {
67
+ plugins.push('typescript');
68
+ }
69
+ const result = await babel.transformAsync(code, {
70
+ plugins: [
71
+ [
72
+ solidLabelsBabel,
73
+ {
74
+ disabled: options.disabled,
75
+ dev: env === 'development' || options.dev,
76
+ },
77
+ ],
78
+ ],
79
+ parserOpts: {
80
+ plugins,
81
+ },
82
+ filename: path.basename(id),
83
+ ast: false,
84
+ sourceMaps: true,
85
+ configFile: false,
86
+ babelrc: false,
87
+ sourceFileName: id,
88
+ });
89
+
90
+ if (result) {
91
+ return {
92
+ code: result.code ?? '',
93
+ map: result.map,
94
+ };
95
+ }
96
+ return undefined;
97
+ },
98
+ vite: {
99
+ enforce: 'pre',
100
+ configResolved(config): void {
101
+ env = config.mode === 'production' ? 'production' : 'development';
102
+
103
+ // run our plugin before the following plugins:
104
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion
105
+ repushPlugin(config.plugins as Plugin[], 'solid-labels', [
106
+ // https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
107
+ 'astro:jsx',
108
+ // https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
109
+ 'solid',
110
+ // https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
111
+ 'solid-start-file-system-router',
112
+ ]);
113
+ },
114
+ },
115
+ };
116
+ });
117
+
118
+ export default solidLabelsPlugin;
@@ -1,128 +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 __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 babel = __toESM(require("@babel/core"), 1);
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);
40
- var import_unplugin = require("unplugin");
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 (targetPlugin && 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 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
- }
123
- }
124
- };
125
- }
126
- );
127
- var src_default = solidLabelsPlugin;
128
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/index.ts"],
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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AAAA,UACF;AAAA,UACA,YAAY;AAAA,YACV;AAAA,UACF;AAAA,UACA,UAAU,iBAAAC,QAAK,SAAS,EAAE;AAAA,UAC1B,KAAK;AAAA,UACL,YAAY;AAAA,UACZ,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
- "names": ["solidLabelsBabel", "path"]
7
- }
@@ -1 +0,0 @@
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,97 +0,0 @@
1
- // src/index.ts
2
- import * as babel from "@babel/core";
3
- import { createFilter } from "@rollup/pluginutils";
4
- import path from "node:path";
5
- import solidLabelsBabel from "solid-labels/babel";
6
- import { createUnplugin } from "unplugin";
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 (targetPlugin && 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 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
- }
89
- }
90
- };
91
- }
92
- );
93
- var src_default = solidLabelsPlugin;
94
- export {
95
- src_default as default
96
- };
97
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/index.ts"],
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;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,MACE,gBACA,cAAc,MACd,gBAAg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AAA,YAEvD;AAAA;AAAA,YAEA;AAAA;AAAA,YAEA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
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};
@@ -1,12 +0,0 @@
1
- import type { FilterPattern } from '@rollup/pluginutils';
2
- import type { Options } from 'solid-labels/babel';
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;
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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"}