Skip to content

Commit

Permalink
fix(#1): through patching next
Browse files Browse the repository at this point in the history
  • Loading branch information
flolu committed Mar 31, 2021
1 parent 5f2b10e commit 205b928
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 10 deletions.
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ next(
args = [
"build",
"$(RULEDIR)",
"--node_options=--preserve-symlinks-main",
"--bazel_run_from_execroot",
],
data = [
"copy_source_files",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start",
"start:bazel": "bazelisk run client",
"start:bazel:debug": "bazelisk run client --sandbox_debug",
"start:image": "bazelisk run client_image"
"start:image": "bazelisk run client_image",
"postinstall": "patch-package"
},
"dependencies": {
"next": "10.0.9",
Expand All @@ -20,6 +21,8 @@
"@bazel/bazelisk": "^1.7.5",
"@types/node": "^14.14.37",
"@types/react": "^17.0.3",
"patch-package": "^6.4.7",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
}
}
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// FIXME https://github.com/flolu/nextjs-bazel/issues/1
// import '../styles/globals.css'
import '../styles/globals.css'

import {AppProps} from 'next/app'

Expand Down
7 changes: 1 addition & 6 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import Document, {Head, Html, Main, NextScript} from 'next/document'

export default class MyDocument extends Document {
render() {
const bodyStyles ={
margin: 0,
fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif'
}

return (
<Html lang="en">
<Head>
Expand All @@ -22,7 +17,7 @@ export default class MyDocument extends Document {

<link rel="manifest" href="/manifest.json" />
</Head>
<body className="theme light" style={bodyStyles}>
<body className="theme light">
<Main />
<NextScript />
</body>
Expand Down
9 changes: 9 additions & 0 deletions patches/next+10.0.9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/node_modules/next/dist/server/lib/find-page-file.js b/node_modules/next/dist/server/lib/find-page-file.js
index c293a00..59e04f8 100644
--- a/node_modules/next/dist/server/lib/find-page-file.js
+++ b/node_modules/next/dist/server/lib/find-page-file.js
@@ -1,2 +1,2 @@
-"use strict";exports.__esModule=true;exports.findPageFile=findPageFile;var _path=require("path");var _chalk=_interopRequireDefault(require("chalk"));var _isWriteable=require("../../build/is-writeable");var _log=require("../../build/output/log");var _fs=require("fs");var _normalizePagePath=require("../../next-server/server/normalize-page-path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}async function isTrueCasePagePath(pagePath,pagesDir){const pageSegments=(0,_path.normalize)(pagePath).split(_path.sep).filter(Boolean);const segmentExistsPromises=pageSegments.map(async(segment,i)=>{const segmentParentDir=(0,_path.join)(pagesDir,...pageSegments.slice(0,i));const parentDirEntries=await _fs.promises.readdir(segmentParentDir);return parentDirEntries.includes(segment);});return(await Promise.all(segmentExistsPromises)).every(Boolean);}async function findPageFile(rootDir,normalizedPagePath,pageExtensions){const foundPagePaths=[];const page=(0,_normalizePagePath.denormalizePagePath)(normalizedPagePath);for(const extension of pageExtensions){if(!normalizedPagePath.endsWith('/index')){const relativePagePath=`${page}.${extension}`;const pagePath=(0,_path.join)(rootDir,relativePagePath);if(await(0,_isWriteable.isWriteable)(pagePath)){foundPagePaths.push(relativePagePath);}}const relativePagePathWithIndex=(0,_path.join)(page,`index.${extension}`);const pagePathWithIndex=(0,_path.join)(rootDir,relativePagePathWithIndex);if(await(0,_isWriteable.isWriteable)(pagePathWithIndex)){foundPagePaths.push(relativePagePathWithIndex);}}if(foundPagePaths.length<1){return null;}if(!(await isTrueCasePagePath(foundPagePaths[0],rootDir))){return null;}if(foundPagePaths.length>1){(0,_log.warn)(`Duplicate page detected. ${_chalk.default.cyan((0,_path.join)('pages',foundPagePaths[0]))} and ${_chalk.default.cyan((0,_path.join)('pages',foundPagePaths[1]))} both resolve to ${_chalk.default.cyan(normalizedPagePath)}.`);}return foundPagePaths[0];}
+"use strict";exports.__esModule=true;exports.findPageFile=findPageFile;var _path=require("path");var _chalk=_interopRequireDefault(require("chalk"));var _isWriteable=require("../../build/is-writeable");var _log=require("../../build/output/log");var _fs=require("fs");var _normalizePagePath=require("../../next-server/server/normalize-page-path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}async function isTrueCasePagePath(pagePath,pagesDir){const pageSegments=(0,_path.normalize)(pagePath).split(_path.sep).filter(Boolean);const segmentExistsPromises=pageSegments.map(async(segment,i)=>{const segmentParentDir=(0,_path.join)(pagesDir,...pageSegments.slice(0,i));const parentDirEntries=await _fs.promises.readdir(segmentParentDir);return parentDirEntries.includes(segment);});return(await Promise.all(segmentExistsPromises)).every(Boolean);}async function findPageFile(rootDir,normalizedPagePath,pageExtensions){const foundPagePaths=[];const page=(0,_normalizePagePath.denormalizePagePath)(normalizedPagePath);for(const extension of pageExtensions){if(!normalizedPagePath.endsWith('/index')){const relativePagePath=`${page}.${extension}`;const pagePath=(0,_path.join)(rootDir,relativePagePath);if(true){foundPagePaths.push(relativePagePath);}}const relativePagePathWithIndex=(0,_path.join)(page,`index.${extension}`);const pagePathWithIndex=(0,_path.join)(rootDir,relativePagePathWithIndex);if(true){foundPagePaths.push(relativePagePathWithIndex);}}if(foundPagePaths.length<1){return null;}if(!(await isTrueCasePagePath(foundPagePaths[0],rootDir))){return null;}if(foundPagePaths.length>1){(0,_log.warn)(`Duplicate page detected. ${_chalk.default.cyan((0,_path.join)('pages',foundPagePaths[0]))} and ${_chalk.default.cyan((0,_path.join)('pages',foundPagePaths[1]))} both resolve to ${_chalk.default.cyan(normalizedPagePath)}.`);}return foundPagePaths[0];}
//# sourceMappingURL=find-page-file.js.map
\ No newline at end of file
Loading

0 comments on commit 205b928

Please sign in to comment.