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

Support older browsers without Proxy #3155

Open
Murreey opened this issue Oct 1, 2024 · 6 comments · May be fixed by #3189
Open

Support older browsers without Proxy #3155

Murreey opened this issue Oct 1, 2024 · 6 comments · May be fixed by #3189
Assignees
Labels
has workaround Workaround provided or linked s: awaiting more info Additional information are requested
Milestone

Comments

@Murreey
Copy link

Murreey commented Oct 1, 2024

We're using Faker in browser, and need to support older browsers that do not have Proxy (including all IE versions). As Faker relies on that for the LocaleProxy, it doesn't work in those browsers.

Is there any scope for Faker to be able to support those browsers? I don't have any suggestions for what that would be, but maybe some sort of browser feature detection or disabling the locale functionality.

Google's proxy-polyfill doesn't cover the has or deleteProperty handlers, so doesn't work for Faker's use case. (Unless an option is to stop using those handlers?)

@ST-DDT
Copy link
Member

ST-DDT commented Oct 1, 2024

As for IE support: We wont add support for it in current versions of faker. Please try downgrading faker js/polyfilling and see whether it works.
v6.1.2 is probably the last one without Proxy usage.
IIRC: You can use the latest v7 for Proxy without has/delete.

Please note that old browsers will probably fail on other JS features we use as well.

Our code works on most modern browsers, if not please report any broken methods.
(We had a bug in v9.0.0 where faker.image.dataUri() was broken in browsers.)

The somewhat planned faker v10 might be without the proxy behavior or at least could be triggered without it due to the standalone module functions.

@ST-DDT ST-DDT added the has workaround Workaround provided or linked label Oct 1, 2024
@xDivisionByZerox
Copy link
Member

@Murreey, some questions from my side:

  1. Did you try to use an older version of faker as suggested? If yes, did it work?
  2. What error message do you get when you use google's polyfill with faker?

@xDivisionByZerox xDivisionByZerox added the s: awaiting more info Additional information are requested label Oct 3, 2024
@Murreey
Copy link
Author

Murreey commented Oct 3, 2024

@xDivisionByZerox

  1. Not yet, but we plan to! The API differences mean a bit of a migration for our prod code, but it does seem like it works from some quick tests.
  2. TypeError: Proxy polyfill does not support trap 'has', coming from here.

@ST-DDT
Copy link
Member

ST-DDT commented Oct 3, 2024

2. TypeError: Proxy polyfill does not support trap 'has', coming from here.

Could you please open an issue in that repo, so they know it is a requested feature?
Maybe one for has and another one for deleteProperty.
And please link back here FFR.

@Murreey
Copy link
Author

Murreey commented Oct 3, 2024

It's in maintenance mode unfortunately.

There's an issue #77 which is about a similar problem that might offer a solution though. Not certain, but I can't see anywhere in Faker that actually needs those handlers to work - making the polyfill ignore the error rather than throwing might be enough to at least get it working.

@matthewmayer
Copy link
Contributor

If you need to support old browsers then running everything client-side may not be the best option. If it's a possibility for your application you could say run a tiny node.js server which exposes endpoints for the specific Faker data you need. Then it will work with any browser.

@ST-DDT ST-DDT linked a pull request Oct 16, 2024 that will close this issue
@ST-DDT ST-DDT linked a pull request Oct 18, 2024 that will close this issue
@ST-DDT ST-DDT added this to the v10.0 milestone Oct 18, 2024
@ST-DDT ST-DDT self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround Workaround provided or linked s: awaiting more info Additional information are requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants