Skip to content

fix: rename server bundle to .cjs to fix ESM/CJS conflict#4

Merged
MarkAC007 merged 1 commit intomainfrom
fix/server-cjs-extension
Mar 27, 2026
Merged

fix: rename server bundle to .cjs to fix ESM/CJS conflict#4
MarkAC007 merged 1 commit intomainfrom
fix/server-cjs-extension

Conversation

@MarkAC007
Copy link
Copy Markdown
Owner

Summary

  • Renames esbuild server output from server.js to server.cjs in build script, Dockerfile, and start script
  • Fixes ReferenceError: require is not defined in ES module scope crash in Azure Container App
  • Root cause: package.json has "type": "module", causing Node.js to treat .js files as ESM, but the bundle uses CJS format with require() calls from @smithy packages

Test plan

  • npm run build:server produces dist/server.cjs
  • docker build -t dpsia-test . succeeds
  • Container starts without ESM/CJS errors
  • POST /assess endpoint works end-to-end

🤖 Generated with Claude Code

package.json has "type": "module" which causes Node.js to treat .js
files as ESM. The esbuild server bundle uses CJS format (require()),
so require() calls from @smithy packages fail at runtime with
"ReferenceError: require is not defined in ES module scope".

Renaming to .cjs explicitly tells Node.js to use CommonJS resolution.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@MarkAC007 MarkAC007 merged commit 2d7b972 into main Mar 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant