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

Output changing between builds since v8.3.0 #1246

Open
phcyso opened this issue Oct 30, 2024 · 0 comments
Open

Output changing between builds since v8.3.0 #1246

phcyso opened this issue Oct 30, 2024 · 0 comments

Comments

@phcyso
Copy link

phcyso commented Oct 30, 2024

Since the tinyglobby change was introduced we have been seeing our output files change between builds.

In a monorepo project we have multiple entrypoints and since 8.3.0 of tsup we have been seeing the resulting output files change between subsequent builds, primarily due to chunk names changing.

I have set up a minimal reproduction of the issue here:
https://github.com/phcyso/tsup_glob_bug_repro

Running yarn bundle over and over will cause at least two files to change each time.

e.g.
Running yarn bundle against the main branch of my reproduction causes one of the index files to diff as:

--- import{b as i}from"../chunk-BJMENOML.mjs";import{a as o}from"../chunk-6VRBJZPP.mjs";import{a as r,b as t,d as m}from"../chunk-V3Q6A3RL.mjs";async function n(){t("world 4"),o("world 4"),o(`what - ${i}`)}r(n,"main");m(import.meta.url,n);export{n as main};

+++
import{a as o}from"../chunk-6VRBJZPP.mjs";import{b as i}from"../chunk-BJMENOML.mjs";import{a as r,b as t,d as m}from"../chunk-V3Q6A3RL.mjs";async function n(){t("world 4"),o("world 4"),o(`what - ${i}`)}r(n,"main");m(import.meta.url,n);export{n as main};

And then running it a second time gives

import{b as i}from"../chunk-BJMENOML.mjs";import{a as o}from"../chunk-6VRBJZPP.mjs";import{a as r,b as t,d as m}from"../chunk-V3Q6A3RL.mjs";async function n(){t("world 4"),o("world 4"),o(`what - ${i}`)}r(n,"main");m(import.meta.url,n);export{n as main};

so back to the original.

This will then flip flop back and forth between these two outputs.

We did some digging and this appears to be the culprit:
https://github.com/egoist/tsup/blob/main/src/index.ts#L111

After hacking this line in node_modules directly to sort the result of the glob call:
options.entry = (await _tinyglobby.glob.call(void 0, entry)).sort();
the issue appears fixed.

I have not raised a PR for this as I am not fully across what the implications of sorting the glob output would be.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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

No branches or pull requests

1 participant