Skip to content

Commit

Permalink
Merge branch 'canary' into feature/regex-image-domains
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerShin committed Oct 30, 2020
2 parents 73c91c8 + 4263318 commit bf77450
Show file tree
Hide file tree
Showing 26 changed files with 277 additions and 43 deletions.
35 changes: 27 additions & 8 deletions examples/using-preact/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const preact = require('preact')
const withPrefresh = require('@prefresh/next')

module.exports = withPrefresh({
Expand Down Expand Up @@ -25,14 +26,32 @@ module.exports = withPrefresh({
const aliases = config.resolve.alias || (config.resolve.alias = {})
aliases.react = aliases['react-dom'] = 'preact/compat'

// Automatically inject Preact DevTools:
if (dev && !isServer) {
const entry = config.entry
config.entry = () =>
entry().then((entries) => {
entries['main.js'] = ['preact/debug'].concat(entries['main.js'] || [])
return entries
})
if (dev) {
if (isServer) {
// Remove circular `__self` and `__source` props only meant for development
let oldVNodeHook = preact.options.vnode
preact.options.vnode = (vnode) => {
const props = vnode.props
if (props != null) {
if ('__self' in props) props.__self = null
if ('__source' in props) props.__source = null
}

if (oldVNodeHook) {
oldVNodeHook(vnode)
}
}
} else {
// Automatically inject Preact DevTools:
const entry = config.entry
config.entry = () =>
entry().then((entries) => {
entries['main.js'] = ['preact/debug'].concat(
entries['main.js'] || []
)
return entries
})
}
}

return config
Expand Down
18 changes: 8 additions & 10 deletions examples/using-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
"build": "next build",
"start": "next start"
},
"devDependencies": {
"react-refresh": "^0.8.3"
},
"devDependencies": {},
"dependencies": {
"@prefresh/next": "^0.3.0",
"next": "^9.4.0",
"preact": "^10.4.4",
"preact-render-to-string": "^5.1.9",
"react": "github:preact-compat/react#1.0.0",
"react-dom": "github:preact-compat/react-dom#1.0.0",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.0.1"
"@prefresh/next": "^1.3.0",
"next": "10.0.0",
"preact": "^10.5.4",
"preact-render-to-string": "^5.1.10",
"react": "npm:@preact/compat@^0.0.3",
"react-dom": "npm:@preact/compat@^0.0.3",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.1.2"
},
"license": "MIT"
}
20 changes: 17 additions & 3 deletions examples/using-preact/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ export default function Home() {
return (
<div>
Hello World.{' '}
<Link href="/about">
<a>About</a>
</Link>
<ul>
<li>
<Link href="/about">
<a>About</a>
</Link>
</li>
<li>
<Link href="/ssr">
<a>SSR</a>
</Link>
</li>
<li>
<Link href="/ssg">
<a>SSG</a>
</Link>
</li>
</ul>
</div>
)
}
9 changes: 9 additions & 0 deletions examples/using-preact/pages/ssg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function SSG({ framework }) {
return <div>{framework} ssg example</div>
}

export function getStaticProps() {
return {
props: { framework: 'preact' },
}
}
9 changes: 9 additions & 0 deletions examples/using-preact/pages/ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function SSR({ framework }) {
return <div>{framework} ssr example</div>
}

export function getServerSideProps() {
return {
props: { framework: 'preact' },
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "10.0.0"
"version": "10.0.1-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": "10.0.0",
"version": "10.0.1-canary.1",
"keywords": [
"react",
"next",
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": "10.0.0",
"version": "10.0.1-canary.1",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
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": "10.0.0",
"version": "10.0.1-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
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": "10.0.0",
"version": "10.0.1-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": "10.0.0",
"version": "10.0.1-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": "10.0.0",
"version": "10.0.1-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "10.0.0",
"version": "10.0.1-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-google-analytics"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "10.0.0",
"version": "10.0.1-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
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": "10.0.0",
"version": "10.0.1-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": "10.0.0",
"version": "10.0.1-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": "10.0.0",
"version": "10.0.1-canary.1",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,10 @@ const nextServerlessLoader: loader.Loader = function () {
getStaticPaths: undefined,
getServerSideProps: undefined,
Component: NotFoundComponent,
err: undefined
err: undefined,
locale: detectedLocale,
locales,
defaultLocale: i18n.defaultLocale,
}))
sendPayload(req, res, result, 'html', ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function prepareDestination(
port?: string
} & ReturnType<typeof parseRelativeUrl> = {} as any

// clone query so we don't modify the original
query = Object.assign({}, query)
delete query.__nextLocale

if (destination.startsWith('/')) {
parsedDestination = parseRelativeUrl(destination)
} else {
Expand Down
11 changes: 11 additions & 0 deletions packages/next/next-server/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ export default class Router {
currentPathname = replaceBasePath(this.basePath, currentPathname!)
}

// re-add locale for custom-routes to allow matching against
if (
isCustomRoute &&
(req as any).__nextStrippedLocale &&
parsedUrl.query.__nextLocale
) {
currentPathname = `/${parsedUrl.query.__nextLocale}${
currentPathname === '/' ? '' : currentPathname
}`
}

const newParams = testRoute.match(currentPathname)

// Check if the match function matched
Expand Down
12 changes: 6 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.0.0",
"version": "10.0.1-canary.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -79,10 +79,10 @@
"@babel/runtime": "7.11.2",
"@babel/types": "7.11.5",
"@hapi/accept": "5.0.1",
"@next/env": "10.0.0",
"@next/polyfill-module": "10.0.0",
"@next/react-dev-overlay": "10.0.0",
"@next/react-refresh-utils": "10.0.0",
"@next/env": "10.0.1-canary.1",
"@next/polyfill-module": "10.0.1-canary.1",
"@next/react-dev-overlay": "10.0.1-canary.1",
"@next/react-refresh-utils": "10.0.1-canary.1",
"ast-types": "0.13.2",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
Expand Down Expand Up @@ -129,7 +129,7 @@
"sharp": "0.26.2"
},
"devDependencies": {
"@next/polyfill-nomodule": "10.0.0",
"@next/polyfill-nomodule": "10.0.1-canary.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "10.0.0",
"version": "10.0.1-canary.1",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "10.0.0",
"version": "10.0.1-canary.1",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
66 changes: 66 additions & 0 deletions test/integration/i18n-support/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,70 @@ module.exports = {
},
],
},
async redirects() {
return [
{
source: '/en-US/redirect',
destination: '/somewhere-else',
permanent: false,
},
{
source: '/nl/redirect',
destination: '/somewhere-else',
permanent: false,
},
{
source: '/redirect',
destination: '/somewhere-else',
permanent: false,
},
]
},
async rewrites() {
return [
{
source: '/en-US/rewrite',
destination: '/another',
},
{
source: '/nl/rewrite',
destination: '/another',
},
{
source: '/rewrite',
destination: '/another',
},
]
},
async headers() {
return [
{
source: '/en-US/add-header',
headers: [
{
key: 'x-hello',
value: 'world',
},
],
},
{
source: '/nl/add-header',
headers: [
{
key: 'x-hello',
value: 'world',
},
],
},
{
source: '/add-header',
headers: [
{
key: 'x-hello',
value: 'world',
},
],
},
]
},
}
4 changes: 3 additions & 1 deletion test/integration/i18n-support/pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ export default function NotFound(props) {
)
}

export const getStaticProps = ({ locale }) => {
export const getStaticProps = ({ locale, locales, defaultLocale }) => {
return {
props: {
locale,
locales,
defaultLocale,
is404: true,
},
}
Expand Down
Loading

0 comments on commit bf77450

Please sign in to comment.