ElMassimo / ElMassimo/vite_ruby

plugin_legacy is not working as expected

Open
#424 0 comments 0 reactions 0 assignees View on GitHub
bug: pending triage
Dominant language
Ruby
Stars
1.6k
Forks
149
Avg merge
5h 13m
Merged PRs (30d)
2

Description

[troubleshooting section]: https://vite-ruby.netlify.app/guide/troubleshooting.html

- [x] I have tried upgrading by running `bundle update vite_ruby`.
- [x] I have read the __[troubleshooting section]__ before opening an issue.

### Description 📖

I am using ViteRails with ViteLegacy and it seems the plugin legacy is not working as expected.
I am trying to use this config to provide replaceAll polyfill:

```
ViteLegacy({
targets: ['Chrome 63'],
modernPolyfills: ['es.string.replace', 'es.string.replace-all', 'esnext.string.replace-all'],
polyfills: ['es.string.replace', 'es.string.replace-all', 'esnext.string.replace-all']
}),
```

It seems that viteLegacy also adds some id's to provide correct polyfills support.

```

System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))
```

Is this [PR](https://github.com/ElMassimo/vite_ruby/pull/296) maybe related?
It's quite old PR but not sure why it was not never merged. (uses the 4.0 plugin-legacy version. Now there is version 5.0. Maybe it's needed to update for the latest version to support correct legacy same as the plugin legacy does?

### Reproduction 🐞
Created an example repo
https://github.com/alexookah/rails_example
Added a simple test console.log with `replaceAll`
https://github.com/alexookah/rails_example/blob/master/app/frontend/entrypoints/example_import.js

### Screenshots 📷
![Screenshot 2023-12-09 at 18 52 11](https://github.com/ElMassimo/vite_ruby/assets/9624843/46aa0219-0ccb-4b8a-831a-465f0c8a8986)

![Screenshot 2023-12-09 at 18 52 00](https://github.com/ElMassimo/vite_ruby/assets/9624843/8295e808-3faa-4000-b73b-5ed6a30db856)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.