Skip to content

Broken as of Vite 8.0.2+ due to change in Rolldown treeshaking #600

@KieranP

Description

@KieranP
  • I have tried upgrading by running bundle update vite_ruby.
  • I have read the [troubleshooting section] before opening an issue.

Description 📖

See rolldown/rolldown#8952 for a bit more context

vite-plugin-ruby appears to assume that all side effects are hoisted to the top 2 levels of the tree-shaking chain (either the entrypoint or direct import dependencies). See https://github.com/ElMassimo/vite_ruby/blob/main/vite_ruby/lib/vite_ruby/manifest.rb#L27-L37

The issue is that Rolldown now tree shakes/removes side effect imports at the top, not deeper down. So when using vite_typescript_tag, it only inserts CSS files from the entrypoint and direct imports. Anything lower down appears to now be missing and causing issues.

e.g. given this manifest:

{
  "components/1.ts": {
    "file": "components/1.js",
    "css": ["components/1.css"]
  },
  "views/1.ts": {
    "file": "views/1.js",
    "imports": ["components/1.ts"],
    "css": ["views/1.css"]
  },
  "entrypoints/1.ts": {
    "file": "entrypoints/1.js",
    "imports": ["views/1.ts"],
    "css": ["entrypoints/1.css"]
  }
}

The CSS from "components/1.ts" does get included because when vite_ruby resolves the manifest, it's only looking at entries and first level imports of entries for CSS,

The resolve_entries evidently needs to keep recursing all imports of imports through the whole chain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: pending triageSomething doesn't seem to be working, but hasn't been verified

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions