@holistics/cli-core 1.0.6 → 2.0.1

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 (3) hide show
  1. package/README.md +16 -0
  2. package/dist/commands.js +1066 -680
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -28,3 +28,19 @@ pnpm run build:dev
28
28
 
29
29
  node ./dist_dev/cli.js
30
30
  ```
31
+
32
+ ## Build banner: `require` polyfill
33
+
34
+ Both `build:dev` and `bun_build.sh` pass this banner to `bun build`:
35
+
36
+ ```
37
+ --banner="import { createRequire } from 'module'; const require = createRequire(import.meta.url);"
38
+ ```
39
+
40
+ Why it's needed:
41
+ - `package.json` declares `"type": "module"`, so `bun build --target node` emits ESM. In ESM, `require` is not defined.
42
+ - The transitive dep `js-sha256` (pulled in via `@holistics/amql` → `packages/amql/src/utilities.ts` which imports `sha224`) detects Node at runtime and calls `eval("require('crypto')")` to swap in Node's native crypto. The `eval` hides the call from the bundler, so it's not rewritten — at runtime it expects a real `require` in scope.
43
+ - Without the banner, the bundle throws `ReferenceError: require is not defined in ES module scope` the first time `sha224` is called.
44
+ - The banner uses Node's `module.createRequire(import.meta.url)` to construct a working `require` bound to the bundle's location, which the `eval`'d code then picks up via lexical scope.
45
+
46
+ If `js-sha256` is ever removed from the dependency tree, this banner can be dropped.