anyone tried using SST with ES modules? it’s not g...
# general
m
anyone tried using SST with ES modules? it’s not going well for me, getting
require() of ES modules is not supported.
r
Are you not able to use
import
?
m
i’m running the build scripts. they won’t run unless i mark them as explicitly commonjs, and if i do it won’t let them import ESM it seems.
r
What does your tsconfig look like?
m
Copy code
{
  // <https://www.npmjs.com/package/@tsconfig/node14>
  "extends": "@tsconfig/node14/tsconfig.json",

  "compilerOptions": {
    "module": "esnext",
    "target": "ESNext",
    "allowJs": true,
    "esModuleInterop": true,
    "composite": true, // <https://www.typescriptlang.org/docs/handbook/project-references.html>
    "incremental": true,

    "jsx": "react-jsx", // better frontend/backend tooling interoperability (ts-jest)

    "moduleResolution": "node", // modern
    "declaration": true /* Generates corresponding '.d.ts' file. */,
    "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
    "sourceMap": true /* Generates corresponding '.map' file. */,
    // "resolveJsonModule": true, // allow importing JSON files
    "experimentalDecorators": true, // enable decorators
    "emitDecoratorMetadata": true, // for runtime use of decorators
    // "baseUrl": "packages", // allow absolute path imports for all project packages
    "strictPropertyInitialization": true,
    "strictNullChecks": true,
    // "noUnusedLocals": true /* Report errors on unused locals. */,
    // "noUnusedParameters": true /* Report errors on unused parameters. */,
    "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
    "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
    "noImplicitOverride": true // must use override
  }
}
i’m just going to try to deal with the dependency issue since it’s mine
I started trying to convert SST to use ES modules. It was a lot of work but I think I got really far. I am happy to discuss this with anyone. https://github.com/serverless-stack/serverless-stack/pull/1117
d
https://github.com/ungarida/email-forwarder/blob/main/src/lambda.ts#L5 I used one like this... but not sure if this is what you mean