ElMassimo / ElMassimo/vite-plugin-erb
Issue after updating from vite 7.0.6 to 7.1.x (7.1.3 latest)
- Dominant language
- TypeScript
- Stars
- 11
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Use case still same as https://github.com/ElMassimo/vite-plugin-erb/issues/5
```erb
<%# encoding: UTF-8 %>
// Tell webpack to watch these files
// https://github.com/usabilityhub/rails-erb-loader#dependencies
/* rails-erb-loader-dependencies ./../config/locales/ */
import I18n from "i18n-js"
I18n.translations = <%= I18n::JS.filtered_translations.to_json %>;
export default I18n
```
Partial error message:
```
$ bundle exec rake assets:precompile RAILS_ENV=production
yarn install v1.22.22
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
success Already up-to-date.
✨ Done in 0.09s.
Building with Vite ⚡️
yarn run v1.22.22
$ /Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/.bin/vite build --mode production
vite v7.1.3 building for production...
transforming...
✓ 1 modules transformed.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
✗ Build failed in 943ms
error during build:
[erb-plugin] [plugin erb-plugin] app/assets/javascripts/plugins/i18n-js/index.ts.erb: Failed to parse JSON file.
file: /Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/app/assets/javascripts/plugins/i18n-js/index.ts.erb
at getRollupError (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
at error (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
at Object.error (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/node-entry.js:22024:20)
at Object.error (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/node-entry.js:21086:42)
at Object.handler (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/vite/dist/node/chunks/dep-Bj7gA1-0.js:8889:11)
at Object.transform (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/vite-plugin-erb/dist/index.js:68:44)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async transform (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/node-entry.js:21063:16)
at async ModuleLoader.addModuleSource (file:///Users/pikachuexe/projects/ruby/sample_apps/vite-plugin-erb-issue-5-mvp/node_modules/rollup/dist/es/shared/node-entry.js:21276:36)
error Command failed with exit code 1.
pid 60218 exit 1
Build with Vite failed! ❌
```
It seems that the plugin is run by PostCSS/JSON plugin for some reason...
No idea if vite/rollup/rolldown? got issue or what
Example repo - [https://github.com/PikachuEXE/vite-plugin-erb-issue-5-mvp](https://github.com/PikachuEXE/vite-plugin-erb-issue-5-mvp?rgh-link-date=2025-04-22T01%3A27%3A02.000Z)
Forgot to push new commits last week
Update 1: issue occurs after https://github.com/vitejs/vite/pull/20358
Contributor guide
Research direction
Reproduce the failure with the linked example repository using the app/assets/javascripts/plugins/i18n-js/index.ts.erb fixture and the reported Vite 7.1.3 build command. Read the vite-plugin-erb transform path shown in the stack trace and compare the behavior before and after Vite pull request 20358. Done means the ERB asset builds without the reported “Failed to parse JSON file” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby, typescript, vite
- Domain
- build-system, frontend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100