@zikojs/notebook-runtime-preact 0.2.0 → 0.3.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/package.json +8 -2
- package/src/index.js +16 -19
- package/src/transform.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zikojs/notebook-runtime-preact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
"author": "zakaria elalaoui",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"type": "module",
|
|
17
|
-
"dependencies": {
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"sucrase": "latest",
|
|
19
|
+
"@codemirror/lang-javascript": "latest"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"preact": "^10.27.2"
|
|
23
|
+
},
|
|
18
24
|
"scripts": {
|
|
19
25
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
20
26
|
}
|
package/src/index.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { transform } from "sucrase";
|
|
2
|
+
import { javascript } from '@codemirror/lang-javascript'
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const PreactIdentifier = "preact";
|
|
5
|
+
|
|
6
|
+
export const preactPlugin = () => ({
|
|
7
|
+
name: PreactIdentifier,
|
|
8
|
+
language: javascript({ jsx: true }),
|
|
9
9
|
|
|
10
10
|
async transform(code, context) {
|
|
11
|
-
|
|
12
|
-
if (context.runtime && context.runtime !== "preact") {
|
|
11
|
+
if (context.runtime && context.runtime !== PreactIdentifier) {
|
|
13
12
|
return code;
|
|
14
13
|
}
|
|
15
|
-
return transformPreact(code, { jsxRuntime, importSource });
|
|
16
|
-
},
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
15
|
+
return transform(code, {
|
|
16
|
+
transforms: ["jsx"],
|
|
17
|
+
jsxRuntime: "automatic",
|
|
18
|
+
jsxImportSource: "preact",
|
|
19
|
+
production: true,
|
|
20
|
+
}).code;
|
|
21
|
+
},
|
|
22
|
+
});
|
package/src/transform.js
DELETED