I know <@U02Q7J6A17S> was looking for ESM support ...
# sst
t
I know @Mischa Spiegelmock was looking for ESM support not sure who else - I personally want this as well. Turns out I was able to get it working with some fairly minimal changes to SST. We'd likely require a
bundle.esm
flag to be turned on to true and from there I need to package aws-lambda-ric in 2 different modes both for esm and cjs. The rest of SST can be left as is for now. Anyone else looking for ESM support?
Got the following file with top-level await working
Copy code
const x = await new Promise((r) => setTimeout(() => r(100), 1000));

export async function handler() {
  return x;
}
m
Tite
d
i was just gonna wait for Node 16 (maybe a month or two?)
m
does node 16 have better ESM support?
d
I believe it does, I haven't tried it personally as I was waiting, but I know it includes things like a
type: "module"
field in
package.json
and the experimental
esm-modules
flag is no longer required.
m
type:module has been around for a few versions
d
14.8+, but it has additional abilities around it like top-level await
it MIGHT give AWS enough to make ESM lambdas, was my thought.
m
t
I thought top level await was supported in aws lambda already
d
i dont see anything in that link about it...
are lambdas already using esm? I thought they were cjs only...
top level await requires esm, is what I am basing that on.
looks like I was inaccurate about 16 being required for that, maybe 16 is just all about ARM support
either way, i was just hopeful it would spur AWS to do the work
r
Yeah, I had to do some workarounds with OneTable migrations that are all esm.