frontend-hamroun 1.1.42 → 1.1.44

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.
Files changed (2) hide show
  1. package/bin/cli.js +0 -69
  2. package/package.json +1 -2
package/bin/cli.js CHANGED
@@ -7,59 +7,10 @@ import path from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import chalk from 'chalk';
9
9
  import { createSpinner } from 'nanospinner';
10
- import { createServer } from 'http';
11
10
 
12
11
  const __filename = fileURLToPath(import.meta.url);
13
12
  const __dirname = path.dirname(__filename);
14
13
 
15
- async function createDevServer(options = {}) {
16
- const { port = 3000, isSSR = false } = options;
17
-
18
- try {
19
- const esbuild = await import('esbuild');
20
-
21
- const ctx = await esbuild.context({
22
- entryPoints: ['src/main.tsx'],
23
- bundle: true,
24
- outdir: 'dist',
25
- format: 'esm',
26
- platform: isSSR ? 'node' : 'browser',
27
- sourcemap: true,
28
- loader: { '.tsx': 'tsx', '.ts': 'tsx' },
29
- jsxFactory: '_jsx',
30
- jsxFragment: '_Fragment',
31
- banner: {
32
- js: `import { jsx as _jsx, Fragment as _Fragment } from 'frontend-hamroun';`,
33
- }
34
- });
35
-
36
- await ctx.watch();
37
-
38
- const server = createServer((req, res) => {
39
- const url = new URL(req.url || '', `http://${req.headers.host}`);
40
-
41
- if (url.pathname === '/') {
42
- res.writeHead(200, { 'Content-Type': 'text/html' });
43
- res.end(fs.readFileSync('index.html', 'utf8'));
44
- } else if (url.pathname.endsWith('.js')) {
45
- res.writeHead(200, { 'Content-Type': 'application/javascript' });
46
- res.end(fs.readFileSync(path.join('dist', url.pathname), 'utf8'));
47
- } else {
48
- res.writeHead(404);
49
- res.end();
50
- }
51
- });
52
-
53
- server.listen(port);
54
- console.log(chalk.green(`Development server running at http://localhost:${port}`));
55
-
56
- return { server, ctx };
57
- } catch (error) {
58
- console.error('Failed to load esbuild:', error);
59
- throw error;
60
- }
61
- }
62
-
63
14
  async function init() {
64
15
  const program = new Command();
65
16
 
@@ -72,26 +23,6 @@ async function init() {
72
23
  await createProject(projectName);
73
24
  });
74
25
 
75
- program
76
- .command('dev')
77
- .description('Start development server')
78
- .option('-p, --port <port>', 'Port number', '3000')
79
- .option('--ssr', 'Enable SSR mode')
80
- .action(async (options) => {
81
- const spinner = createSpinner('Starting development server...').start();
82
- try {
83
- await createDevServer({
84
- port: parseInt(options.port),
85
- isSSR: options.ssr
86
- });
87
- spinner.success({ text: 'Development server started' });
88
- } catch (error) {
89
- spinner.error({ text: chalk.red('Failed to start server') });
90
- console.error(error);
91
- process.exit(1);
92
- }
93
- });
94
-
95
26
  program.parse();
96
27
  }
97
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-hamroun",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
4
4
  "description": "A lightweight frontend framework with hooks and virtual DOM",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -61,7 +61,6 @@
61
61
  "dependencies": {
62
62
  "chalk": "^5.3.0",
63
63
  "commander": "^11.0.0",
64
- "esbuild": "^0.19.2",
65
64
  "fs-extra": "^11.1.1",
66
65
  "inquirer": "^9.2.10",
67
66
  "nanospinner": "^1.1.0"