Skip to content

Commit

Permalink
Merge branch 'canary' into refactor-build
Browse files Browse the repository at this point in the history
  • Loading branch information
feedthejim committed Feb 1, 2023
2 parents ee78594 + e01f0e4 commit 7b2ec89
Show file tree
Hide file tree
Showing 56 changed files with 340 additions and 583 deletions.
2 changes: 1 addition & 1 deletion .github/actions/issue-validator/canary.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If your issue has not been resolved in that time and it has been closed/locked,

### **I did not open this issue, but it is relevant to me, what can I do to help?**

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please **do not** comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please **do not** comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.

### **I think my reproduction is good enough, why aren't you looking into it quicker?**

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/issue-validator/repro.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If your issue has _not_ been resolved in that time and it has been closed/locked

### **I did not open this issue, but it is relevant to me, what can I do to help?**

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please **do not** comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please **do not** comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.

### **I think my reproduction is good enough, why aren't you looking into it quicker?**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = function actionInfo() {
if (releaseTypes.has(info.actionName)) {
info.isRelease = true
} else {
// Since GITHUB_REPOSITORY and REF might not match the fork
// since GITHUB_REPOSITORY and REF might not match the fork
// use event data to get repository and ref info
const prData = event['pull_request']

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/next-stats-action/src/run/benchmark-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const parseField = (stdout = '', field = '') => {
return stdout.split(field).pop().trim().split(/\s/).shift().trim()
}

// benchmark a url
// benchmark an url
async function benchmarkUrl(
url = '',
options = {
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
Choose the right checklist for the change(s) that you're making:
-->

## Bug
Expand Down
8 changes: 4 additions & 4 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
"title": "getServerSideProps",
"path": "/docs/basic-features/data-fetching/get-server-side-props.md"
},
{
"title": "getStaticPaths",
"path": "/docs/basic-features/data-fetching/get-static-paths.md"
},
{
"title": "getStaticProps",
"path": "/docs/basic-features/data-fetching/get-static-props.md"
},
{
"title": "getStaticPaths",
"path": "/docs/basic-features/data-fetching/get-static-paths.md"
},
{
"title": "Incremental Static Regeneration",
"path": "/docs/basic-features/data-fetching/incremental-static-regeneration.md"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.1.7-canary.0"
"version": "13.1.7-canary.1"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -12,7 +12,7 @@
"test-pack": "cd ../../ && pnpm test-pack eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "13.1.7-canary.0",
"@next/eslint-plugin-next": "13.1.7-canary.1",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
3 changes: 2 additions & 1 deletion packages/font/src/google/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ const downloadGoogleFonts: FontLoader = async ({
const selfHostedFileUrl = emitFontFile(
fontFileBuffer,
ext,
preloadFontFile
preloadFontFile,
!!adjustFontFallbackMetrics
)

return {
Expand Down
7 changes: 6 additions & 1 deletion packages/font/src/local/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ const fetchFonts: FontLoader = async ({
src.map(async ({ path, style, weight, ext, format }) => {
const resolved = await resolve(path)
const fileBuffer = await promisify(loaderContext.fs.readFile)(resolved)
const fontUrl = emitFontFile(fileBuffer, ext, preload)
const fontUrl = emitFontFile(
fileBuffer,
ext,
preload,
typeof adjustFontFallback === 'undefined' || !!adjustFontFallback
)

let fontMetadata: any
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"private": true,
"scripts": {
"clean": "rm -rf ./native/*",
Expand Down
7 changes: 6 additions & 1 deletion packages/next/font/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export type FontLoader = (options: {
variableName: string
data: any[]
config: any
emitFontFile: (content: Buffer, ext: string, preload: boolean) => string
emitFontFile: (
content: Buffer,
ext: string,
preload: boolean,
isUsingSizeAdjust?: boolean
) => string
resolve: (src: string) => string
isDev: boolean
isServer: boolean
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "13.1.7-canary.0",
"version": "13.1.7-canary.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -77,7 +77,7 @@
]
},
"dependencies": {
"@next/env": "13.1.7-canary.0",
"@next/env": "13.1.7-canary.1",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
Expand Down Expand Up @@ -127,11 +127,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.13.3",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.1.7-canary.0",
"@next/polyfill-nomodule": "13.1.7-canary.0",
"@next/react-dev-overlay": "13.1.7-canary.0",
"@next/react-refresh-utils": "13.1.7-canary.0",
"@next/swc": "13.1.7-canary.0",
"@next/polyfill-module": "13.1.7-canary.1",
"@next/polyfill-nomodule": "13.1.7-canary.1",
"@next/react-dev-overlay": "13.1.7-canary.1",
"@next/react-refresh-utils": "13.1.7-canary.1",
"@next/swc": "13.1.7-canary.1",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ export default async function nextFontLoader(this: any) {
})
)

const emitFontFile = (content: Buffer, ext: string, preload: boolean) => {
const emitFontFile = (
content: Buffer,
ext: string,
preload: boolean,
isUsingSizeAdjust?: boolean
) => {
const opts = { context: this.rootContext, content }
const interpolatedName = loaderUtils.interpolateName(
this,
// Font files ending with .p.(woff|woff2|eot|ttf|otf) are preloaded
`static/media/[hash]${preload ? '.p' : ''}.${ext}`,
`static/media/[hash]${isUsingSizeAdjust ? '-s' : ''}${
preload ? '.p' : ''
}.${ext}`,
opts
)
const outputPath = `${assetPrefix}/_next/${interpolatedName}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type FontLoaderManifest = {
app: {
[moduleRequest: string]: string[]
}
appUsingSizeAdjust: boolean
pagesUsingSizeAdjust: boolean
}
const PLUGIN_NAME = 'FontLoaderManifestPlugin'

Expand Down Expand Up @@ -50,6 +52,8 @@ export class FontLoaderManifestPlugin {
const fontLoaderManifest: FontLoaderManifest = {
pages: {},
app: {},
appUsingSizeAdjust: false,
pagesUsingSizeAdjust: false,
}

if (this.appDirEnabled) {
Expand All @@ -60,6 +64,12 @@ export class FontLoaderManifestPlugin {
/\.(woff|woff2|eot|ttf|otf)$/.test(file)
)

if (!fontLoaderManifest.appUsingSizeAdjust) {
fontLoaderManifest.appUsingSizeAdjust = fontFiles.some((file) =>
file.includes('-s')
)
}

// Font files ending with .p.(woff|woff2|eot|ttf|otf) are preloaded
const preloadedFontFiles: string[] = fontFiles.filter(
(file: string) => /\.p.(woff|woff2|eot|ttf|otf)$/.test(file)
Expand All @@ -86,6 +96,12 @@ export class FontLoaderManifestPlugin {
/\.(woff|woff2|eot|ttf|otf)$/.test(file)
)

if (!fontLoaderManifest.pagesUsingSizeAdjust) {
fontLoaderManifest.pagesUsingSizeAdjust = fontFiles.some((file) =>
file.includes('-s')
)
}

// Font files ending with .p.(woff|woff2|eot|ttf|otf) are preloaded
const preloadedFontFiles: string[] = fontFiles.filter(
(file: string) => /\.p.(woff|woff2|eot|ttf|otf)$/.test(file)
Expand Down
20 changes: 18 additions & 2 deletions packages/next/src/client/components/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ function findHeadInCache(
return undefined
}

function isExternalURL(url: URL) {
return url.origin !== location.origin
}

/**
* The global router that wraps the application components.
*/
Expand Down Expand Up @@ -180,9 +184,12 @@ function Router({
navigateType: 'push' | 'replace',
forceOptimisticNavigation: boolean
) => {
const url = new URL(href, location.origin)

return dispatch({
type: ACTION_NAVIGATE,
url: new URL(href, location.origin),
url,
isExternalUrl: isExternalURL(url),
forceOptimisticNavigation,
navigateType,
cache: {
Expand All @@ -205,6 +212,10 @@ function Router({
}
prefetched.add(href)
const url = new URL(href, location.origin)
// External urls can't be prefetched in the same way.
if (isExternalURL(url)) {
return
}
try {
const routerTree = window.history.state?.tree || initialTree
const serverResponse = await fetchServerResponse(
Expand Down Expand Up @@ -261,7 +272,12 @@ function Router({
useEffect(() => {
// When mpaNavigation flag is set do a hard navigation to the new url.
if (pushRef.mpaNavigation) {
window.location.href = canonicalUrl
const location = window.location
if (pushRef.pendingPush) {
location.assign(canonicalUrl)
} else {
location.replace(canonicalUrl)
}
return
}

Expand Down
Loading

0 comments on commit 7b2ec89

Please sign in to comment.