neutronium 3.0.3 → 3.0.4
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/compiler/compiler.js +1 -30
- package/package.json +1 -1
- package/sandbox.mjs +29 -0
package/compiler/compiler.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const babel = require('@babel/core');
|
|
2
|
-
import * as Babel from "@babel/standalone";
|
|
3
2
|
const path = require('path');
|
|
4
3
|
const fs = require('fs');
|
|
5
4
|
const { baseHtml } = require('./template');
|
|
@@ -93,33 +92,6 @@ async function compileProject(projectDir = process.cwd()) {
|
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
async function compileAndReturnOutput(source) {
|
|
97
|
-
try {
|
|
98
|
-
log(`⚙️ Babel transforming`);
|
|
99
|
-
|
|
100
|
-
const result = Babel.transform(source, {
|
|
101
|
-
plugins: [
|
|
102
|
-
'@babel/plugin-transform-react-jsx', {
|
|
103
|
-
pragma: "neutronium.h",
|
|
104
|
-
pragmaFrag: "_neutronium.Fragment",
|
|
105
|
-
runtime: "classic",
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
})
|
|
109
|
-
let code = result.code;
|
|
110
|
-
|
|
111
|
-
console.log('🛠️ Generating index.html...');
|
|
112
|
-
const htmlContent = baseHtml(code);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
log('✅ Compilation complete!');
|
|
116
|
-
return htmlContent;
|
|
117
|
-
} catch (e) {
|
|
118
|
-
console.error('❌ Compilation failed:', e.message);
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
95
|
function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
|
|
124
96
|
const server = serveProject(projectDir, port);
|
|
125
97
|
compileProject(projectDir);
|
|
@@ -272,6 +244,5 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
|
|
|
272
244
|
module.exports = {
|
|
273
245
|
compileProject,
|
|
274
246
|
compileProjectWatch,
|
|
275
|
-
serveProject
|
|
276
|
-
compileAndReturnOutput
|
|
247
|
+
serveProject
|
|
277
248
|
};
|
package/package.json
CHANGED
package/sandbox.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Babel from '@babel/standalone';
|
|
2
|
+
import { baseHtml } from './compiler/template';
|
|
3
|
+
|
|
4
|
+
export async function compileAndReturnOutput(source) {
|
|
5
|
+
try {
|
|
6
|
+
log(`⚙️ Babel transforming`);
|
|
7
|
+
|
|
8
|
+
const result = Babel.transform(source, {
|
|
9
|
+
plugins: [
|
|
10
|
+
'@babel/plugin-transform-react-jsx', {
|
|
11
|
+
pragma: "neutronium.h",
|
|
12
|
+
pragmaFrag: "_neutronium.Fragment",
|
|
13
|
+
runtime: "classic",
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
})
|
|
17
|
+
let code = result.code;
|
|
18
|
+
|
|
19
|
+
console.log('🛠️ Generating index.html...');
|
|
20
|
+
const htmlContent = baseHtml(code);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
log('✅ Compilation complete!');
|
|
24
|
+
return htmlContent;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error('❌ Compilation failed:', e.message);
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|