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

Upgrade vite to latest 4.x version #351

Closed
chrispcampbell opened this issue Sep 2, 2023 · 1 comment · Fixed by #354, #353 or #364
Closed

Upgrade vite to latest 4.x version #351

chrispcampbell opened this issue Sep 2, 2023 · 1 comment · Fixed by #354, #353 or #364
Assignees
Labels
dependencies Pull requests that update a dependency file improvement

Comments

@chrispcampbell
Copy link
Contributor

We're on an older version of vite (3.1.3), and dependabot suggests upgrading to the most recent 3.x version. I'm not quite ready to upgrade to 4.x (need to see whether there are any incompatibilities affecting plugin-vite, or if we can change the peer dependency spec there to be 3.x OR 4.x). So for now we should do the minimal change and upgrade to the latest 3.x version, which seems safe from my testing.

@chrispcampbell chrispcampbell added dependencies Pull requests that update a dependency file improvement labels Sep 2, 2023
@chrispcampbell chrispcampbell self-assigned this Sep 2, 2023
@chrispcampbell chrispcampbell changed the title Upgrade vite to latest 3.x version Upgrade vite to latest 4.x version Sep 5, 2023
@chrispcampbell
Copy link
Contributor Author

chrispcampbell commented Sep 5, 2023

After further investigation, I found that we'd need some fixes to get things working with the latest 3.x version (3.2.7), and similar fixes are needed for the latest 4.x (4.4.9). Since 4.x has been out for over 9 months, and they're getting ready for another major version bump to 5.x, it doesn't really make sense to hang on to 3.x any longer.

There are a few specific places in the SDE repo that we make use of vite, which I'll summarize below for the record:

  • check-ui-shell (dev dependency): We use vite only as a bundler (in library mode) to generate the index.js bundle. This one is straightforward and there are no issues with using 4.4.9 here.

  • plugin-check (direct dependency): We have 3 different vite config files in this package (that get used when a client project uses this plugin). For this package, we need a couple changes to those config files so that they work with 4.4.9 (I will pin to 4.4.9 specifically for now until I get a better sense of how compatible upcoming versions of vite are).

  • plugin-vite (peer dependency): This plugin is a simple wrapper around vite, and there are no significant API changes between 3.x and 4.x, so I will update the peer dependency spec to allow either one ("vite": "^3.0.0 || ^4.0.0"). This way we can still use 3.x for building En-ROADS the app (in the short term, until I get it fully updated to work with 4.x) but still use 4.x in other places (like model-check).

  • plugin-worker (direct dependency): We have 1 bundled vite config in this package, and an earlier workaround (that tries to prevent the vite resolver from using the browser field of the threads package) is not working in more recent 3.x and 4.x versions, so I found a different solution (use browserField: false) so that we no longer need that workaround.

  • I upgraded to 4.x in devDependencies for template-default, and in the sample-check-* packages.

  • I also upgraded @sveltejs/vite-plugin-svelte and vitest to the latest for compatibility with the newer vite 4.x we're using.

The one unsavory part of this change is the new workaround I've had to add in plugin-check in vite-config-for-bundle.ts that intercepts some vite:resolve calls so that we don't use the browser field from the threads package. This is pretty fragile, but since we pin specific versions of vite and threads it should be good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file improvement
Projects
None yet
1 participant