Skip to content

Commit bb49dd1

Browse files
committed
d
1 parent 33ab71e commit bb49dd1

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

esbuild-node.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
// used by esbuild-node.sh
1+
// This script bundles files matching *.node.[js|cjs|mjs] using esbuild.
2+
// The list of files to process is passed as a text file path in the first argument.
3+
//
4+
// WHY THIS SCRIPT EXISTS:
5+
// Raw esbuild typically outputs .js files. However, for Node.js scripts,
6+
// the extension (.cjs or .mjs) is critical for correct module resolution.
7+
//
8+
// Example Transformation:
9+
// Input: ./pages/bash/xx/xx.node.cjs
10+
// Esbuild: outputs ./pages/bash/xx/xx.node.bundled.gitignored.js
11+
// Script: copies .js to ./pages/bash/xx/xx.node.bundled.gitignored.cjs
12+
// (Note: This results in TWO files: the .js bundle and the .cjs copy)
13+
//
14+
// Without this script, Node.js might fail to run the bundle if it misinterprets
15+
// the module type (ESM vs CJS). This script keeps the target extension in sync.
16+
//
17+
// Usage:
18+
// node esbuild-node.js var/esbuild.txt
19+
// node esbuild-node.js var/esbuild.txt --watch
20+
//
21+
// Typically called by: /bin/bash esbuild-node.sh [watch]
22+
223

324
import * as esbuild from "esbuild";
425

xx.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ cat <<EEE
3232
server:
3333
http://\${LOCAL_HOSTS}:\${NODE_API_PORT}
3434
35+
Warning:
36+
Generally this project uses pnpm
37+
3538
EEE
3639
3740
`,

0 commit comments

Comments
 (0)