Skip to content

Synchronize browser and node targets with monorepo targets#83

Merged
JReinhold merged 1 commit intomainfrom
chore/remove-hardcoded-targets
Aug 25, 2025
Merged

Synchronize browser and node targets with monorepo targets#83
JReinhold merged 1 commit intomainfrom
chore/remove-hardcoded-targets

Conversation

@Sidnioulz
Copy link
Member

This PR ensures tsup builds with the same targets as Storybook. This is to avoid addon authors compiling for older targets and embedding polyfills for browsers that wouldn't run on Storybook anyway.

@JReinhold FYI assigning this to you as you last made changes to targets and I wanna make sure you're on board :)

@Sidnioulz Sidnioulz requested a review from JReinhold August 18, 2025 08:02
@JReinhold
Copy link
Collaborator

I actually explicitly removed the targets recently, with the argument that addons are going to be built by Storybook's manager builder anyway, so it doesn't add much value to try and do that beforehand. In fact, keeping it as modern as possible probably slims down the addon package.
For the preview entries I also think it's safe to assume that they get built by the user's builder, but we can't know for sure.

The only thing that won't get built by Storybook is the presets/node side of things, so we need to ensure they are built to a target matching Storybook's.

Although I also see this in the tsup docs:

The value for target defaults to compilerOptions.target in your tsconfig.json, or node14 if unspecified. For more information check out esbuild's target option.

Which in our case would mean that addons build for ES2023. Ideally they would build for esnext given the arguments above.

But I'm actually okay with the changes here, to keep things more explicit.

@JReinhold JReinhold merged commit b31cc1b into main Aug 25, 2025
1 of 2 checks passed
@JReinhold JReinhold deleted the chore/remove-hardcoded-targets branch August 25, 2025 07:45
@Sidnioulz
Copy link
Member Author

I actually explicitly removed the targets recently, with the argument that addons are going to be built by Storybook's manager builder anyway, so it doesn't add much value to try and do that beforehand. In fact, keeping it as modern as possible probably slims down the addon package. For the preview entries I also think it's safe to assume that they get built by the user's builder, but we can't know for sure.

The only thing that won't get built by Storybook is the presets/node side of things, so we need to ensure they are built to a target matching Storybook's.

Sorry, I was OOO and couldn't get back to you in time to discuss this before merging.

I agree with you that not having a browser target is better than having even an up-to-date one. My concern is that a lot of existing addons have out-of-date hardcoded targets, and people taking over these addons might find it easier to understand how to update targets if they see a new target syntax in the addon-kit.

I'd like to leave this imported target for two major versions and then remove it, as there'll be few addons left with hardcoded targets. Does that sound acceptable to you?

@JReinhold
Copy link
Collaborator

SGTM

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.

2 participants