rolldown-plugin-solid-oxc 0.1.0-alpha.5 → 0.1.0-alpha.8
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.ts +76 -0
- package/dist/index.js +92 -0
- package/package.json +11 -13
- package/dist/index.d.mts +0 -71
- package/dist/index.mjs +0 -88
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,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
|
+
moduleName: opts.module_name,
|
|
60
|
+
generate,
|
|
61
|
+
hydratable: opts.hydratable,
|
|
62
|
+
delegateEvents: opts.delegate_events,
|
|
63
|
+
wrapConditionals: opts.wrap_conditionals,
|
|
64
|
+
contextToCustomElements: opts.context_to_custom_elements,
|
|
65
|
+
sourceMap: 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
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-solid-oxc",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"description": "Rolldown plugin for SolidJS using OXC-based compiler",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"types": "./dist/index.d.
|
|
11
|
-
"
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"dist"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
-
"dev": "
|
|
19
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
20
|
+
"dev": "tsup src/index.ts --format esm --dts --watch"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"rolldown",
|
|
@@ -40,11 +41,8 @@
|
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"solid-jsx-oxc": "*",
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"
|
|
45
|
-
"typescript": "^5.
|
|
46
|
-
},
|
|
47
|
-
"engines": {
|
|
48
|
-
"node": ">= 22"
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"tsup": "^8.0.0",
|
|
46
|
+
"typescript": "^5.0.0"
|
|
49
47
|
}
|
|
50
48
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "rolldown";
|
|
2
|
-
|
|
3
|
-
//#region src/index.d.ts
|
|
4
|
-
|
|
5
|
-
interface SolidOxcOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Dev mode - enables additional debugging
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
dev?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Hot module replacement (requires dev: true)
|
|
13
|
-
* @default true in dev mode
|
|
14
|
-
*/
|
|
15
|
-
hot?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Filter which files to transform (regex pattern)
|
|
18
|
-
* @default /\.[jt]sx$/
|
|
19
|
-
*/
|
|
20
|
-
include?: RegExp;
|
|
21
|
-
/**
|
|
22
|
-
* Filter which files to exclude (regex pattern)
|
|
23
|
-
* @default /node_modules/
|
|
24
|
-
*/
|
|
25
|
-
exclude?: RegExp;
|
|
26
|
-
/**
|
|
27
|
-
* The module to import runtime helpers from
|
|
28
|
-
* @default 'solid-js/web'
|
|
29
|
-
*/
|
|
30
|
-
module_name?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Generate mode
|
|
33
|
-
* @default 'dom'
|
|
34
|
-
*/
|
|
35
|
-
generate?: 'dom' | 'ssr' | 'universal';
|
|
36
|
-
/**
|
|
37
|
-
* Enable hydration support
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
hydratable?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Delegate events for better performance
|
|
43
|
-
* @default true
|
|
44
|
-
*/
|
|
45
|
-
delegate_events?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Wrap conditionals in memos
|
|
48
|
-
* @default true
|
|
49
|
-
*/
|
|
50
|
-
wrap_conditionals?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Pass context to custom elements
|
|
53
|
-
* @default true
|
|
54
|
-
*/
|
|
55
|
-
context_to_custom_elements?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Built-in components that should be passed through
|
|
58
|
-
*/
|
|
59
|
-
builtIns?: string[];
|
|
60
|
-
/**
|
|
61
|
-
* Enable SSR mode
|
|
62
|
-
* @default false
|
|
63
|
-
*/
|
|
64
|
-
ssr?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
68
|
-
*/
|
|
69
|
-
declare function solidOxc(options?: SolidOxcOptions): Plugin;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { SolidOxcOptions, solidOxc as default, solidOxc };
|
package/dist/index.mjs
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
//#region src/index.ts
|
|
2
|
-
const 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
|
-
/**
|
|
27
|
-
* Rolldown plugin for SolidJS using OXC-based compiler
|
|
28
|
-
*/
|
|
29
|
-
function solidOxc(options = {}) {
|
|
30
|
-
const opts = {
|
|
31
|
-
...defaultOptions,
|
|
32
|
-
...options
|
|
33
|
-
};
|
|
34
|
-
let solidJsxOxc = null;
|
|
35
|
-
return {
|
|
36
|
-
name: "rolldown-plugin-solid-oxc",
|
|
37
|
-
async buildStart() {
|
|
38
|
-
try {
|
|
39
|
-
solidJsxOxc = await import("solid-jsx-oxc");
|
|
40
|
-
} catch (e) {
|
|
41
|
-
this.error("Failed to load solid-jsx-oxc. Make sure it is built for your platform.");
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
transform: {
|
|
45
|
-
filter: { id: {
|
|
46
|
-
include: opts.include,
|
|
47
|
-
exclude: opts.exclude
|
|
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) finalCode = finalCode + `
|
|
69
|
-
if (import.meta.hot) {
|
|
70
|
-
import.meta.hot.accept();
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
return {
|
|
74
|
-
code: finalCode,
|
|
75
|
-
map: result.map ? JSON.parse(result.map) : null
|
|
76
|
-
};
|
|
77
|
-
} catch (e) {
|
|
78
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
79
|
-
this.error(`Failed to transform ${id}: ${message}`);
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
export { solidOxc as default, solidOxc };
|