Skip to content

rolldown-vite doesn't cache Vite plugin output when using native plugin #230

Open
@JellyBrick

Description

@JellyBrick

Describe the bug

I'm using a plugin that writes virtual stubs to a file in the project. (see https://github.com/th-ch/youtube-music/blob/feat/rolldown-native-plugin/vite-plugins/plugin-loader.mts)

These virtual stubs are then used as virtual modules via vite-plugin-resolver.
(see https://github.com/th-ch/youtube-music/blob/feat/rolldown-native-plugin/vite-plugins/plugin-importer.mts, https://github.com/th-ch/youtube-music/blob/f6b4abd5ea0263305d87265634223d6ae9b40a6d/electron.vite.config.mts#L31)

While this setup works correctly with vite (or rolldown-vite without native plugin), it appears that the output of the virtual stub generation isn't being passed to subsequent plugins when using native plugin.

(I apologize that this is not a minimal reproduction due to the complexity of the code. I will do my best to isolate the code and provide a minimal reproduction soon)

Reproduction

https://github.com/th-ch/youtube-music/tree/feat/rolldown-native-plugin

Steps to reproduce

  1. pnpm install
  2. pnpm electron-vite build

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
    Memory: 11.37 GB / 15.53 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.18.3 - /usr/bin/node
    npm: 11.2.0 - /usr/bin/npm
    pnpm: 10.11.1 - /usr/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.98
  npmPackages:
    rolldown-vite:  6.3.18 
    rollup: 4.41.1 => 4.41.1

Used Package Manager

pnpm

Logs

experimental.enableNativePlugin=false

Click to expand!
rolldown-vite v6.3.18 building SSR bundle for production...
✓ 2716 modules transformed.

dist/main/from-jaOESCxJ.js                 69.35 kB
dist/main/index.js                      8,199.82 kB
[EVAL] Warning: Use of `eval` function is strongly discouraged as it poses security risks and may cause issues with minification.
      ╭─[ node_modules/.pnpm/[email protected]/node_modules/file-type/core.js:1419:17 ]
      │
 1419 │     const stream = eval('require')('stream'); // eslint-disable-line no-eval
      │                    ──┬─  
      │                      ╰─── Use of `eval` function here.
──────╯

✓ built in 13.55s
rolldown-vite v6.3.18 building SSR bundle for production...
✓ 289 modules transformed.
dist/preload/preload.js  1,265.80 kB
✓ built in 9.47s
rolldown-vite v6.3.18 building for production...
✓ 319 modules transformed.
../dist/renderer/index.html                  0.48 kB
../dist/renderer/youtube-music.iife.js  13,194.91 kB
✓ built in 11.91s

experimental.enableNativePlugin=true

Click to expand!
rolldown-vite v6.3.18 building SSR bundle for production...
✓ 2919 modules transformed.
✗ Build failed in 4.41s
error during build:
Build failed with 42 errors:

[MISSING_EXPORT] Error: "pluginStub" is not exported by "src/plugins/audio-compressor.ts".
   ╭─[ \0plugin-resolve:virtual:plugins:1:33 ]
   │
 1 │ import audioCompressorPlugin, { pluginStub as audioCompressorPluginStub } from "./src/plugins/audio-compressor.ts";
   │                                 ─────┬────  
   │                                      ╰────── Missing export
───╯

[MISSING_EXPORT] Error: "pluginStub" is not exported by "src/plugins/visualizer/index.ts".
   ╭─[ \0plugin-resolve:virtual:plugins:2:28 ]
   │
 2 │ import visualizerPlugin, { pluginStub as visualizerPluginStub } from "./src/plugins/visualizer/index.ts";
   │                            ─────┬────  
   │                                 ╰────── Missing export
───╯

[MISSING_EXPORT] Error: "pluginStub" is not exported by "src/plugins/video-toggle/index.ts".
   ╭─[ \0plugin-resolve:virtual:plugins:3:29 ]
   │
 3 │ import videoTogglePlugin, { pluginStub as videoTogglePluginStub } from "./src/plugins/video-toggle/index.ts";
   │                             ─────┬────  
   │                                  ╰────── Missing export
───╯

[MISSING_EXPORT] Error: "pluginStub" is not exported by "src/plugins/unobtrusive-player/index.ts".
   ╭─[ \0plugin-resolve:virtual:plugins:4:35 ]
   │
 4 │ import unobtrusivePlayerPlugin, { pluginStub as unobtrusivePlayerPluginStub } from "./src/plugins/unobtrusive-player/index.ts";
   │                                   ─────┬────  
   │                                        ╰────── Missing export
───╯

[MISSING_EXPORT] Error: "pluginStub" is not exported by "src/plugins/tuna-obs/index.ts".
   ╭─[ \0plugin-resolve:virtual:plugins:5:25 ]
   │
 5 │ import tunaObsPlugin, { pluginStub as tunaObsPluginStub } from "./src/plugins/tuna-obs/index.ts";
   │                         ─────┬────  
   │                              ╰────── Missing export
───╯

...
    at normalizeErrors (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-Dwb_rX9h.mjs:2362:18)
    at handleOutputErrors (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-Dwb_rX9h.mjs:3368:34)
    at transformToRollupOutput (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-Dwb_rX9h.mjs:3362:2)
    at RolldownBuild.write (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-Dwb_rX9h.mjs:4639:11)
    at async buildEnvironment (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/rolldown-vite/dist/node/chunks/dep-BVD1pq3j.js:44451:16)
    at async build (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected][email protected]_/node_modules/electron-vite/dist/chunks/lib-B57e7lYt.mjs:26:13)
    at async CAC.<anonymous> (file:///home/jellybrick/youtube-music/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected][email protected]_/node_modules/electron-vite/dist/cli.mjs:83:9)

Validations

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions