@package-broker/adapter-node 0.3.2 → 0.3.8

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": "@package-broker/adapter-node",
3
- "version": "0.3.2",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "typecheck": "tsc --noEmit",
9
9
  "dev": "tsx watch src/index.ts",
10
10
  "build": "tsup",
11
- "start": "node dist/index.js",
11
+ "start": "node dist/index.cjs",
12
12
  "clean": "rm -rf dist"
13
13
  },
14
14
  "dependencies": {
package/src/index.ts CHANGED
@@ -7,7 +7,6 @@ import { FileSystemDriver } from './drivers/fs-driver.js';
7
7
  import { RedisDriver } from './drivers/redis-driver.js';
8
8
  import { MemoryCacheDriver, MemoryQueueDriver } from '@package-broker/core';
9
9
  import path from 'node:path';
10
- import { fileURLToPath } from 'node:url';
11
10
  import { serveStatic } from '@hono/node-server/serve-static';
12
11
  import { readFile } from 'node:fs/promises';
13
12
  import type { Context, Next } from 'hono';
@@ -15,8 +14,6 @@ import type { Context, Next } from 'hono';
15
14
  // Load environment variables
16
15
  config();
17
16
 
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
-
20
17
  // Configuration
21
18
  const PORT = Number(process.env.PORT) || 3000;
22
19
  const DB_DRIVER = process.env.DB_DRIVER || 'sqlite';
@@ -86,7 +83,7 @@ async function start() {
86
83
  });
87
84
 
88
85
  // Serve config.js dynamically
89
- app.get('/config.js', (c: Context) => {
86
+ appInstance.get('/config.js', (c: Context) => {
90
87
  return c.text(`window.env = { API_URL: "${process.env.API_URL || '/'}" };`, 200, {
91
88
  'Content-Type': 'application/javascript',
92
89
  });
@@ -94,10 +91,10 @@ async function start() {
94
91
 
95
92
  if (process.env.PUBLIC_DIR) {
96
93
  console.log(`Serving static files from ${process.env.PUBLIC_DIR}`);
97
- app.use('/*', serveStatic({ root: process.env.PUBLIC_DIR }));
94
+ appInstance.use('/*', serveStatic({ root: process.env.PUBLIC_DIR }));
98
95
 
99
96
  // SPA Fallback
100
- app.get('*', async (c: Context) => {
97
+ appInstance.get('*', async (c: Context) => {
101
98
  try {
102
99
  return c.html(await readFile(path.join(process.env.PUBLIC_DIR!, 'index.html'), 'utf-8'));
103
100
  } catch (e) {
package/tsup.config.ts CHANGED
@@ -10,11 +10,25 @@ const cloudflarePlugin = {
10
10
  },
11
11
  };
12
12
 
13
+
14
+ // Node.js built-in modules that should not be bundled
15
+ const nodeBuiltins = [
16
+ 'util', 'path', 'fs', 'os', 'crypto', 'stream', 'events', 'buffer',
17
+ 'url', 'querystring', 'http', 'https', 'net', 'tls', 'dns', 'zlib',
18
+ 'child_process', 'cluster', 'module', 'process', 'assert', 'string_decoder',
19
+ 'timers', 'punycode', 'readline', 'repl', 'tty', 'vm', 'worker_threads'
20
+ ];
21
+
13
22
  export default defineConfig({
14
23
  entry: ['src/index.ts'],
15
- format: ['esm'],
24
+ // Output CommonJS to avoid ESM/CJS interop issues entirely.
25
+ // CJS uses require() natively - no createRequire shims needed.
26
+ format: ['cjs'],
16
27
  target: 'node20',
28
+ // Keep core/shared bundled so Node can run the built output even if core uses
29
+ // extensionless / directory imports that Node ESM won't resolve at runtime.
17
30
  noExternal: ['@package-broker/core', '@package-broker/shared'],
31
+ external: nodeBuiltins,
18
32
  clean: true,
19
33
  esbuildPlugins: [cloudflarePlugin],
20
34
  });