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 old browsers without polyfills #982

Merged

Conversation

graingert
Copy link
Contributor

@graingert graingert commented Jul 19, 2018

Reasons for making this change

Currently react-jsonschema-form forces downstream projects to use babel-polyfill, and includes duplicated babel helpers.

This removes those duplicate helpers and adds ponyfills for modern globals like Set, Promise and Objects.assign.

This PR also replaces methods like Array.prototype.includes and Array.prototype.fill with ponyfills from core-js

If this is related to existing tickets, include links to them as well:

#798

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@graingert graingert force-pushed the support-old-browsers-without-polyfills branch 3 times, most recently from e52434a to 1f5cd3c Compare July 19, 2018 10:14
Copy link
Contributor

@magopian magopian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, one question regarding a change.

@@ -3,18 +3,16 @@ import PropTypes from "prop-types";

import { asNumber } from "../../utils";

const nums = new Set(["number", "integer"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this Set be taken from core-js? Or maybe the same change as above, using the polyfilled includes from core-js.

@graingert
Copy link
Contributor Author

transform-runtime automatically ponyfills globals like Set Promise setImmediate and Object.assign

@magopian
Copy link
Contributor

Thanks!

@magopian
Copy link
Contributor

@graingert i've resolved the merge conflict, please let me know if this looks correct, before I merge it. Thanks!

@magopian
Copy link
Contributor

oh, wait, no, I borked it. Let me try again...

@graingert
Copy link
Contributor Author

@magopian let me take over

@graingert graingert force-pushed the support-old-browsers-without-polyfills branch from 0d10d98 to a33a930 Compare July 23, 2018 14:31
@@ -42,10 +42,10 @@
},
"dependencies": {
"ajv": "^5.2.3",
"babel-preset-env": "^1.7.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, I put this in the wrong place in my last pr, should have been a devDep

@graingert
Copy link
Contributor Author

@magopian done

Copy link
Contributor

@magopian magopian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, excellent, thanks

@magopian magopian merged commit ca8b612 into rjsf-team:master Jul 23, 2018
@graingert graingert deleted the support-old-browsers-without-polyfills branch July 23, 2018 14:35
@dalgard
Copy link

dalgard commented Aug 8, 2018

If I understand this change correctly, it should result in a minor version bump, since direct support for old browsers is a new (non-breaking) feature of the package 🙏

@graingert
Copy link
Contributor Author

@dalgard sure, but erm... it's a bit too late now

@glasserc
Copy link
Contributor

Semver says it's a minor bump only if new functionality is added to the API. The API hasn't changed, so it's a patch version.

@glasserc
Copy link
Contributor

glasserc commented Sep 28, 2018

@graingert , could you please look at #991 and #1022 and tell me what you think? I am worried that we may have broken the way some of our users are including rjsf, but I'm not an expert in JS packaging so I'm hoping you can help.

@graingert
Copy link
Contributor Author

Ok I'll have a look tomorrow

@graingert
Copy link
Contributor Author

@glasserc I took a look - looks like it's a simple fix to the webpack babel-loader config to exclude babel loader on babel and core-js in webpack.

This is why it works when people use the package from npm directly

@glasserc
Copy link
Contributor

glasserc commented Oct 1, 2018

To elaborate on the above comment, I spoke with @graingert via IRC and he explained that he thought the problem was that we're running babel on all our dependencies, including the ones that provide ponyfills such as corejs and babel-runtime, and that this is due to a webpack misconfiguration. I'll try to fix it and open a PR today.

@graingert
Copy link
Contributor Author

graingert commented Oct 1, 2018

@glasserc currently I think you only need to exclude node_modules\/core-js\/.* from babel-loader

It may be prudent to exclude all of node_modules and switch to a whitelist, however

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

Successfully merging this pull request may close these issues.

4 participants