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

Skipping partial html files generated due to enabling ppr in Nextjs #7625

Merged
merged 21 commits into from
Oct 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0a303e8
Skipping partial html files generated due to enabling ppr in Nextjs
chalosalvador Sep 4, 2024
703b6a9
Detect partial html files in build and add them to reasonsForBackend.
chalosalvador Sep 12, 2024
c4eedfe
Add tests cases for new utils functions
chalosalvador Sep 12, 2024
983cd5d
Merge branch 'master' of github.com:firebase/firebase-tools into chal…
chalosalvador Sep 12, 2024
c78c861
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Sep 12, 2024
467392a
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Oct 3, 2024
ec84e82
Merge branch 'chalosalvador/fix-next-ppr-dynamic-pages' of github.com…
chalosalvador Oct 4, 2024
5aab663
Check if file .html exists before trying to read it.
chalosalvador Oct 4, 2024
c86c96a
Remove warning if file does not exist
chalosalvador Oct 4, 2024
0f0ea1a
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Oct 4, 2024
74ec984
Changelog
chalosalvador Oct 4, 2024
f04ed22
Promise.all test isPartialHTML
chalosalvador Oct 9, 2024
d81127e
Merge branch 'master' of github.com:firebase/firebase-tools into chal…
chalosalvador Oct 9, 2024
005d6d3
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Oct 17, 2024
47c3def
Refactor to use .meta files for PPR
chalosalvador Oct 17, 2024
9dd127a
Changelog
chalosalvador Oct 17, 2024
2d1eb4a
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Oct 22, 2024
f007b25
Merge branch 'master' into chalosalvador/fix-next-ppr-dynamic-pages
chalosalvador Oct 24, 2024
ff589a5
Update CHANGELOG.md
leoortizz Oct 24, 2024
17ca89c
Update CHANGELOG.md
leoortizz Oct 24, 2024
b5a67be
Merge branch 'master' of github.com:firebase/firebase-tools into chal…
chalosalvador Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/frameworks/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@
const DEFAULT_NUMBER_OF_REASONS_TO_LIST = 5;

function getReactVersion(cwd: string): string | undefined {
return findDependency("react-dom", { cwd, omitDev: false })?.version;

Check warning on line 100 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe return of an `any` typed value

Check warning on line 100 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .version on an `any` value
}

/**
* Returns whether this codebase is a Next.js backend.
*/
export async function discover(dir: string) {

Check warning on line 106 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
if (!(await pathExists(join(dir, "package.json")))) return;
const version = getNextVersion(dir);
if (!(await whichNextConfigFile(dir)) && !version) return;
Expand Down Expand Up @@ -160,10 +160,10 @@

const nextBuild = new Promise((resolve, reject) => {
const buildProcess = spawn(cli, ["build"], { cwd: dir, env });
buildProcess.stdout?.on("data", (data) => logger.info(data.toString()));

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Error`

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .toString on an `any` value

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
buildProcess.stderr?.on("data", (data) => logger.info(data.toString()));

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Error`

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .toString on an `any` value

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
buildProcess.on("error", (err) => {
reject(new FirebaseError(`Unable to build your Next.js app: ${err}`));

Check warning on line 166 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "Error" of template literal expression
});
buildProcess.on("exit", (code) => {
resolve(code);
Expand Down Expand Up @@ -536,6 +536,15 @@
let defaultDestPath = isDefaultLocale && join(destDir, basePath, ...destPartsOrIndex);
if (!fileExistsSync(sourcePath) && fileExistsSync(`${sourcePath}.html`)) {
sourcePath += ".html";
// Check if the HTML file is partial (doesn't have closing </html> tag)
const content = await readFile(sourcePath, "utf8");
if (!content.includes("</html>")) {
jamesdaniels marked this conversation as resolved.
Show resolved Hide resolved
logger.debug(
`Skipping ${path} as it appears to be a partial HTML file which is not supported by Firebase Hosting`,
);
return;
}

if (localizedDestPath) localizedDestPath += ".html";
if (defaultDestPath) defaultDestPath += ".html";
} else if (
Expand Down
Loading