alotabits
CDCloudflare Developers
•Created by Mozzy on 6/12/2024 in #workers-and-pages-discussions
Dynamic imports
Hmm, could it be that your esbuild output is creating commonjs? If that is the case, you may need an index.mjs shim that ES imports your index.js and ES exports the handler function. All this is sounding very similar to what had to do to get a webpack bundled project to run correctly. Webpack produced commonjs with bundle splitting and dynamic imports, but wrangler/workers needed a ESM file to root the project. Since webpack used commonjs, it uses require() statements instead of import() statements. I’m not sure how that lines up with your esbuild command line with —format=esm.
6 replies
CDCloudflare Developers
•Created by Mozzy on 6/12/2024 in #workers-and-pages-discussions
Dynamic imports
@Erik Beuschau Have you tried making the main file a .mjs? It’s long enough ago that I don’t recall the details, but I think this made a difference for me when I was using —no-bundle.
6 replies