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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional test case for regexp #11003

Closed
Timer opened this issue Mar 12, 2020 · 1 comment 路 Fixed by #11006
Closed

Additional test case for regexp #11003

Timer opened this issue Mar 12, 2020 · 1 comment 路 Fixed by #11006
Milestone

Comments

@Timer
Copy link
Member

Timer commented Mar 12, 2020

@Timer @timneutkens I see PR was merged (and closes this issue). Not to open another thread but test/integration/production/public/regexp-test.js seems to have ... the hubspot script 馃 . The Hubspot script had only issues with Promise but I didn't see any issue with RegExp that needs polyfiling.

A quickly wrote a case where it failed before PR (I mentioned es.regexp.sticky):

import * as React from "react";

const str1 = "table football";
const regex1 = new RegExp("foo", "y") // sticky
regex1.lastIndex = 6

const Home = () => {
  const isSticky = regex1.sticky // Expected: true
  const isMatch1 = regex1.test(str1) // Expected: true
  const isMatch2 = regex1.test(str1) // Expected: false

  return (
    <div>
      Works!!!
      <div>isSticky: {isSticky.toString()}</div>
      <div>isMatch1: {isMatch1.toString()}</div>
      <div>isMatch2: {isMatch2.toString()}</div>
    </div>
  )
}

export default Home

In IE11:

Syntax in regular expression

@developit

Then automate contextual polyfilling similar to preset-env, but with the knowledge of what APIs can already be assumed available based on the nomodule polyfill / modern browser baseline.

It's what I was suggesting. preset-env actually does use core-js-compat and a custom filter method to include/exclude polyfills based on browsersList query (in targets prop). It's more or less just:

const { targets } = require('core-js-compat')({
  targets: 'IE 11',  // <<< browser baseline. Browserslist query
  filter: /^(es|web)\./, // <<< filter only es and web polyfills
})
Object
  .keys(targets)
  .filter(moduleName => ...) // exclude deprecated, not needed such as es.string.fontcolor

Then you end up with a more or less nomodule-polyfill (excluding whatwg-fetch)

We want to minimize the number of core-js polyfills included to support mainly IE11, Edge, and Safari. It'd be great if we could just do:

// next.config.js
module.exports = {
  browsers: '> 0.25%, not dead'
}

And have core-js-compat generate it for us.

Originally posted by @eddyw in #10966 (comment)

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants