1. 21 11月, 2020 1 次提交
  2. 19 11月, 2020 1 次提交
    • J
      Remove old modern mode experiment (#19275) · 30c2dfdc
      Joe Haddad 提交于
      This PR removes the modern mode experiment because:
      
      - It does not yield meaningful bundle size wins when compared to other initiatives we've taken
      - It's not compatible with webpack 5 (which we're upgrading to)
      - It's currently broken and causes most apps to malfunction
      - There's no champion currently owning the experiment
      
      We can re-introduce this in the future when we'd like to make it a default for all Next.js apps.
      
      Note: **Next.js still supports Differential Loading (`nomodule`) and does it by default.** This PR strictly removes the experimental modern _syntax_, and does not disable our existing modern/legacy polyfilling.
      
      ---
      
      Fixes #19200
      Fixes #18960
      Fixes #14707
      Fixes #14465
      30c2dfdc
  3. 11 11月, 2020 1 次提交
  4. 06 11月, 2020 1 次提交
    • G
      ncc 0.25.0 upgrade and fixes (#18873) · 8221c180
      Guy Bedford 提交于
      This upgrades to ncc@0.25.0 and fixes the previous bugs including:
      
      * ncc not referenced correctly in build
      * Babel type errors
      * node-fetch, etag, chalk and raw-body dependencies not building with ncc - these have been "un-ncc'd" for now. As they are relatively small dependencies, this doesn't seem too much of an issue and we can follow up in the tracking ncc issue at https://github.com/vercel/ncc/issues/612.
      * `yarn dev` issues
      
      Took a lot of bisecting, but the overall diff isn't too bad here in the end.
      8221c180
  5. 27 10月, 2020 1 次提交
  6. 16 10月, 2020 2 次提交
  7. 08 10月, 2020 2 次提交
    • J
      Update to have default locale matched on root (#17669) · bbc1a21c
      JJ Kasper 提交于
      Follow-up PR to https://github.com/vercel/next.js/pull/17370 when the path is not prefixed with a locale and the default locale is the detected locale it doesn't redirect to locale prefixed variant. If the default locale path is visited and the default locale is visited this also redirects to the root removing the un-necessary locale in the URL. 
      
      This also exposes the `defaultLocale` on the router since the RFC mentions `Setting a defaultLocale is required in every i18n library so it'd be useful for Next.js to provide it to the application.` although doesn't explicitly spec where we want to expose it. If we want to expose it differently this can be updated. 
      bbc1a21c
    • J
      Add initial changes for i18n support (#17370) · b2d1d87e
      JJ Kasper 提交于
      This adds the initial changes outlined in the [i18n routing RFC](https://github.com/vercel/next.js/discussions/17078). This currently treats the locale prefix on routes similar to how the basePath is treated in that the config doesn't require any changes to your pages directory and is automatically stripped/added based on the detected locale that should be used. 
      
      Currently redirecting occurs on the `/` route if a locale is detected regardless of if an optional catch-all route would match the `/` route or not we may want to investigate whether we want to disable this redirection automatically if an `/index.js` file isn't present at root of the pages directory. 
      
      TODO: 
      
      - [x] ensure locale detection/populating works in serverless mode correctly
      - [x] add tests for locale handling in different modes, fallback/getStaticProps/getServerSideProps
      
      To be continued in fall-up PRs
      
      - [ ] add tests for revalidate, auto-export, basePath + i18n
      - [ ] add mapping of domains with locales
      - [ ] investigate detecting locale against non-index routes and populating the locale in a cookie
      
      x-ref: https://github.com/vercel/next.js/issues/17110
      b2d1d87e
  8. 05 10月, 2020 2 次提交
  9. 26 9月, 2020 1 次提交
  10. 22 9月, 2020 1 次提交
  11. 07 9月, 2020 1 次提交
  12. 06 8月, 2020 1 次提交
    • A
      Add experimental image post-processing (#15875) · b6060fa4
      Alex Castle 提交于
      This PR adds a second experimental post-processing step for the framework introduced by @prateekbh in #14746. The image post-processing step scans the rendered document for the first few images and uses a simple heuristic to determine if the images should be automatically preloaded.
      
      Analysis of quite a few production Next apps has shown that a lot of sites are taking a substantial hit to their [LCP](https://web.dev/lcp/) score because an image that's part of the "hero" element on the page is not preloaded and is getting downloaded with lower priority than the JavaScript bundles. This post-processor should automatically fix that for a lot of sites, without causing any real performance effects in cases where it fails to identify the hero image.
      
      This feature is behind an experimental flag, and will be subject to quite a bit of experimentation and tweaking before it's ready to be made a default setting.
      b6060fa4
  13. 04 8月, 2020 2 次提交
  14. 03 8月, 2020 1 次提交
  15. 28 7月, 2020 1 次提交
  16. 23 6月, 2020 1 次提交
  17. 18 6月, 2020 1 次提交
  18. 15 6月, 2020 1 次提交
  19. 10 6月, 2020 1 次提交
  20. 07 6月, 2020 1 次提交
  21. 05 6月, 2020 1 次提交
    • J
      Fix pages/index.js and pages/index/index.js behavior (#13699) · 1b36f0c0
      Jan Potoms 提交于
      Disambiguate between pages/index.js and pages/index/index.js so that they resolve differently.
      It all started with a bug in pagesmanifest that propagated throughout the codebase. After fixing pagesmanifest I was able to remove a few hacks here and there and more logic is shared now. especially the logic that resolves an entrypoint back into a route path. To sum up what happened:
      
      - `getRouteFromEntrypoint` is the inverse operation of `getPageFile` that's under `pages/_document.tsx`
      - `denormalizePagePath` is the inverse operation of `normalizePagePath`.
      
      Everything is refactored in terms of these operations, that makes their behavior uniform and easier to update/patch in a central place. Before there were subtle differences between those that made `index/index.js` hard to handle.
      
      Some potential follow up on this PR:
      - [`hot-reloader`](https://github.com/vercel/next.js/pull/13699/files#diff-6161346d2c5f4b7abc87059d8768c44bR207) still has one place that does very similar behavior to `getRouteFromEntrypoint`. It can probably be rewritten in terms of `getRouteFromEntrypoint`.
      - There are a few places where `denormalizePagePath(normalizePagePath(...))` is happening. This is a sign that `normalizePagePath` is doing some validation that is independent of its rewriting logic. That should probably be factored out in its own function. after that I should probably investigate whether `normalizePagePath` is even still needed at all.
      - a lot of code is doing `.replace(/\\/g, '')`. If wanted, that could be replaced with `normalizePathSep`.
      - It looks to me like some logic that's spread across the project can be centralized in 4 functions 
        - `getRouteFromEntrypoint` (part of this PR)
        - its inverse `getEntrypointFromRoute` (already exists in `_document.tsx` as `getPageFile`)
        - `getRouteFromPageFile` 
        - its inverse `getPageFileFromRoute` (already exists as `findPageFile ` in `server/lib/find-page-file.ts`)
      
        It could be beneficial to structure the code to keep these fuctionalities close together and name them similarly.
       - revise `index.amp` handling in pagesmanifest. I left it alone in this PR to keep it scoped, but it may be broken wrt nested index files as well. It might even make sense to reshape the pagesmanifest altogether to handle html/json/amp/... better
      1b36f0c0
  22. 02 6月, 2020 1 次提交
    • T
      Added no-shadow rule to eslint (#13645) · b124ed2e
      Tim Neutkens 提交于
      Was going through _document and noticed some variable shadowing going on. Added a rule for it to our eslint configuration and went through all warnings with @Timer.
      b124ed2e
  23. 28 5月, 2020 1 次提交
  24. 27 5月, 2020 2 次提交
    • J
      Make sure to not duplicate exports with exportTrailingSlash (#11011) · ce0a32c3
      JJ Kasper 提交于
      This makes sure we don't duplicate the `/` route or any others while exporting with `exportTrailingSlash` enabled. We do still output `404.html` with `exportTrailingSlash` enabled in case anyone was relying on this file being present.
      
      Fixes: https://github.com/zeit/next.js/issues/11008
      ce0a32c3
    • C
      Add failing paths to export error summary (#10026) · d94e8db5
      Christian Stuff 提交于
      Closes #9990 by collecting all paths with errors during `next export` and reporting them sorted in the error summary at the end.
      
      It will produce an output similar to:
      
      ```
          Error: Export encountered errors on following paths:
              /nested/page
              /page
              /page-1
              /page-10
              /page-11
              /page-12
              /page-13
              /page-2
              /page-3
              /page-4
              /page-5
              /page-6
              /page-7
              /page-8
              /page-9
              at _default (/app/next.js/packages/next/dist/export/index.js:19:788)
              at process._tickCallback (internal/process/next_tick.js:68:7)
      ```
      
      I tested the output with the `handle-export-errors` integration test suite, but I'm not sure how to gracefully test this added output.
      I thought of collecting all page source files with [recursiveReaddirSync](https://github.com/zeit/next.js/blob/2ba352da39ee00b6595aecdc9ffb2f103e803a85/packages/next/next-server/server/lib/recursive-readdir-sync.ts) but it seems I can't import it in js test files:
      
      ```
      SyntaxError: /app/next.js/packages/next/next-server/server/lib/recursive-readdir-sync.ts: Unexpected token, expected "," (11:5)
      
             9 |  */
            10 | export function recursiveReadDirSync(
          > 11 |   dir: string,
               |      ^
            12 |   arr: string[] = [],
            13 |   rootDir = dir
            14 | ): string[] {
      ```
      
      The test itself could look like:
      ```js
        it('Reports failing paths', async () => {
          const { stderr } = await nextBuild(appDir, [], {
            stdout: true,
            stderr: true,
          })
          const pages = []
          // collect pages to be ['/page', '/page-1', ... etc.]
          pages.forEach(page => {
            expect(stderr).toContain(page)
          })
        })
      ```
      d94e8db5
  25. 26 5月, 2020 2 次提交
    • J
      Convert export worker to typescript (#13381) · 67df4970
      Jan Potoms 提交于
      This is purely adding types except for the line:
      
      ```js
      params = getRouteMatcher(getRouteRegex(page))(path) || undefined
      ```
      
      Also added a couple of `@ts-ignore` as to avoid having to make any more functional changes
      67df4970
    • J
      Add a few extra types (#13363) · 2e1a322d
      Jan Potoms 提交于
      Added a few extra types here and there while I was digging through the code
      2e1a322d
  26. 25 5月, 2020 1 次提交
  27. 21 5月, 2020 1 次提交
  28. 19 5月, 2020 2 次提交
  29. 02 5月, 2020 1 次提交
  30. 14 4月, 2020 1 次提交
    • J
      Add basePath in link component and add/remove it consistently (#9988) · d3e308a7
      JJ Kasper 提交于
      * Add basePath in link component and add/remove it consistently
      
      * Update to not use regex for delBasePath
      
      * Expose addBasePath as router method
      
      * Revert "Expose addBasePath as router method"
      
      This reverts commit 40fed596195c6affabf837e42d472452768e13a3.
      
      * Expose basePath as router field
      
      * Apply suggestion
      
      * Expose basePath as router field
      
      * remove un-used vars
      
      * Update externals
      
      * Apply lint fix
      
      * Update size-limit test
      
      * Update prefetch
      d3e308a7
  31. 31 3月, 2020 3 次提交