rolldown-plugin-solid-oxc 0.1.0-alpha.10

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