rolldown-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 +76 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +127 -0
- package/dist/index.mjs +92 -0
- package/package.json +48 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Plugin } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
5
|
+
*
|
|
6
|
+
* Since Rolldown uses OXC internally, this provides optimal performance.
|
|
7
|
+
* Uses Rolldown's native plugin hook filters for maximum efficiency.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface SolidOxcOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Dev mode - enables additional debugging
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
dev?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Hot module replacement (requires dev: true)
|
|
18
|
+
* @default true in dev mode
|
|
19
|
+
*/
|
|
20
|
+
hot?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Filter which files to transform (regex pattern)
|
|
23
|
+
* @default /\.[jt]sx$/
|
|
24
|
+
*/
|
|
25
|
+
include?: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Filter which files to exclude (regex pattern)
|
|
28
|
+
* @default /node_modules/
|
|
29
|
+
*/
|
|
30
|
+
exclude?: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* The module to import runtime helpers from
|
|
33
|
+
* @default 'solid-js/web'
|
|
34
|
+
*/
|
|
35
|
+
module_name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Generate mode
|
|
38
|
+
* @default 'dom'
|
|
39
|
+
*/
|
|
40
|
+
generate?: 'dom' | 'ssr' | 'universal';
|
|
41
|
+
/**
|
|
42
|
+
* Enable hydration support
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
hydratable?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Delegate events for better performance
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
delegate_events?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Wrap conditionals in memos
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
wrap_conditionals?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Pass context to custom elements
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
context_to_custom_elements?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Built-in components that should be passed through
|
|
63
|
+
*/
|
|
64
|
+
builtIns?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Enable SSR mode
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
ssr?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
73
|
+
*/
|
|
74
|
+
declare function solidOxc(options?: SolidOxcOptions): Plugin;
|
|
75
|
+
|
|
76
|
+
export { type SolidOxcOptions, solidOxc as default, solidOxc };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Plugin } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
5
|
+
*
|
|
6
|
+
* Since Rolldown uses OXC internally, this provides optimal performance.
|
|
7
|
+
* Uses Rolldown's native plugin hook filters for maximum efficiency.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface SolidOxcOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Dev mode - enables additional debugging
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
dev?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Hot module replacement (requires dev: true)
|
|
18
|
+
* @default true in dev mode
|
|
19
|
+
*/
|
|
20
|
+
hot?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Filter which files to transform (regex pattern)
|
|
23
|
+
* @default /\.[jt]sx$/
|
|
24
|
+
*/
|
|
25
|
+
include?: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Filter which files to exclude (regex pattern)
|
|
28
|
+
* @default /node_modules/
|
|
29
|
+
*/
|
|
30
|
+
exclude?: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* The module to import runtime helpers from
|
|
33
|
+
* @default 'solid-js/web'
|
|
34
|
+
*/
|
|
35
|
+
module_name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Generate mode
|
|
38
|
+
* @default 'dom'
|
|
39
|
+
*/
|
|
40
|
+
generate?: 'dom' | 'ssr' | 'universal';
|
|
41
|
+
/**
|
|
42
|
+
* Enable hydration support
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
hydratable?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Delegate events for better performance
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
delegate_events?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Wrap conditionals in memos
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
wrap_conditionals?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Pass context to custom elements
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
context_to_custom_elements?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Built-in components that should be passed through
|
|
63
|
+
*/
|
|
64
|
+
builtIns?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Enable SSR mode
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
ssr?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
73
|
+
*/
|
|
74
|
+
declare function solidOxc(options?: SolidOxcOptions): Plugin;
|
|
75
|
+
|
|
76
|
+
export { type SolidOxcOptions, solidOxc as default, solidOxc };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
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 defaultOptions = {
|
|
38
|
+
include: /\.[jt]sx$/,
|
|
39
|
+
exclude: /node_modules/,
|
|
40
|
+
module_name: "solid-js/web",
|
|
41
|
+
generate: "dom",
|
|
42
|
+
hydratable: false,
|
|
43
|
+
delegate_events: true,
|
|
44
|
+
wrap_conditionals: true,
|
|
45
|
+
context_to_custom_elements: true,
|
|
46
|
+
dev: false,
|
|
47
|
+
hot: true,
|
|
48
|
+
builtIns: [
|
|
49
|
+
"For",
|
|
50
|
+
"Show",
|
|
51
|
+
"Switch",
|
|
52
|
+
"Match",
|
|
53
|
+
"Suspense",
|
|
54
|
+
"SuspenseList",
|
|
55
|
+
"Portal",
|
|
56
|
+
"Index",
|
|
57
|
+
"Dynamic",
|
|
58
|
+
"ErrorBoundary"
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
function solidOxc(options = {}) {
|
|
62
|
+
const opts = { ...defaultOptions, ...options };
|
|
63
|
+
let solidJsxOxc = null;
|
|
64
|
+
return {
|
|
65
|
+
name: "rolldown-plugin-solid-oxc",
|
|
66
|
+
async buildStart() {
|
|
67
|
+
try {
|
|
68
|
+
solidJsxOxc = await import("solid-jsx-oxc");
|
|
69
|
+
} catch (e) {
|
|
70
|
+
this.error(
|
|
71
|
+
"Failed to load solid-jsx-oxc. Make sure it is built for your platform."
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
// Use Rolldown's native hook filter for optimal performance
|
|
76
|
+
// Rolldown skips calling the plugin entirely for non-matching files
|
|
77
|
+
transform: {
|
|
78
|
+
filter: {
|
|
79
|
+
id: {
|
|
80
|
+
include: opts.include,
|
|
81
|
+
exclude: opts.exclude
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async handler(code, id) {
|
|
85
|
+
const fileId = id.split("?", 1)[0];
|
|
86
|
+
if (!solidJsxOxc) {
|
|
87
|
+
this.error("solid-jsx-oxc module not loaded");
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const generate = opts.ssr ? "ssr" : opts.generate;
|
|
91
|
+
try {
|
|
92
|
+
const result = solidJsxOxc.transformJsx(code, {
|
|
93
|
+
filename: fileId,
|
|
94
|
+
module_name: opts.module_name,
|
|
95
|
+
generate,
|
|
96
|
+
hydratable: opts.hydratable,
|
|
97
|
+
delegate_events: opts.delegate_events,
|
|
98
|
+
wrap_conditionals: opts.wrap_conditionals,
|
|
99
|
+
context_to_custom_elements: opts.context_to_custom_elements,
|
|
100
|
+
source_map: true
|
|
101
|
+
});
|
|
102
|
+
let finalCode = result.code;
|
|
103
|
+
if (opts.dev && opts.hot !== false) {
|
|
104
|
+
const hotCode = `
|
|
105
|
+
if (import.meta.hot) {
|
|
106
|
+
import.meta.hot.accept();
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
finalCode = finalCode + hotCode;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
code: finalCode,
|
|
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
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
solidOxc
|
|
127
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
include: /\.[jt]sx$/,
|
|
4
|
+
exclude: /node_modules/,
|
|
5
|
+
module_name: "solid-js/web",
|
|
6
|
+
generate: "dom",
|
|
7
|
+
hydratable: false,
|
|
8
|
+
delegate_events: true,
|
|
9
|
+
wrap_conditionals: true,
|
|
10
|
+
context_to_custom_elements: true,
|
|
11
|
+
dev: false,
|
|
12
|
+
hot: true,
|
|
13
|
+
builtIns: [
|
|
14
|
+
"For",
|
|
15
|
+
"Show",
|
|
16
|
+
"Switch",
|
|
17
|
+
"Match",
|
|
18
|
+
"Suspense",
|
|
19
|
+
"SuspenseList",
|
|
20
|
+
"Portal",
|
|
21
|
+
"Index",
|
|
22
|
+
"Dynamic",
|
|
23
|
+
"ErrorBoundary"
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
function solidOxc(options = {}) {
|
|
27
|
+
const opts = { ...defaultOptions, ...options };
|
|
28
|
+
let solidJsxOxc = null;
|
|
29
|
+
return {
|
|
30
|
+
name: "rolldown-plugin-solid-oxc",
|
|
31
|
+
async buildStart() {
|
|
32
|
+
try {
|
|
33
|
+
solidJsxOxc = await import("solid-jsx-oxc");
|
|
34
|
+
} catch (e) {
|
|
35
|
+
this.error(
|
|
36
|
+
"Failed to load solid-jsx-oxc. Make sure it is built for your platform."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
// Use Rolldown's native hook filter for optimal performance
|
|
41
|
+
// Rolldown skips calling the plugin entirely for non-matching files
|
|
42
|
+
transform: {
|
|
43
|
+
filter: {
|
|
44
|
+
id: {
|
|
45
|
+
include: opts.include,
|
|
46
|
+
exclude: opts.exclude
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
async handler(code, id) {
|
|
50
|
+
const fileId = id.split("?", 1)[0];
|
|
51
|
+
if (!solidJsxOxc) {
|
|
52
|
+
this.error("solid-jsx-oxc module not loaded");
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const generate = opts.ssr ? "ssr" : opts.generate;
|
|
56
|
+
try {
|
|
57
|
+
const result = solidJsxOxc.transformJsx(code, {
|
|
58
|
+
filename: fileId,
|
|
59
|
+
module_name: opts.module_name,
|
|
60
|
+
generate,
|
|
61
|
+
hydratable: opts.hydratable,
|
|
62
|
+
delegate_events: opts.delegate_events,
|
|
63
|
+
wrap_conditionals: opts.wrap_conditionals,
|
|
64
|
+
context_to_custom_elements: opts.context_to_custom_elements,
|
|
65
|
+
source_map: true
|
|
66
|
+
});
|
|
67
|
+
let finalCode = result.code;
|
|
68
|
+
if (opts.dev && opts.hot !== false) {
|
|
69
|
+
const hotCode = `
|
|
70
|
+
if (import.meta.hot) {
|
|
71
|
+
import.meta.hot.accept();
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
finalCode = finalCode + hotCode;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
code: finalCode,
|
|
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
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
solidOxc as default,
|
|
91
|
+
solidOxc
|
|
92
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rolldown-plugin-solid-oxc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rolldown 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
|
+
"rolldown",
|
|
24
|
+
"rollup",
|
|
25
|
+
"plugin",
|
|
26
|
+
"solid",
|
|
27
|
+
"solidjs",
|
|
28
|
+
"jsx",
|
|
29
|
+
"oxc"
|
|
30
|
+
],
|
|
31
|
+
"author": "SolidJS Contributors",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"rolldown": ">=0.1.0",
|
|
35
|
+
"solid-jsx-oxc": "*"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"rolldown": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"solid-jsx-oxc": "*",
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"tsup": "^8.0.0",
|
|
46
|
+
"typescript": "^5.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|