File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616 the committed wrapper re-exports). This avoids both Vercel's TS
1717 compilation overwriting the bundle (` ERR_MODULE_NOT_FOUND ` ) and the
1818 "File not found" error from deleting source files during build.
19+ Added ` createRequire ` banner to the esbuild config so that CJS
20+ dependencies (knex/tarn) can ` require() ` Node.js built-in modules like
21+ ` events ` without the "Dynamic require is not supported" error.
1922 Updated rewrites to match: ` /api/:path* ` → ` /api/[[...route]] ` .
2023- ** Studio CORS error on Vercel temporary/preview domains** — Changed
2124 ` VITE_SERVER_URL ` from hardcoded ` https://play.objectstack.ai ` to ` "" `
Original file line number Diff line number Diff line change @@ -45,7 +45,19 @@ await build({
4545 // Vercel resolves ESM .js files correctly when "type": "module" is set.
4646 // CJS format would conflict with the project's "type": "module" setting,
4747 // causing Node.js to fail parsing require()/module.exports as ESM syntax.
48- banner : { js : '// Bundled by esbuild — see scripts/bundle-api.mjs' } ,
48+ //
49+ // The createRequire banner provides a real `require` function in the ESM
50+ // scope. esbuild's __require shim (generated for CJS→ESM conversion)
51+ // checks `typeof require !== "undefined"` and uses it when available,
52+ // which fixes "Dynamic require of <builtin> is not supported" errors
53+ // from CJS dependencies like knex/tarn that require() Node.js built-ins.
54+ banner : {
55+ js : [
56+ '// Bundled by esbuild — see scripts/bundle-api.mjs' ,
57+ 'import { createRequire } from "module";' ,
58+ 'const require = createRequire(import.meta.url);' ,
59+ ] . join ( '\n' ) ,
60+ } ,
4961} ) ;
5062
5163console . log ( '[bundle-api] Bundled server/index.ts → api/_handler.js' ) ;
You can’t perform that action at this time.
0 commit comments