neutronium 1.6.0 → 1.8.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.
@@ -14,9 +14,7 @@ function compileProject(projectDir = process.cwd()) {
14
14
  const distDir = path.join(projectDir, 'dist');
15
15
  const outHtmlPath = path.join(distDir, 'index.html');
16
16
  const outJsPath = path.join(distDir, 'App.compiled.js');
17
-
18
- // Use relative path to Neutronium source
19
- const neutroniumPath = path.relative(distDir, path.join(projectDir, 'node_modules/neutronium/src/index.js')).replace(/\\/g, '/');
17
+ const neutroniumPath = '../node_modules/neutronium/src/index.js';
20
18
 
21
19
  try {
22
20
  log('📖 Reading App.js...');
@@ -26,16 +24,18 @@ function compileProject(projectDir = process.cwd()) {
26
24
  const { code: transpiled } = babel.transformSync(sourceCode, {
27
25
  filename: 'App.js',
28
26
  presets: [['@babel/preset-env', { targets: { esmodules: true } }]],
29
- plugins: [['@babel/plugin-transform-react-jsx', { pragma: 'h' }]],
27
+ plugins: [['@babel/plugin-transform-react-jsx', { pragma: '_neutronium.h' }]],
30
28
  });
31
29
 
32
- log('📦 Writing App.compiled.js...');
33
30
  const finalJsCode = `
34
- import { h, createApp } from '${neutroniumPath}';
31
+ import * as _neutronium from '${neutroniumPath}';
32
+
33
+ "use strict";
35
34
 
36
35
  ${transpiled}
37
36
 
38
- createApp(App).mount('#app');
37
+ (0, _neutronium.createApp)(App).mount('#app');
38
+ _neutronium.createApp(App).mount('#app');
39
39
  `.trim();
40
40
 
41
41
  ensureDir(distDir);
@@ -70,11 +70,17 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
70
70
  }
71
71
 
72
72
  function serveProject(projectDir = process.cwd(), port = 3000) {
73
- const distDir = projectDir
73
+ const distDir = path.join(projectDir, 'dist');
74
74
 
75
75
  const server = http.createServer((req, res) => {
76
- let reqPath = req.url === '/' ? '/index.html' : req.url;
77
- const filePath = path.join(distDir, reqPath);
76
+ let reqPath = req.url;
77
+
78
+ // Redirect "/" to "dist/index.html"
79
+ if (reqPath === '/' || reqPath === '/index.html') {
80
+ reqPath = '/dist/index.html';
81
+ }
82
+
83
+ const filePath = path.join(projectDir, reqPath);
78
84
 
79
85
  if (!fs.existsSync(filePath)) {
80
86
  res.writeHead(404);
@@ -104,4 +110,4 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
104
110
  return server;
105
111
  }
106
112
 
107
- module.exports = { compileProject, compileProjectWatch };
113
+ module.exports = { compileProject, compileProjectWatch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutronium",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "A dense, efficient JavaScript framework for building modern web applications",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",