Isn’t `esBuildConfig.define` supposed to replace a...
# help
d
Isn’t
esBuildConfig.define
supposed to replace as a string? With this…
Copy code
const viewerRequest = new sst.Function(this, 'FunctionViewerRequest', {
  handler: 'src/viewer-request.handler',
  ...defaultOptions,
  memorySize: 128,
  timeout: cdk.Duration.seconds(5),
  bundle: {
    esbuildConfig: {
      define: {
        'process.env.PRERENDER_TOKEN': 'NOT_TELLING',
      },
    },
  },
})
… and this in the function…
Copy code
const PRERENDER_TOKEN = process.env.PRERENDER_TOKEN
…I’m getting the error…
"errorMessage":"NOT_TELLING is not defined"
Which makes it look like the replacement isn’t replacing as a string?
""
I know using env vars is easier… but this is for an edge function where that is not supported
t
Can you wrap it in quotes?
it replaces the literal otherwise it couldn't support replacing numbers
d
which part? when defining the “define” or IN the function?
t
'"NOT_TELLING"'
d
kk
ya just wanted to make sure that was intentional.
t
yeah it's esbuild behavior we just pass through