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

Where does flag configuration code go in a Rails project? (can't get Intl to work when pre-rendering a react component) #150

Closed
gregblass opened this issue Sep 17, 2019 · 5 comments

Comments

@gregblass
Copy link

Is there a specific place I should be placing this in a Rails project?

MiniRacer::Platform.set_flags! :harmony

I have it in config/initializers/mini_racer.rb

However, I'm still getting this error when trying to use Intl when prerendering a component:

React::ServerRendering::PrerenderError (Encountered error "#<ExecJS::ProgramError: ReferenceError: Intl is not defined>" when prerendering

Or, could it be possible that Intl just still not supported, even with :harmony enabled?

@nightpool
Copy link
Contributor

It looks like Intl support has to be enabled independently: https://v8.dev/docs/i18n#embedding-v8

@nightpool
Copy link
Contributor

Ah, but see here wrt i18n support: rubyjs/libv8#278

@ksweetie
Copy link

I've got the same error trying to do the same thing. Did you ever figure this out?

@nightpool
Copy link
Contributor

This is fixed by #166

c = MiniRacer::Context.new

c.eval("['1','b','c','a','\u00E4'].sort(new Intl.Collator('en').compare);")
# => ["1", "a", "\u00E4", "b", "c"]

c.eval("['1','b','c','a','\u00E4'].sort(new Intl.Collator('sv').compare);")
# => ["1", "a", "b", "c", "\u00E4"]

@tisba
Copy link
Collaborator

tisba commented Jan 19, 2022

Has your initial problem been solved, @ksweetie?

@tisba tisba closed this as completed Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants