neutronium 3.0.2 → 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 -41
- package/package.json +3 -2
- package/sandbox.mjs +29 -0
package/compiler/compiler.js
CHANGED
|
@@ -92,45 +92,6 @@ async function compileProject(projectDir = process.cwd()) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
async function compileAndReturnOutput(code) {
|
|
96
|
-
try {
|
|
97
|
-
log('📁 Scanning project files...');
|
|
98
|
-
log(`⚙️ Babel transforming`);
|
|
99
|
-
|
|
100
|
-
code = babel.transformSync(code, {
|
|
101
|
-
babelrc: false,
|
|
102
|
-
configFile: false,
|
|
103
|
-
presets: [],
|
|
104
|
-
plugins: [[
|
|
105
|
-
'@babel/plugin-transform-react-jsx',
|
|
106
|
-
{
|
|
107
|
-
pragma: '_neutronium.h',
|
|
108
|
-
pragmaFrag: '_neutronium.Fragment',
|
|
109
|
-
runtime: 'classic',
|
|
110
|
-
}
|
|
111
|
-
]]
|
|
112
|
-
});
|
|
113
|
-
code = code.code
|
|
114
|
-
// Ensure _neutronium is imported
|
|
115
|
-
if (!code.includes('_neutronium')) {
|
|
116
|
-
code = `import * as _neutronium from 'https://esm.sh/neutronium@3.0.2/es2022/neutronium.mjs`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Replace imports to "neutronium" with local path
|
|
120
|
-
code = code.replace(/from\s+['"]neutronium['"]/g, `from '${neutroniumPath.replace(/\\/g, '/')}'`);
|
|
121
|
-
|
|
122
|
-
console.log('🛠️ Generating index.html...');
|
|
123
|
-
const htmlContent = baseHtml(code);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
log('✅ Compilation complete!');
|
|
127
|
-
return htmlContent;
|
|
128
|
-
} catch (e) {
|
|
129
|
-
console.error('❌ Compilation failed:', e.message);
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
95
|
function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
|
|
135
96
|
const server = serveProject(projectDir, port);
|
|
136
97
|
compileProject(projectDir);
|
|
@@ -283,6 +244,5 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
|
|
|
283
244
|
module.exports = {
|
|
284
245
|
compileProject,
|
|
285
246
|
compileProjectWatch,
|
|
286
|
-
serveProject
|
|
287
|
-
compileAndReturnOutput
|
|
247
|
+
serveProject
|
|
288
248
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neutronium",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Ultra-dense JavaScript framework – maximum performance, minimal overhead",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/core": "^7.28.0",
|
|
35
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
35
|
+
"@babel/plugin-transform-react-jsx": "^7.28.6",
|
|
36
36
|
"@babel/preset-env": "^7.28.0",
|
|
37
37
|
"@babel/preset-react": "^7.27.1",
|
|
38
|
+
"@babel/standalone": "^7.28.6",
|
|
38
39
|
"chokidar": "^4.0.3",
|
|
39
40
|
"inquirer": "^12.7.0",
|
|
40
41
|
"mime": "^4.0.7",
|
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
|
+
}
|