Hi, is there any guidance on setting up esbuild wi...
# help
s
Hi, is there any guidance on setting up esbuild with a sst site such that sourcemaps properly work? We're using esbuild-jest and currently all our line numbers in our stack trace is a few lines off.
t
is this frontend or backend?
s
backend. It's node giving me the wrong lines.
f
@thdxr would setting the
NODE_OPTIONS=--enable-source-maps
environment variable when running jest help @Steven Klaiber-Noblein ths case?
s
@Frank: good suggestion. I've added that in my debugging. I suspect that's necessary but not sufficient. eg I need to tell node to use the source-maps, but I suspect I'm not properly generating the sourcemaps.
it unfortunately didn't change anything.
f
just to clarify, by
sst site
do u mean an SST project where the line numbers are off when testing ur function code? Or do u mean an actual site created using the
sst.StaticSite
construct?
o
SST project. We’re using
esbuild-jest
and line numbers are off on functions. Here’s our jest config:
Copy code
"jest": {
    "transform": {
      "^.+\\.ts?$": [
        "esbuild-jest",
        {
          "sourcemap": "both"
        }
      ],
      "^.+\\.js?$": "esbuild-jest"
    },
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/(?!(lodash-es)/)"
    ],
    "setupFilesAfterEnv": [
      "../../jest.setup.js"
    ]
  }
t
this is probably unrelated to sst since esbuild-jest is compiling everything locally but node doesn't use sourcemaps without that flag right?
o
yeah it’s unrelated to SST, just seeing if to see if anyone in the brain trust has gotten sourcemaps to work
t
I started using esbuild-jest as well but I haven't noticed the sourcemap issue
o
mind sharing your config?
t
I meant I might have the sourcemap issue - just didn't notice it 😄 My config is esm focused:
Copy code
"jest": {
    "preset": "ts-jest/presets/default-esm",
    "setupFilesAfterEnv": [
      "<rootDir>/test/setup.ts"
    ],
    "moduleNameMapper": {
      "@bumi/core/(.*)$": "<rootDir>/core/$1"
    },
    "transform": {
      "^.+\\.tsx?$": [
        "esbuild-jest",
        {
          "sourcemap": true,
          "format": "esm",
          "target": "esnext"
        }
      ]
    }
  }
s
to close the loop here, we ended up solving this for us by switching from
esbuild-jest
to
@swc/jest