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

Next.js 14.2.x bundler mangles \\b in template literals #70500

Open
silas opened this issue Sep 26, 2024 · 1 comment
Open

Next.js 14.2.x bundler mangles \\b in template literals #70500

silas opened this issue Sep 26, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.

Comments

@silas
Copy link

silas commented Sep 26, 2024

Link to the code that reproduces this issue

https://github.com/silas/nextjs-issue-70500.git

To Reproduce

  1. npm install
  2. npm run build

Current vs. Expected behavior

npm run build should complete successfully.

This is the difference between a working and non-working build:

$ git diff 592f5ba...0a0e772
diff --git a/src/app/demo.ts b/src/app/demo.ts
index cc8e1f1..f8c8f45 100644
--- a/src/app/demo.ts
+++ b/src/app/demo.ts
@@ -1,3 +1,3 @@
-const demo = '{"match":"\\b"}';
+const demo = `{"match":"\\b"}`;

 export { demo };

The working version produces:

{"match":"\\b"}

And the non-working version produces:

{"match":"\\\b"}

You can try the working build by running:

  1. git checkout 592f5ba
  2. npm run build

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.9.0
  npm: 10.8.3
  Yarn: 1.22.22
  pnpm: 9.11.0
Relevant Packages:
  next: 14.2.13 // Latest available version is detected (14.2.13).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Webpack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

This issue was uncovered in shikijs/shiki#784

It's possible this is related to webpack, but the upstream default settings for webpack@4 and webpack@5 don't cause this issue.

Versions

It looks like this stopped working in 14.2.0-canary.66...14.2.0-canary.67:

14.1.4            working
14.2.0-canary.66  working
14.2.0-canary.67  non-working
14.2.0            non-working
14.2.13           non-working
@silas silas added the bug Issue was opened via the bug report template. label Sep 26, 2024
@github-actions github-actions bot added the Webpack Related to Webpack with Next.js. label Sep 26, 2024
@fuma-nama
Copy link
Contributor

Some news, I've tested on Next.js 15 canary, it works as expected. It seems like they fixed it on canary but is not ported to 14.

@silas silas changed the title Next.js bundler mangles \\b in template literals Next.js 14.2.x bundler mangles \\b in template literals Sep 29, 2024
@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants