Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from esbuild to jiti for preset handling #29082

Closed
Tracked by #29038
JReinhold opened this issue Sep 11, 2024 · 1 comment
Closed
Tracked by #29038

Migrate from esbuild to jiti for preset handling #29082

JReinhold opened this issue Sep 11, 2024 · 1 comment
Assignees

Comments

@JReinhold
Copy link
Contributor

JReinhold commented Sep 11, 2024

Storybook currently use esbuild for 3 things:

  1. bundling/converting our own TS code to ESM and CJS (before publishing)
  2. bundling managerEntries from source (possibly TS, from users/addons) to an output that can run directly in the browser, whilst globalizing certain modules
  3. loading TS config files into node at runtime (main.ts) via esbuild-register

Can we replace it with a smaller runtime-bundler like jiti, that achieves the same thing?

@JReinhold JReinhold changed the title Replace [esbuild](esbuild.github.io) with [jiti](https://github.com/unjs/jiti) for preset handling Replace esbuild with jiti for preset handling Sep 11, 2024
@JReinhold JReinhold changed the title Replace esbuild with jiti for preset handling Migrate from esbuild to jiti for preset handling Sep 11, 2024
@ndelangen
Copy link
Member

I left a comment in my investigation-PR:

Jiti has a different approach to enabling loading .ts-files from esbuild-register.

Jiti seems to transpile the files individually, and skip files that don't need to be transpiled.

esbuild-register actually bundles the entrypoint into a single (in memory?) file.

The difference between these approaches is that esbuild-register solves any incorrect CJS > EMS usage by bundling; jiti will leave those problematic connections in place, which then fail at runtime.

In my PR I needed to solve this in our codebase in at least 1 place. So there's a high chance this problem might be in multiple presets of ours or community presets, or even in presets of users'.

For this reason it's my recommendation to make this change in a breaking change.

@JReinhold JReinhold closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants