makepack 1.5.17 → 1.5.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makepack",
3
- "version": "1.5.17",
3
+ "version": "1.5.19",
4
4
  "type": "module",
5
5
  "description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
6
6
  "files": [
@@ -10,7 +10,6 @@ const server = async () => {
10
10
  const config = await makepackConfig()
11
11
  userExpress(app)
12
12
  await viteSetup(app)
13
-
14
13
  app.use((_req, res) => {
15
14
  res.status(500).send('Internal Server Error');
16
15
  });
@@ -39,35 +39,30 @@ const start = async () => {
39
39
  process.exit(1)
40
40
  }
41
41
 
42
- startServer(config)
43
42
  const expressjs = path.join(process.cwd(), 'express.js')
44
43
  const expressts = path.join(process.cwd(), 'express.ts')
45
44
 
46
45
  if (fs.existsSync(expressjs) || fs.existsSync(expressts)) {
47
46
  let filename = fs.existsSync(expressjs) ? "express.js" : "express.ts";
48
- const build = () => {
49
- esbuild.build({
50
- entryPoints: [filename],
51
- outfile: path.resolve(__dirname, 'user-express.js'),
52
- bundle: true,
53
- format: 'esm',
54
- platform: 'node',
55
- });
56
- }
47
+ let outfile = path.resolve(__dirname, 'user-express.js')
48
+
49
+ const ctx = await esbuild.context({
50
+ entryPoints: [filename],
51
+ outfile: path.resolve(__dirname, 'user-express.js'),
52
+ bundle: true,
53
+ format: 'esm',
54
+ platform: 'node',
55
+ external: ['express'],
56
+ })
57
57
 
58
- build()
58
+ ctx.watch()
59
59
 
60
- const watcher = chokidar.watch(filename, {
60
+ const watcher = chokidar.watch(outfile, {
61
61
  persistent: true,
62
62
  ignoreInitial: true,
63
63
  });
64
64
 
65
65
  watcher.on('change', async () => {
66
- build()
67
- startServer(config)
68
- });
69
-
70
- watcher.on('unlink', (path) => {
71
66
  startServer(config)
72
67
  });
73
68
 
@@ -76,6 +71,7 @@ const start = async () => {
76
71
  process.exit(0);
77
72
  });
78
73
  }
74
+ startServer(config)
79
75
  }
80
76
 
81
77
  export default start
@@ -1,8 +1,7 @@
1
1
  // express.ts
2
- var express = (app) => {
3
-
2
+ var expressApp = (app) => {
4
3
  };
5
- var express_default = express;
4
+ var express_default = expressApp;
6
5
  export {
7
6
  express_default as default
8
7
  };
@@ -7,6 +7,7 @@ const viteSetup = async (app) => {
7
7
  const config = await makepackConfig()
8
8
  const viteConfig = {
9
9
  root: process.cwd(),
10
+ base: "/",
10
11
  // plugins: [react()],
11
12
  server: {
12
13
  middlewareMode: true,
@@ -26,6 +27,7 @@ const viteSetup = async (app) => {
26
27
 
27
28
  app.get('*', async (req, res, next) => {
28
29
  const url = req.originalUrl;
30
+
29
31
  try {
30
32
  let template = await vite.transformIndexHtml(url, `
31
33
  <!doctype html>
@@ -40,6 +42,7 @@ const viteSetup = async (app) => {
40
42
  </body>
41
43
  </html>
42
44
  `);
45
+
43
46
  res.status(200).set({
44
47
  'Content-Type': 'text/html'
45
48
  }).end(template);