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

fix(ssr): mark builtin modules as side effect free #15658

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 19, 2024

Description

Currently all builtin modules are mark as a side-effect by default. This PR forces them as side-effect-free so they don't get imported if the code that uses it got treeshaken away.

While I think it's hard to guarantee all builtin modules (including deno and bun) in the future will remain side-effect free, I think it's probably a safe assumption for now, and we can manually mark those that are not in the future in a non-breaking way.

Having this optimization will help bundling libraries or code that may accidentally reference node builtins, but are not actually using it. There is the valid argument that the code shouldn't have referenced them in the first place though 🤔

Additional context

similar esbuild issue: evanw/esbuild#705


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added p2-nice-to-have Not breaking anything but nice to have (priority) feat: ssr labels Jan 19, 2024
Copy link

stackblitz bot commented Jan 19, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 74fdbd5: Open

suite result latest scheduled
analogjs success success
astro success success
histoire success success
ladle success success
laravel failure failure
marko success success
nuxt success success
nx failure failure
previewjs success success
qwik failure failure
rakkas success success
remix failure failure
sveltekit success success
unocss success success
vike failure failure
vite-plugin-pwa success success
vite-plugin-react success success
vite-plugin-react-pages success success
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success success
vite-setup-catalogue success success
vitepress success success
vitest success success

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Nice one! Let's merge it and try it out during the beta.

@patak-dev patak-dev merged commit 526cf23 into main Jan 19, 2024
10 checks passed
@patak-dev patak-dev deleted the builtin-side-effect-free branch January 19, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: ssr p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants