这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix a race between dts clean and generate #767

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

Closed
wants to merge 1 commit into from
Closed

Fix a race between dts clean and generate #767

wants to merge 1 commit into from

Conversation

arilotter
Copy link

Rollup's buildStart hook runs in parallel - see https://github.com/rollup/rollup/blob/master/docs/05-plugin-development.md#buildstart As described in their "build hooks" section, parallel hooks "will be run in the specified plugin order. If a hook is async, subsequent hooks of this kind will be run in parallel and not wait for the current hook."
Since buildStart is parallel and we hadn't specified sequential: true or order: xxx, this plugin's buildStart hook could get run at the same time as other buildStart hooks. This caused a race condition when generating .d.ts files, and caused TSC errors consistently every other run of tsup.

This commit ensures that the clean plugin will always run before the .d.ts generation step, preventing the race.

Rollup's `buildStart` hook runs in parallel - see https://github.com/rollup/rollup/blob/master/docs/05-plugin-development.md#buildstart
As described in their "build hooks" section, `parallel` hooks "will be run in the specified plugin order. If a hook is async, subsequent hooks of this kind will be run in parallel and not wait for the current hook."
Since `buildStart` is parallel and we hadn't specified `sequential: true` or `order: xxx`, this plugin's `buildStart` hook could get run at the same time as other `buildStart` hooks.
This caused a race condition when generating `.d.ts` files, and caused TSC errors consistently every other run of `tsup`.

This commit ensures that the clean plugin will always run before the `.d.ts` generation step, preventing the race.
@vercel
Copy link

vercel bot commented Nov 9, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
tsup ✅ Ready (Inspect) Visit Preview Nov 9, 2022 at 5:33PM (UTC)

@arilotter
Copy link
Author

This doesn't seem to fix the issue when running tsup --watch, though..

@arilotter
Copy link
Author

After further investigation - this is not a TSUP bug, this is caused by a dependency cycle between two packages. Closing this PR.

@arilotter arilotter closed this Nov 10, 2022
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.

1 participant