next.js: Es2018 Unicode Property Escapes Not working

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

  • OS: macOS,
  • Browser NA
  • Version of Next.js: [e.g. 10.0.2]
  • Version of Node.js: [e.g. 12.18.2]

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 13
  • Comments: 18 (2 by maintainers)

Most upvoted comments

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

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"]
}

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.

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

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.

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.

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