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 13 fixes #5175

Merged
merged 14 commits into from Oct 31, 2022
Merged

Next 13 fixes #5175

merged 14 commits into from Oct 31, 2022

Conversation

jamesdaniels
Copy link
Member

@jamesdaniels jamesdaniels commented Oct 26, 2022

Couple of fixes for Next.js v13

  • Bump deploy test to Next 13, add an app directory and some additional components
  • Set __NEXT_REACT_ROOT when compiling an app targeting React 18
  • Don't blindly copy over all .html files, we need to skip those using ISR
  • Skip ISR files while building the hosting directory
  • Generated html/json can be found in the app directory, not just pages, now
  • Removed some unused deps
  • Use NPM on Next.js hosting init

TODO

  • add comment clarifying we shouldn't go overboard optimizing for app directory yet, as it's unstable
  • change log
  • cleanup types
  • move to semver test for react 18

@codecov-commenter
Copy link

codecov-commenter commented Oct 26, 2022

Codecov Report

Base: 56.22% // Head: 56.15% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (c266bd6) compared to base (87e8f0c).
Patch coverage: 7.69% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5175      +/-   ##
==========================================
- Coverage   56.22%   56.15%   -0.07%     
==========================================
  Files         308      308              
  Lines       20752    20776      +24     
  Branches     4206     4214       +8     
==========================================
- Hits        11667    11666       -1     
- Misses       8071     8096      +25     
  Partials     1014     1014              
Impacted Files Coverage Δ
src/frameworks/next/index.ts 13.41% <7.69%> (-1.59%) ⬇️
src/emulator/auth/state.ts 84.87% <0.00%> (-0.57%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TheIronDev

This comment was marked as resolved.

@jamesdaniels
Copy link
Member Author

@TheIronDev added into the nextjs deploy test. FYI I'm porting the matrix/canary tests from FirebaseExtended to this repo, WIP here #5187 aiming to have that in good shape early next week. This would catch problems like this.

// TODO drop from hosting if revalidate
for (const route in prerenderManifest.routes) {
if (prerenderManifest.routes[route]) {
for (const path in prerenderManifest.routes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be of?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not an iterable, it's an object: { "/foo": { ... }, "/bar": { ... }}

so in is correct, though with the linting rule (to ensure we don't iterate over private) it's a little verbose... perhaps const path of Object.keys(prerenderManifest) or const [path, route] of Object.entries(prerenderManifest.routes) would be stylistically preferable?

src/frameworks/next/index.ts Outdated Show resolved Hide resolved
// / => index.json => index.html => index.html
// /foo => foo.json => foo.html
const parts = route
const parts = path
.split("/")
.slice(1)
.filter((it) => !!it);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slice and filter bits seem redundant. It seems like you're using splice(1) because leading slashes will lead to an empty element from split (are we guaranteed to lead with a slash?) and filter will filter out empty components as well. So if you're only and always going to have a leading slash, then splice does the trick. But filter seems like it works for that case and a final slash.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was likely overly defensive here, worrying aboth leading/trailing slash, I'll check my assumptions. that said, we're pushing cleanURLs to be true by default now when paired with hosting.source, I can probably simplify this code. I'll do that in a follow on so I unblock Next 13 from working

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took on as a TODO to explore simplifying

@hassaanp
Copy link

when can we expect this to merge?

@jamesdaniels jamesdaniels merged commit 2a675d8 into master Oct 31, 2022
@jamesdaniels jamesdaniels deleted the jamesdaniels_next_13 branch October 31, 2022 20:14
@LorenzoBloedow
Copy link

When can we expect the next release with this fix? I tried building it myself a few days ago but had a weird bug where it kept
duplicating my whole project, probably did something wrong in the build process.

@jeremyrajan
Copy link

i tried the 11.15.0 release, doesnt seem to work tho. Still giving me error that its looking for pages and not app. Anything I am doing wrong?

@RajendraAVerma
Copy link

RajendraAVerma commented Nov 1, 2022

i tried the 11.15.0 release, doesnt seem to work tho. Still giving me error that its looking for pages and not app. Anything I am doing wrong?

I tried the 11.15.0 release and hopefully it work 🔥👍 !

 "dependencies": {
    "eslint": "8.26.0",
    "eslint-config-next": "13.0.1",
    "next": "13.0.1",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  }

@luisorbaiceta
Copy link

i tried the 11.15.0 release, doesnt seem to work tho. Still giving me error that its looking for pages and not app. Anything I am doing wrong?

Version 11.15.0 is from two weeks ago and this has been merged 12 hours ago

@JGSolutions
Copy link

do u guys still use npm build && npm export?

@jamesdaniels
Copy link
Member Author

jamesdaniels commented Nov 14, 2022

@JGSolutions ATM we call the Node entry point for Next Build API next/dist/build and we blindly attempt a next export. If the export succeeds we deploy that to the CDN, if it fails we parse the Next Build API and locate all the static artifacts that should be deployed to the CDN. We then use heuristics to determine if a Cloud Functions backend is needed—running a Next Custom Server—when the CDN misses.

In an upcoming release, we're dropping the attempted next export as we've found shortcomings in its assumptions that make it an unreliable early return for building the CDN artifacts. Our own "export" out of the Next Built API is proving just as reliable now that we've built up a good understanding of the manifest files.

@sanesanyo
Copy link

@jamesdaniels Can you please look at this thread: #5369 ? We have been struggling with Firebase NextJS deployment issues and so far no one has answered from Firebase side. Given you are working on the development, hopefully you can help us out. Thanks a lot in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet