Skip to content

Conversation

@lucassarcanjo
Copy link

Previously, KeepNames, Target, and Sourcemap options were hardcoded and ignored user configuration. This allows users to override these options via transform.server.build.esbuild to resolve issues like SSR hydration problems in TanStack Start applications.

Note: KeepNames defaults to true. Only override if user explicitly disables it. For Target and Sourcemap, check non-zero values as zero represents "not set" for these enums.

Fixes #6293

Previously, KeepNames, Target, and Sourcemap options were hardcoded
and ignored user configuration. This allows users to override these
options via transform.server.build.esbuild to resolve issues like
SSR hydration problems in TanStack Start applications.

Fixes anomalyco#6293
@vimtor vimtor self-assigned this Jan 13, 2026
@vimtor
Copy link
Collaborator

vimtor commented Jan 13, 2026

thanks for your contribution @lucassarcanjo

do you have any good example/use case for me to try this out?

@lucassarcanjo
Copy link
Author

I used examples/cloudflare-worker and added custom properties like keepNames in the build configuration:

Example of sst.config.ts
/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
app(input) {
  return {
    name: "cloudflare-worker",
    removal: input?.stage === "production" ? "retain" : "remove",
    home: "cloudflare",
  };
},
async run() {
  const bucket = new sst.cloudflare.Bucket("MyBucket");
  const worker = new sst.cloudflare.Worker("MyWorker", {
    handler: "./index.ts",
    link: [bucket],
    url: true,

    // configuration to be tested here
    build: {
      esbuild: {
        keepNames: false,
      },
    },
  });

  return {
    api: worker.url,
  };
},
});

Added a log to get all configurations from worker.go and got the correct values:

slog.Info("building with options", "options", options)

image

Copy link
Collaborator

@vimtor vimtor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your contribution @lucassarcanjo

the keepNames option works without any issue

however the sourcemap and target options don't seem to update when you set the config probably because of how the json unmarshalling works from the raw string to the go enum

we either fix them or remove their overriding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloudflare Worker: Allow overriding hardcoded esbuild options

2 participants