Skip to content

Rolldown-Vite #84

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

Draft
wants to merge 197 commits into
base: main
Choose a base branch
from
Draft

Rolldown-Vite #84

wants to merge 197 commits into from

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Mar 7, 2025

Description

Current Status

  • Vite repo test status
    • ✅ unit tests
    • e2e tests
      • ✅ assets: skipping watch related tests
      • ✅ external: changed the test for intended behavior change
      • ❌ legacy: system output is not supported yet
      • ⚠️ object-hooks: sequential: false object hooks are not supported
      • ✅ resolve: skipped some browser field related tests as those cases were only supported by esbuild and Vite, also skipped some test that does fallback based on the file content which is Vite only and I believe it should not be done
  • ecosystem-ci (see https://github.com/vitejs/vite-ecosystem-ci/blob/rolldown-vite/README-temp.md)

Intended behavior differences

Known missing features

related to native plugins
TODO list for me
  • set rolldown's minify target
  • update docs

Copy link

pkg-pr-new bot commented Mar 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vitejs/rolldown-vite@84

commit: 18e54bf

@sapphi-red sapphi-red force-pushed the rolldown-vite branch 2 times, most recently from 9ce2683 to a974a4a Compare March 17, 2025 03:57
@sapphi-red sapphi-red changed the title WIP Rolldown-Vite Mar 17, 2025
@sapphi-red sapphi-red mentioned this pull request Mar 17, 2025
3 tasks
`function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
: // If the base isn't relative, then the deps are relative to the projects `outDir` and the base
// is appended inside __vitePreload too.
`function(dep) { return ${JSON.stringify(environment.config.base)}+dep }`

Check warning

Code scanning / CodeQL

Improper code sanitization

Code construction depends on an [improperly sanitized value](1).
@christianjuth
Copy link

christianjuth commented Mar 25, 2025

Found this PR in the Vite docs. Curious how stable rolldown-vite is. On a scale of "Next.js would call this is stable" to "this will actually work 99% of the time", were are we at?

@sapphi-red sapphi-red force-pushed the rolldown-vite branch 2 times, most recently from 51fd297 to 3fc2ac5 Compare March 26, 2025 02:29
@sapphi-red
Copy link
Member Author

Found this PR in the Vite docs. Curious how stable rolldown-vite is. On a scale of "Next.js would call this is stable" to "this will actually work 99% of the time", were are we at?

I'd say it would work for basic cases as it is passing most tests through out the ecosystem.

sapphi-red and others added 17 commits March 26, 2025 14:58
Co-authored-by: underfin <likui.underfin@gmail.com>
Co-authored-by: underfin <likui.underfin@gmail.com>
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
Co-authored-by: Yury <YurySolovyov@users.noreply.github.com>
Co-authored-by: underfin <2218301630@qq.com>
Co-authored-by: IWANABETHATGUY <iwanabethatguy@qq.com>
Co-authored-by: IWANABETHATGUY <iwanabethatguy@qq.com>
Co-authored-by: IWANABETHATGUY <iwanabethatguy@qq.com>
Co-Authored-By: Evan You <evan@vuejs.org>
@corneliusio
Copy link

@sapphi-red Not sure if this is helpful or unrelated, but in regard to this part:

manifest

    cannot use data on Vite side (e.g. css/assets)
        I cannot make a simple reproduction for this one. If you only enable the native manifest plugin and run build in playground/backend-integration, you can see the manifest not containing css and assets field in index.html

Due to the nature of projects I work on almost exclusively being MPA's, we use Vite only for processing front-end assets and then have back-end code in PHP for reading the manifest and loading compiled assets where needed. For some non-JS assets this means they're never explicitly included in any JS or CSS file as they are only meant to be consumed by the back-end. We ensure these assets get processed with something along the lines of this:

import.meta.glob('../img/**/*')

However, what I found when testing out the new rolldown-vite setup is that these assets were no longer appearing in the manifest. After a little tinkering I found that creating a side-effect from the call to import.meta making it not tree-shakable fixed this. Basically just:

window.__ASSETS__ = import.meta.glob('../img/**/*')

So it seems like maybe there are cases where these assets are simply being dropped due to tree-shaking. But, this is only a guess and possibly not related to your above issue. But I thought I'd share just in case.

@sapphi-red
Copy link
Member Author

@corneliusio That isn't related to what I wrote, because that's not related to native plugins. import.meta.glob call does not have a sideeffect, so it's removed. If you use that outside the JS part, it should be marked as an entry (build.rollupOptions.input). Otherwise, Vite can do any optimization.

@sapphi-red
Copy link
Member Author

I'll lock this PR as comments on this PR will be difficult to track. Feel free to create an issue or discussion if you need to comment.

@vitejs vitejs locked and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants