thdxr
01/07/2022, 1:11 PMRoss Gerbasi
01/07/2022, 5:28 PMnode_modules folder just seeing if I could force this to happen. I am finding some success swapping the esbuild config in the NodeHandler and the runBeforeBundling hook with
target: "node14.8",
format: "esm",
I can at least get my project built out properly in that it will properly compile imports on external modules and top level await. Problem now seems to be getting it to run locally, and then I am assuming I would need to add type: module in my deployed package.json. Anyway it doesn't feel too far off. I was just curious what your approach was gonna be to this?
Seeing that esbuild is bundling all our code there is not much use in ESM imports. The only time they come into play is really external modules (aws-sdk). Since this is transpiled code though I don't think it matters to much whether it is required or imported.
However top level await is a bigger deal as we could do async operations prior to a handler even being called. This seems interesting to me. Sadly we need to move to module to get TLA.
For local I am wondering if a fake package.json in the artifacts folder set to module would get things working, or maybe when using ESM we need to swap to .mjs
Anyway just thinking out loud as its on my mind. Curious where your head is on this.Mischa Spiegelmock
01/08/2022, 2:04 PMRoss Gerbasi
01/09/2022, 8:52 PMmjs files. Are there issues going all in on .js with package of type: module? Could the dynamic requires be swapped with dynamic imports?thdxr
01/09/2022, 9:24 PMthdxr
01/09/2022, 9:24 PMthdxr
01/09/2022, 9:24 PMRoss Gerbasi
01/09/2022, 9:27 PMtype: module ?thdxr
01/10/2022, 2:45 PMthdxr
01/10/2022, 2:46 PMMischa Spiegelmock
01/10/2022, 4:30 PMRoss Gerbasi
01/10/2022, 5:53 PMtype: "module" would be great, and instead of generating .mjs files just push out a package.json with type: module for each lambda. Locally instead of using dynamic require() we could just use dynamid import() to bring in the handler in dev mode.
Or am I missing something obvious?Mischa Spiegelmock
01/10/2022, 6:02 PM__dirname but there are sort of like polyfillsRoss Gerbasi
01/10/2022, 6:04 PM