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

feat: Add Vite build config #2

Merged
merged 20 commits into from Jan 3, 2024
Merged

feat: Add Vite build config #2

merged 20 commits into from Jan 3, 2024

Conversation

lachlancollins
Copy link
Member

@lachlancollins lachlancollins commented Dec 31, 2023

Changes

This PR is the culmination of several attempts at making our builds work in all environments. It started in Rollup, moved to tsup, and is now settling on Vite with plugins. This export contains all the generic settings which all our packages would need.

Limitations

  • Unlike the current tsup setup on some repos (e.g. query), it does not generate "legacy" builds for older bundlers (looking at you, Webpack 4). Migrating to this config here would be a major release.
  • While it can compile Svelte and Angular code, these frameworks have their own incredible build tools which should be used instead.

Todo

  • Integration tests
  • Documentation

@lachlancollins lachlancollins marked this pull request as draft December 31, 2023 09:34
@crutchcorn
Copy link
Member

FWIW the Angular Vite story is pretty good:

https://github.com/analogjs/analog/tree/main/packages/vite-plugin-angular

It's maintained by the Analog team, who use it for their metaframework and utilizes the official build tools under the hood.

@crutchcorn
Copy link
Member

Also, and apologies for potentially missing this - what is a "legacy" build. Specifically what changes are there over CJS?

@lachlancollins
Copy link
Member Author

FWIW the Angular Vite story is pretty good:

analogjs/analog@main/packages/vite-plugin-angular

It's maintained by the Analog team, who use it for their metaframework and utilizes the official build tools under the hood.

The angular-query-experimental package uses ng-packagr, which I think uses that plugin!

@lachlancollins
Copy link
Member Author

Also, and apologies for potentially missing this - what is a "legacy" build. Specifically what changes are there over CJS?

Legacy transpiled for bundlers that supported lower than ES2020, and therefore were larger files.

@crutchcorn
Copy link
Member

@lachlancollins could we have two Vite config files and pass this as a plugin to one in order to solve this?

https://www.npmjs.com/package/@vitejs/plugin-legacy

@crutchcorn
Copy link
Member

I know it seems hacky/silly to run multiple instances of Vite for different outputs, but isn't that what tsup effectively does as well?

@lachlancollins
Copy link
Member Author

I know it seems hacky/silly to run multiple instances of Vite for different outputs, but isn't that what tsup effectively does as well?

Oh for sure, I'm just wondering if we should be supporting deprecated bundlers which hold back the ecosystem. Introducing this to something like query would be a major release anyway, so it would be a reasonable time to drop Webpack v4.

@crutchcorn
Copy link
Member

Fair enough! You've got my vote.

@lachlancollins lachlancollins marked this pull request as ready for review December 31, 2023 21:48
@lachlancollins lachlancollins merged commit f3bd6a9 into main Jan 3, 2024
1 check passed
@lachlancollins lachlancollins deleted the build-config branch January 3, 2024 04:33
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.

None yet

2 participants