https://serverless-stack.com/ logo
#sst
Title
# sst
t

thdxr

12/12/2021, 12:28 AM
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

Mischa Spiegelmock

12/12/2021, 8:21 AM
Tite
d

Derek Kershner

12/13/2021, 4:11 PM
i was just gonna wait for Node 16 (maybe a month or two?)
m

Mischa Spiegelmock

12/13/2021, 4:11 PM
does node 16 have better ESM support?
d

Derek Kershner

12/13/2021, 4:16 PM
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

Mischa Spiegelmock

12/13/2021, 4:16 PM
type:module has been around for a few versions
d

Derek Kershner

12/13/2021, 4:17 PM
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

Mischa Spiegelmock

12/13/2021, 4:19 PM
t

thdxr

12/13/2021, 4:26 PM
I thought top level await was supported in aws lambda already
d

Derek Kershner

12/13/2021, 5:04 PM
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

Ryan

12/23/2021, 12:43 AM
Yeah, I had to do some workarounds with OneTable migrations that are all esm.
2 Views