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

Build process does not run my custom Vite plugin #13078

Open
sneridagh opened this issue Feb 21, 2025 · 4 comments
Open

Build process does not run my custom Vite plugin #13078

sneridagh opened this issue Feb 21, 2025 · 4 comments
Labels

Comments

@sneridagh
Copy link

sneridagh commented Feb 21, 2025

I'm using React Router as a...

framework

Reproduction

I have a custom Vite Plugin that generates a file with additional routes for my RR7 app. For more information, this Vite plugin is a pre plugin.

It worked well until we updated to 7.2.0 where it broke when building. In dev it works well. In order to prove that the plugin is just ignored I even broke the Vite plugin code, and it did not errored (while in dev did).

I'm sorry right now I can't post a reproduction repo, also it would be hard to explain in detail what the Vite plugin does and how to test that it does not work. If really needed I can try, but I'm hoping that this rings some bells.

When 7.1.5 is used, it works perfectly, as it used to.

System Info

System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 409.00 MB / 64.00 GB
    Shell: 5.1.12 - /opt/homebrew/bin/bash
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.4.1 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
    Watchman: 2024.06.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 133.0.6943.127
    Safari: 18.3

Used Package Manager

pnpm

Expected Behavior

My custom Vite plugin is executed in build mode. In 7.1.5 is used, it works perfectly, as it used to.

Actual Behavior

My custom Vite plugin seems that does not run in build mode, but it does in dev mode.

@sneridagh sneridagh added the bug label Feb 21, 2025
@LucasOe
Copy link

LucasOe commented Feb 21, 2025

I just tried replicating this issue using rollup-plugin-dedent, which I published yesterday.

I'm using the plugin in Vite, and it also uses enforce: "pre" to transform code, and I can't seem to replicate the issue, using React Router version 7.2.0. The package works for in dev and build mode for me.

@sneridagh
Copy link
Author

sneridagh commented Feb 21, 2025

ok, then maybe it's a strange interaction with the pnpm monorepo setup we are using.

I cleaned up some things so, in this branch:

https://github.com/plone/volto/tree/7

It's using RR 7.1.5, the command pnpm build (which does pnpm --filter seven build) works as expected (see CI actions are green).

This branch:

plone/volto#6774

is created from the previous but using RR 7.2.0 and it's failing (see CI red actions):

https://github.com/plone/volto/actions/runs/13461807540/job/37618720542?pr=6774

for the same command.

As said, I tried to debug it, and the code does not reach the plugin in build mode whereas in dev it does.

@markdalgleish
Copy link
Member

@sneridagh Are you able to create a minimal repro? Looking at your CI output and reproducing locally, it looks like your routes.ts file is trying to import a file that doesn't exist (import applyAddonConfiguration, { addonsInfo } from '../registry.loader';). If you can figure out the core issue and isolate it into its own repro I'll be able to look into this further.

@sneridagh
Copy link
Author

@markdalgleish hey, thanks for taking a look.
Let me explain a bit, this plugin creates the file ../registry.loader in the code base, so it can be read on boot. It contains the definition of routes that are being read in other modules that act as add-ons. After that, these routes are added to the main app routes.ts.

I can put together an even minimum version, in a separated repo, but the error given will be the same, since the file that is expected to be generated, it won't be generated. Then RR7 will complain about the routes.ts import of that file is not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants