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

Build fails when object keys contain Japanese middle dots(・) in v14.2 #67057

Open
RNm-dove opened this issue Jun 20, 2024 · 1 comment
Open
Labels
bug Issue was opened via the bug report template.

Comments

@RNm-dove
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/polished-cookies-rnn3js?embed=1&file=%2Fapp%2Fpage.tsx%3A10%2C1&workspaceId=e3e624d7-9211-4d3c-b433-5fbdb4e7ad1b

To Reproduce

  1. Fork codesandbox.
  2. Build Application by typing yarn build in codesandbox.

Current vs. Expected behavior

Current Behavior:
When building a Next.js project, if an object key contains a Japanese middle dot (・), the build process fails with a syntax error.

Expected Behavior:
The build process should complete successfully without any errors, even if object keys contain Japanese middle dots.

NOTE:
It’s not a big problem for us. We can avoid using Japanese middle dots in object keys to bypass the error. I hope this information will be helpful to others who are in the same situation.

Description:
When running the following code:

const JapaneseMiddleDotKeyJson = {
  "a・b": "hoge",
};

export default function Home() {
  return <span>{JapaneseMiddleDotKeyJson["a・b"]}</span>;
}

and executing the build command:

yarn build

The terminal output shows an error indicating a syntax error and failure to collect page data:

➜  workspace git:(master) ✗ yarn build
yarn run v1.22.19
$ next build
  ▲ Next.js 14.2.4

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
   Collecting page data  ../project/workspace/.next/server/app/page.js:1
(()=>{var e={};e.id=931,e.ids=[931],e.modules={7849:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external")},2934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},5403:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external")},4580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},4749:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external")},5869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},1017:e=>{"use strict";e.exports=require("path")},7310:e=>{"use strict";e.exports=require("url")},6088:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>a.a,__next_app__:()=>p,originalPathname:()=>f,pages:()=>l,routeModule:()=>d,tree:()=>c}),r(908),r(1506),r(5866);var n=r(3191),i=r(8716),o=r(7922),a=r.n(o),s=r(5231),u={};for(let e in s)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(u[e]=()=>s[e]);r.d(t,u);let c=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,908)),"/project/workspace/app/page.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,7481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(r.bind(r,1506)),"/project/workspace/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,5866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,7481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],l=["/project/workspace/app/page.tsx"],f="/page",p={require:r,loadChunk:()=>Promise.resolve()},d=new n.AppPageRouteModule({definition:{kind:i.x.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},9784:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,2994,23)),Promise.resolve().then(r.t.bind(r,6114,23)),Promise.resolve().then(r.t.bind(r,9727,23)),Promise.resolve().then(r.t.bind(r,9671,23)),Promise.resolve().then(r.t.bind(r,1868,23)),Promise.resolve().then(r.t.bind(r,4759,23))},5303:()=>{},1506:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var n=r(9510);function i({children:e}){return(0,n.jsxs)("html",{children:[n.jsx("head",{}),n.jsx("body",{children:e})]})}},908:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>o});var n=r(9510);let i={a・b:"hoge"};function o(){return n.jsx("span",{children:i["a・b"]})}},338:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{ACTION:function(){return n},FLIGHT_PARAMETERS:function(){return u},NEXT_DID_POSTPONE_HEADER:function(){return l},NEXT_ROUTER_PREFETCH_HEADER:function(){return o},NEXT_ROUTER_STATE_TREE:function(){return i},NEXT_RSC_UNION_QUERY:function(){return c},NEXT_URL:function(){return a},RSC_CONTENT_TYPE_HEADER:function(){return s},RSC_HEADER:function(){return r}});let r="RSC",n="Next-Action",i="Next-Router-State-Tree",o="Next-Router-Prefetch",a="Next-Url",s="text/x-component",u=[[r],[i],[o]],c="_rsc",l="x-nextjs-postponed";("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7255:e=>{(()=>{"use strict";"undefined"!=typeof __nccwpck_require__&&(__nccwpck_require__.ab=__dirname+"/");var t={};(()=>{/*!
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

SyntaxError: Invalid or unexpected token
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1205:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at mod.require (/project/workspace/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:130:18)
    at requirePage (/project/workspace/node_modules/next/dist/server/require.js:109:84)

> Build error occurred
Error: Failed to collect page data for /
    at /project/workspace/node_modules/next/dist/build/utils.js:1268:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64
  Available memory (MB): 32768
  Available CPU cores: 8
Binaries:
  Node: 18.19.0
  npm: 10.5.1
  Yarn: 1.22.19
  pnpm: 7.33.1
Relevant Packages:
  next: 14.2.4 // Latest available version is detected (14.2.4).
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.0.4
Next.js Config:
  output: standalone

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

Not sure

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

next build (local)

Additional context

The issue is specific to Next.js version 14.2.x. I tested the same code with versions 14.1.4 and 15.0.0-canary.38, and the error did not occur in those versions. This suggests that the issue is introduced in the 14.2.x release.

@RNm-dove RNm-dove added the bug Issue was opened via the bug report template. label Jun 20, 2024
@RNm-dove
Copy link
Author

RNm-dove commented Jun 25, 2024

Additional info.
If you import a library with objects that have Japanese middle dots (・) in their key names, the Microsoft Edge browser will throw a LoadChunkError.

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.
Projects
None yet
Development

No branches or pull requests

1 participant