Skip to content

Commit

Permalink
Fix missing JSON.stringify in loader (vercel#41599)
Browse files Browse the repository at this point in the history
We can't directly put `filePath` in the generated code as it can contain in valid JavaScript string such as `"\2"` in `"C:\Users\foo\2022\bar.js"`. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal

Reported issue in Next.js:

![image](https://user-images.githubusercontent.com/3676859/196962933-0a3bf4b4-9142-426f-9ac5-bdcfb3c5ebf0.png)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
shuding authored and Kikobeats committed Oct 24, 2022
1 parent e31c54c commit 826f84e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/build/webpack/loaders/next-app-loader.ts
Expand Up @@ -94,7 +94,7 @@ async function createTreeCodeFromPath({
}
return `${
file === FILE_TYPES.layout
? `layoutOrPagePath: '${filePath}',`
? `layoutOrPagePath: ${JSON.stringify(filePath)},`
: ''
}'${file}': () => require(${JSON.stringify(filePath)}),`
})
Expand Down

0 comments on commit 826f84e

Please sign in to comment.