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

Bump vite to ~5.4.14 #2312

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Bump vite to ~5.4.14 #2312

wants to merge 10 commits into from

Conversation

r100-stack
Copy link
Member

@r100-stack r100-stack commented Oct 23, 2024

Changes

After PR TODO from #2256 (#2256 (comment)).

Fixes GHSA-vg6x-rcgg-rjx6. Closed #2409 in favor of this PR.


Bumps vite from ~5.1 to ~5.4.14.

After the bump, the styles.css was not getting generated in styles.js/dist. Looks like it is because of vitejs/vite/#16051 from 5.2.0-beta.0.

To fix it, I added the vite plugin suggested in vitejs/vite#16051 (comment). I had tried it when I had opened this PR too. However, it didn't work back then (which is why I had tried another fix which posed other problems; more info below). But since this vite plugin works now, I went ahead with this.

Old fix

To fix it, I renamed styles.module.css to styles.css. If there is a reason why the file has to be a module.css file, then we'd have to import and use the styles somewhere, or something along these lines.

One problem with using styles.css, however, is that the iui- prefix is not there in the generated styles.css file because the css module part of the vite config file is not applied.

Since I noticed multiple vite versions, I also deduped it to use 5.4.14 (7ab18fb).

Testing

  • CI still passing
  • The build script is working in the itwinui-react workspace
  • The generated styles.css in packages/itwinui-react is unchanged.

Docs

No changeset as vite is used in dev workspaces or listed as devDependencies in the package workspaces (itwinui-react).

@r100-stack r100-stack self-assigned this Oct 23, 2024
@r100-stack r100-stack changed the title Bump vite to ~5.4.10 Bump vite to ~5.4.14 Jan 22, 2025
@r100-stack r100-stack marked this pull request as ready for review January 22, 2025 15:58
@r100-stack r100-stack requested a review from a team as a code owner January 22, 2025 15:58
@r100-stack r100-stack requested review from mayank99 and smmr-dn and removed request for a team January 22, 2025 15:59
Comment on lines 90 to 103
// https://github.com/vitejs/vite/pull/16051#issuecomment-2076616816
function cssModuleSideEffectful() {
return {
name: 'css-module-side-effectful',
enforce: 'post',
transform(_, id) {
if (id.endsWith('.module.css')) {
return {
moduleSideEffects: 'no-treeshake',
};
}
},
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find. My only suggestion would be to inline this plugin in the config above, so that we get better types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sounds good, made it inline (fcd5592).

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.

2 participants