Dynamic imports

I ended up with the following
No description
5 Replies
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
alotabits
alotabits3w ago
@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.
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
alotabits
alotabits3w ago
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.
Mozzy
MozzyOP3w ago
I ended up just throwing it all in KV. Best decision for me

Did you find this page helpful?