vite-plugin-solid-oxc 0.1.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/index.d.mts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +140 -0
- package/dist/index.mjs +105 -0
- package/package.json +43 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FilterPattern, Plugin } from 'vite';
|
|
2
|
+
export { Plugin } from 'vite';
|
|
3
|
+
|
|
4
|
+
interface SolidOxcOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Filter which files to transform
|
|
7
|
+
* @default /\.[jt]sx$/
|
|
8
|
+
*/
|
|
9
|
+
include?: FilterPattern;
|
|
10
|
+
/**
|
|
11
|
+
* Filter which files to exclude
|
|
12
|
+
* @default /node_modules/
|
|
13
|
+
*/
|
|
14
|
+
exclude?: FilterPattern;
|
|
15
|
+
/**
|
|
16
|
+
* The module to import runtime helpers from
|
|
17
|
+
* @default 'solid-js/web'
|
|
18
|
+
*/
|
|
19
|
+
module_name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate mode
|
|
22
|
+
* @default 'dom'
|
|
23
|
+
*/
|
|
24
|
+
generate?: 'dom' | 'ssr' | 'universal';
|
|
25
|
+
/**
|
|
26
|
+
* Enable hydration support
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hydratable?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Delegate events for better performance
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
delegate_events?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Wrap conditionals in memos
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
wrap_conditionals?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Pass context to custom elements
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
context_to_custom_elements?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Built-in components that should be passed through
|
|
47
|
+
*/
|
|
48
|
+
builtIns?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Enable SSR mode (shorthand for generate: 'ssr')
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
ssr?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Dev mode - enables additional debugging
|
|
56
|
+
* @default based on vite mode
|
|
57
|
+
*/
|
|
58
|
+
dev?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Hot module replacement
|
|
61
|
+
* @default true in dev mode
|
|
62
|
+
*/
|
|
63
|
+
hot?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Vite plugin for SolidJS using OXC-based compiler
|
|
67
|
+
*/
|
|
68
|
+
declare function solidOxc(options?: SolidOxcOptions): Plugin;
|
|
69
|
+
|
|
70
|
+
export { type SolidOxcOptions, solidOxc as default, solidOxc };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FilterPattern, Plugin } from 'vite';
|
|
2
|
+
export { Plugin } from 'vite';
|
|
3
|
+
|
|
4
|
+
interface SolidOxcOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Filter which files to transform
|
|
7
|
+
* @default /\.[jt]sx$/
|
|
8
|
+
*/
|
|
9
|
+
include?: FilterPattern;
|
|
10
|
+
/**
|
|
11
|
+
* Filter which files to exclude
|
|
12
|
+
* @default /node_modules/
|
|
13
|
+
*/
|
|
14
|
+
exclude?: FilterPattern;
|
|
15
|
+
/**
|
|
16
|
+
* The module to import runtime helpers from
|
|
17
|
+
* @default 'solid-js/web'
|
|
18
|
+
*/
|
|
19
|
+
module_name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate mode
|
|
22
|
+
* @default 'dom'
|
|
23
|
+
*/
|
|
24
|
+
generate?: 'dom' | 'ssr' | 'universal';
|
|
25
|
+
/**
|
|
26
|
+
* Enable hydration support
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hydratable?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Delegate events for better performance
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
delegate_events?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Wrap conditionals in memos
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
wrap_conditionals?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Pass context to custom elements
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
context_to_custom_elements?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Built-in components that should be passed through
|
|
47
|
+
*/
|
|
48
|
+
builtIns?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Enable SSR mode (shorthand for generate: 'ssr')
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
ssr?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Dev mode - enables additional debugging
|
|
56
|
+
* @default based on vite mode
|
|
57
|
+
*/
|
|
58
|
+
dev?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Hot module replacement
|
|
61
|
+
* @default true in dev mode
|
|
62
|
+
*/
|
|
63
|
+
hot?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Vite plugin for SolidJS using OXC-based compiler
|
|
67
|
+
*/
|
|
68
|
+
declare function solidOxc(options?: SolidOxcOptions): Plugin;
|
|
69
|
+
|
|
70
|
+
export { type SolidOxcOptions, solidOxc as default, solidOxc };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
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 index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => solidOxc,
|
|
34
|
+
solidOxc: () => solidOxc
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_vite = require("vite");
|
|
38
|
+
var defaultOptions = {
|
|
39
|
+
include: /\.[jt]sx$/,
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
module_name: "solid-js/web",
|
|
42
|
+
generate: "dom",
|
|
43
|
+
hydratable: false,
|
|
44
|
+
delegate_events: true,
|
|
45
|
+
wrap_conditionals: true,
|
|
46
|
+
context_to_custom_elements: true,
|
|
47
|
+
builtIns: [
|
|
48
|
+
"For",
|
|
49
|
+
"Show",
|
|
50
|
+
"Switch",
|
|
51
|
+
"Match",
|
|
52
|
+
"Suspense",
|
|
53
|
+
"SuspenseList",
|
|
54
|
+
"Portal",
|
|
55
|
+
"Index",
|
|
56
|
+
"Dynamic",
|
|
57
|
+
"ErrorBoundary"
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
function solidOxc(options = {}) {
|
|
61
|
+
const opts = { ...defaultOptions, ...options };
|
|
62
|
+
const filter = (0, import_vite.createFilter)(opts.include, opts.exclude);
|
|
63
|
+
let isDev = false;
|
|
64
|
+
let isSSR = false;
|
|
65
|
+
let solidJsxOxc = null;
|
|
66
|
+
return {
|
|
67
|
+
name: "vite-plugin-solid-oxc",
|
|
68
|
+
enforce: "pre",
|
|
69
|
+
configResolved(config) {
|
|
70
|
+
isDev = config.command === "serve";
|
|
71
|
+
isSSR = opts.ssr ?? (typeof config.build?.ssr === "boolean" ? config.build.ssr : !!config.build?.ssr);
|
|
72
|
+
},
|
|
73
|
+
async buildStart() {
|
|
74
|
+
try {
|
|
75
|
+
solidJsxOxc = await import("solid-jsx-oxc");
|
|
76
|
+
} catch (e) {
|
|
77
|
+
this.error(
|
|
78
|
+
"Failed to load solid-jsx-oxc. Make sure it is built for your platform.\nRun: cd packages/solid-jsx-oxc && npm run build"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async transform(code, id) {
|
|
83
|
+
const fileId = id.split("?", 1)[0];
|
|
84
|
+
if (!filter(fileId)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (!solidJsxOxc) {
|
|
88
|
+
this.error("solid-jsx-oxc module not loaded");
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const generate = isSSR ? "ssr" : opts.generate;
|
|
92
|
+
try {
|
|
93
|
+
const result = solidJsxOxc.transformJsx(code, {
|
|
94
|
+
filename: fileId,
|
|
95
|
+
module_name: opts.module_name,
|
|
96
|
+
generate,
|
|
97
|
+
hydratable: opts.hydratable,
|
|
98
|
+
delegate_events: opts.delegate_events,
|
|
99
|
+
wrap_conditionals: opts.wrap_conditionals,
|
|
100
|
+
context_to_custom_elements: opts.context_to_custom_elements,
|
|
101
|
+
source_map: true
|
|
102
|
+
});
|
|
103
|
+
if (isDev && opts.hot !== false) {
|
|
104
|
+
const hotCode = `
|
|
105
|
+
if (import.meta.hot) {
|
|
106
|
+
import.meta.hot.accept();
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
result.code = result.code + hotCode;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
code: result.code,
|
|
113
|
+
map: result.map ? JSON.parse(result.map) : null
|
|
114
|
+
};
|
|
115
|
+
} catch (e) {
|
|
116
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
117
|
+
this.error(`Failed to transform ${id}: ${message}`);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
// Handle Solid's JSX types
|
|
122
|
+
config() {
|
|
123
|
+
return {
|
|
124
|
+
esbuild: {
|
|
125
|
+
// Let our plugin handle JSX, not esbuild
|
|
126
|
+
jsx: "preserve",
|
|
127
|
+
jsxImportSource: "solid-js"
|
|
128
|
+
},
|
|
129
|
+
resolve: {
|
|
130
|
+
conditions: ["solid"],
|
|
131
|
+
dedupe: ["solid-js", "solid-js/web"]
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
solidOxc
|
|
140
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createFilter } from "vite";
|
|
3
|
+
var defaultOptions = {
|
|
4
|
+
include: /\.[jt]sx$/,
|
|
5
|
+
exclude: /node_modules/,
|
|
6
|
+
module_name: "solid-js/web",
|
|
7
|
+
generate: "dom",
|
|
8
|
+
hydratable: false,
|
|
9
|
+
delegate_events: true,
|
|
10
|
+
wrap_conditionals: true,
|
|
11
|
+
context_to_custom_elements: true,
|
|
12
|
+
builtIns: [
|
|
13
|
+
"For",
|
|
14
|
+
"Show",
|
|
15
|
+
"Switch",
|
|
16
|
+
"Match",
|
|
17
|
+
"Suspense",
|
|
18
|
+
"SuspenseList",
|
|
19
|
+
"Portal",
|
|
20
|
+
"Index",
|
|
21
|
+
"Dynamic",
|
|
22
|
+
"ErrorBoundary"
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
function solidOxc(options = {}) {
|
|
26
|
+
const opts = { ...defaultOptions, ...options };
|
|
27
|
+
const filter = createFilter(opts.include, opts.exclude);
|
|
28
|
+
let isDev = false;
|
|
29
|
+
let isSSR = false;
|
|
30
|
+
let solidJsxOxc = null;
|
|
31
|
+
return {
|
|
32
|
+
name: "vite-plugin-solid-oxc",
|
|
33
|
+
enforce: "pre",
|
|
34
|
+
configResolved(config) {
|
|
35
|
+
isDev = config.command === "serve";
|
|
36
|
+
isSSR = opts.ssr ?? (typeof config.build?.ssr === "boolean" ? config.build.ssr : !!config.build?.ssr);
|
|
37
|
+
},
|
|
38
|
+
async buildStart() {
|
|
39
|
+
try {
|
|
40
|
+
solidJsxOxc = await import("solid-jsx-oxc");
|
|
41
|
+
} catch (e) {
|
|
42
|
+
this.error(
|
|
43
|
+
"Failed to load solid-jsx-oxc. Make sure it is built for your platform.\nRun: cd packages/solid-jsx-oxc && npm run build"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async transform(code, id) {
|
|
48
|
+
const fileId = id.split("?", 1)[0];
|
|
49
|
+
if (!filter(fileId)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (!solidJsxOxc) {
|
|
53
|
+
this.error("solid-jsx-oxc module not loaded");
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const generate = isSSR ? "ssr" : opts.generate;
|
|
57
|
+
try {
|
|
58
|
+
const result = solidJsxOxc.transformJsx(code, {
|
|
59
|
+
filename: fileId,
|
|
60
|
+
module_name: opts.module_name,
|
|
61
|
+
generate,
|
|
62
|
+
hydratable: opts.hydratable,
|
|
63
|
+
delegate_events: opts.delegate_events,
|
|
64
|
+
wrap_conditionals: opts.wrap_conditionals,
|
|
65
|
+
context_to_custom_elements: opts.context_to_custom_elements,
|
|
66
|
+
source_map: true
|
|
67
|
+
});
|
|
68
|
+
if (isDev && opts.hot !== false) {
|
|
69
|
+
const hotCode = `
|
|
70
|
+
if (import.meta.hot) {
|
|
71
|
+
import.meta.hot.accept();
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
result.code = result.code + hotCode;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
code: result.code,
|
|
78
|
+
map: result.map ? JSON.parse(result.map) : null
|
|
79
|
+
};
|
|
80
|
+
} catch (e) {
|
|
81
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
82
|
+
this.error(`Failed to transform ${id}: ${message}`);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
// Handle Solid's JSX types
|
|
87
|
+
config() {
|
|
88
|
+
return {
|
|
89
|
+
esbuild: {
|
|
90
|
+
// Let our plugin handle JSX, not esbuild
|
|
91
|
+
jsx: "preserve",
|
|
92
|
+
jsxImportSource: "solid-js"
|
|
93
|
+
},
|
|
94
|
+
resolve: {
|
|
95
|
+
conditions: ["solid"],
|
|
96
|
+
dedupe: ["solid-js", "solid-js/web"]
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
solidOxc as default,
|
|
104
|
+
solidOxc
|
|
105
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-plugin-solid-oxc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vite plugin for SolidJS using OXC-based compiler",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
20
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"vite",
|
|
24
|
+
"vite-plugin",
|
|
25
|
+
"solid",
|
|
26
|
+
"solidjs",
|
|
27
|
+
"jsx",
|
|
28
|
+
"oxc",
|
|
29
|
+
"rolldown"
|
|
30
|
+
],
|
|
31
|
+
"author": "SolidJS Contributors",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"solid-jsx-oxc": "*",
|
|
35
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.0.0",
|
|
39
|
+
"tsup": "^8.5.1",
|
|
40
|
+
"typescript": "^5.0.0",
|
|
41
|
+
"vite": "^6.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|