@wq2/rolldown-plugin-solid-oxc 0.1.0-alpha.15 → 0.1.0-alpha.16

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,74 @@
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
+ /// <reference path="../src/rolldown.d.ts" />
8
+ import type { Plugin } from 'rolldown';
9
+ export interface SolidOxcOptions {
10
+ /**
11
+ * Dev mode - enables additional debugging
12
+ * @default false
13
+ */
14
+ dev?: boolean;
15
+ /**
16
+ * Hot module replacement (requires dev: true)
17
+ * @default true in dev mode
18
+ */
19
+ hot?: boolean;
20
+ /**
21
+ * Filter which files to transform (regex pattern)
22
+ * @default /\.[jt]sx$/
23
+ */
24
+ include?: RegExp;
25
+ /**
26
+ * Filter which files to exclude (regex pattern)
27
+ * @default /node_modules/
28
+ */
29
+ exclude?: RegExp;
30
+ /**
31
+ * The module to import runtime helpers from
32
+ * @default 'solid-js/web'
33
+ */
34
+ module_name?: string;
35
+ /**
36
+ * Generate mode
37
+ * @default 'dom'
38
+ */
39
+ generate?: 'dom' | 'ssr' | 'universal';
40
+ /**
41
+ * Enable hydration support
42
+ * @default false
43
+ */
44
+ hydratable?: boolean;
45
+ /**
46
+ * Delegate events for better performance
47
+ * @default true
48
+ */
49
+ delegate_events?: boolean;
50
+ /**
51
+ * Wrap conditionals in memos
52
+ * @default true
53
+ */
54
+ wrap_conditionals?: boolean;
55
+ /**
56
+ * Pass context to custom elements
57
+ * @default true
58
+ */
59
+ context_to_custom_elements?: boolean;
60
+ /**
61
+ * Built-in components that should be passed through
62
+ */
63
+ builtIns?: string[];
64
+ /**
65
+ * Enable SSR mode
66
+ * @default false
67
+ */
68
+ ssr?: boolean;
69
+ }
70
+ /**
71
+ * Rolldown plugin for SolidJS using OXC-based compiler
72
+ */
73
+ export default function solidOxc(options?: SolidOxcOptions): Plugin;
74
+ 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('@wq2/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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wq2/rolldown-plugin-solid-oxc",
3
- "version": "0.1.0-alpha.15",
3
+ "version": "0.1.0-alpha.16",
4
4
  "description": "Rolldown plugin for SolidJS using OXC-based compiler",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",