vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.44k stars 27.04k forks source link

Es2018 Unicode Property Escapes Not working #19303

Open shirazz opened 4 years ago

shirazz commented 4 years ago

Bug report

Describe the bug

Reproduction: codesandbox.io/s/muddy-cookies-9jr6z?file=/pages/index.js

After upgrading to V 10.0.2 the ES2018 Unicode Property Escapes feature is not working anymore. The same works perfectly till V 10.0.1 Not sure if it is due to the impact of https://github.com/vercel/next.js/pull/18759

Expected behavior

Since the upgrade is not a major one, expecting the feature to work with out any issues.

System information

timneutkens commented 4 years ago

Can you add a complete reproduction?

shirazz commented 4 years ago

@timneutkens Sorry for not including a reproduction demo. Please see it here https://codesandbox.io/s/muddy-cookies-9jr6z?file=/pages/index.js

xxczaki commented 4 years ago

Current workaround:

  1. Install @babel/plugin-transform-unicode-regex:
$ npm install --save-dev @babel/plugin-transform-unicode-regex
  1. Place it in your Babel configuration
const presets = [
    'next/babel'
];

const plugins = [
    '@babel/plugin-transform-unicode-regex'
];

module.exports = {presets, plugins};

Might not be the best thing to do, but at least it fixes the issue :smile:

cc @shirazz @timneutkens

shirazz commented 4 years ago

Awesome!! Let's hope a proper fix lands on a future release. Haven't got time to check in detail

shirazz commented 3 years ago

Was trying this last night and got an error like below. Adding @babel/core fixed the issue as well. @timneutkens is this an ideal way to fix this issue. Does adding @bable/core make any unexpected impacts. Adding codesandbox URL's for your reference as well.

image

Codesandbox URL with error. Codesandbox URL with babel core added.

nghiepdev commented 3 years ago

Same issue with Next@10.0.8 and Typescript. Add @babel/plugin-transform-unicode-regex into .babelrc plugins has been resolved the issue. Waiting for the next.js core fixing.

jrosspaperless commented 3 years ago

Still occurring as of Next@10.2.3. Adding @babel/plugin-transform-unicode-regex resulted in e.charCodeAt is not a function when trying to compile decamelize.

Emyboy commented 2 years ago

Current workaround:

  1. Install @babel/plugin-transform-unicode-regex:
$ npm install --save-dev @babel/plugin-transform-unicode-regex
  1. Place it in your Babel configuration
const presets = [
  'next/babel'
];

const plugins = [
    '@babel/plugin-transform-unicode-regex'
];

module.exports = {presets, plugins};

Might not be the best thing to do, but at least it fixes the issue 😄

cc @shirazz @timneutkens

This worked for me. Thanks

thomasyim-spendsy commented 1 year ago

Current workaround:

  1. Install @babel/plugin-transform-unicode-regex:
$ npm install --save-dev @babel/plugin-transform-unicode-regex
  1. Place it in your Babel configuration
const presets = [
  'next/babel'
];

const plugins = [
    '@babel/plugin-transform-unicode-regex'
];

module.exports = {presets, plugins};

Might not be the best thing to do, but at least it fixes the issue 😄

cc @shirazz @timneutkens

This workaround works 👍 Subscribing this issue, waiting for official fixes.

iamjoshua commented 9 months ago

This is still an issue. Adding a custom babel config breaks builds in 14 as the current documentation doesn't explain how to extend babel config without overriding next's default settings.

franher commented 6 months ago

This bug is happening to us on Next.js 14.2.3. Any news on a fix? Could you help us applying the workaround? Is not clear enough how to apply it.

Thank you for your time.

samuelkraft commented 5 months ago

I just had this issue on Next.js 14.2.3 when using highlight.js and made it work by adding the package to transpilePackages in the next config.

const nextConfig = {
  transpilePackages: ["highlight.js"]
}
chumaumenze commented 5 months ago

I keep getting this regex error.

SyntaxError: Invalid regular expression: /0[oO](([0-7]_*)+)/mu: Invalid escape

Nextjs 14.2.4 highlight.js 11.9.0

BretCameron commented 5 months ago

I keep getting this regex error.

SyntaxError: Invalid regular expression: /0[oO](([0-7]_*)+)/mu: Invalid escape

Nextjs 14.2.4 highlight.js 11.9.0

I have this exact error as well.

kasvith commented 5 months ago

im having same issue with highlight.js

I keep getting this regex error.

SyntaxError: Invalid regular expression: /0[oO](([0-7]_*)+)/mu: Invalid escape

Nextjs 14.2.4 highlight.js 11.9.0

kasvith commented 5 months ago

I just had this issue on Next.js 14.2.3 when using highlight.js and made it work by adding the package to transpilePackages in the next config.

const nextConfig = {
  transpilePackages: ["highlight.js"]
}

this worked

chumaumenze commented 5 months ago

I just had this issue on Next.js 14.2.3 when using highlight.js and made it work by adding the package to transpilePackages in the next config.


const nextConfig = {

  transpilePackages: ["highlight.js"]

}

this worked

I had tried this but it didn't work for static export.

kasvith commented 5 months ago

oh that can be the case, im not using static export