Skip to content

Commit

Permalink
Merge branch 'canary' into add/standalone-build
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Nov 8, 2021
2 parents 64ce2cd + 9fe0fda commit 79c1b3b
Show file tree
Hide file tree
Showing 39 changed files with 229 additions and 74 deletions.
3 changes: 3 additions & 0 deletions docs/advanced-features/i18n-routing.md
Expand Up @@ -100,6 +100,8 @@ module.exports = {

domains: [
{
// Note: subdomains must be included in the domain value to be matched
// e.g. www.example.com should be used if that is the expected hostname
domain: 'example.com',
defaultLocale: 'en-US',
},
Expand All @@ -122,6 +124,7 @@ module.exports = {
For example if you have `pages/blog.js` the following urls will be available:

- `example.com/blog`
- `www.example.com/blog`
- `example.fr/blog`
- `example.nl/blog`
- `example.nl/nl-BE/blog`
Expand Down
8 changes: 4 additions & 4 deletions docs/api-reference/next.config.js/url-imports.md
Expand Up @@ -45,7 +45,7 @@ These resources will have a `no-cache` entry in the lockfile and will always be

## Examples

#### Skypack
### Skypack

```js
import confetti from 'https://cdn.skypack.dev/canvas-confetti'
Expand All @@ -59,7 +59,7 @@ export default () => {
}
```

#### Static Image Imports
### Static Image Imports

```js
import Image from 'next/image'
Expand All @@ -72,15 +72,15 @@ export default () => (
)
```

#### URLs in CSS
### URLs in CSS

```css
.className {
background: url('https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png');
}
```

#### Asset Imports
### Asset Imports

```js
import Image from 'next/image'
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/typescript.md
Expand Up @@ -53,7 +53,7 @@ npm run dev
# ...
```

You're now ready to start converting files from `.js` to `.tsx` and leveraging the benefits of TypeScript!.
You're now ready to start converting files from `.js` to `.tsx` and leveraging the benefits of TypeScript!

> A file named `next-env.d.ts` will be created in the root of your project. This file ensures Next.js types are picked up by the TypeScript compiler. **You cannot remove it or edit it** as it can change at any time.
Expand Down
2 changes: 1 addition & 1 deletion docs/testing.md
Expand Up @@ -136,7 +136,7 @@ You can learn more about Cypress and Continuous Integration from these resources

- [Cypress Continuous Integration Docs](https://docs.cypress.io/guides/continuous-integration/introduction)
- [Cypress GitHub Actions Guide](https://on.cypress.io/github-actions)
- [Official Cypress Github Action](https://github.com/cypress-io/github-action)
- [Official Cypress GitHub Action](https://github.com/cypress-io/github-action)

## Playwright

Expand Down
2 changes: 1 addition & 1 deletion examples/with-chakra-ui-typescript/src/pages/index.tsx
Expand Up @@ -21,7 +21,7 @@ const Index = () => (
<Main>
<Text>
Example repository of <Code>Next.js</Code> + <Code>chakra-ui</Code> +{' '}
<Code>typescript</Code>.
<Code>TypeScript</Code>.
</Text>

<List spacing={3} my={0}>
Expand Down
4 changes: 2 additions & 2 deletions examples/with-firebase-hosting/README.md
Expand Up @@ -41,9 +41,9 @@ npm run deploy
yarn deploy
```

## Typescript
## TypeScript

To use Typescript, simply follow [Typescript setup](https://nextjs.org/learn/excel/typescript/setup) as normal (package.json scripts are already set).
To use TypeScript, simply follow [TypeScript setup](https://nextjs.org/learn/excel/typescript/setup) as normal (package.json scripts are already set).

i.e: `npm install --save-dev typescript @types/react @types/node`

Expand Down
2 changes: 1 addition & 1 deletion examples/with-mobx-state-tree-typescript/README.md
@@ -1,4 +1,4 @@
# MobX State Tree with Typescript example
# MobX State Tree with TypeScript example

Usually splitting your app state into `pages` feels natural but sometimes you'll want to have global state for your app. This is an example on how you can use mobx that also works with our universal rendering approach.

Expand Down
2 changes: 1 addition & 1 deletion examples/with-mobx-state-tree-typescript/store.ts
Expand Up @@ -20,7 +20,7 @@ const Store = types
timer = setInterval(() => {
// mobx-state-tree doesn't allow anonymous callbacks changing data.
// Pass off to another action instead (need to cast self as any
// because typescript doesn't yet know about the actions we're
// because TypeScript doesn't yet know about the actions we're
// adding to self here)
;(self as any).update()
}, 1000)
Expand Down
@@ -0,0 +1,14 @@
export default function Home({}) {
return (
<div>
<p>Hello World</p>
</div>
)
}

export async function getStaticProps() {
await import('_http_common').then((http) => console.log(http))
return {
props: {},
}
}
@@ -0,0 +1,4 @@
export var __N_SSG = true;
export default function Home({}) {
return __jsx("div", null, __jsx("p", null, "Hello World"));
};
@@ -1,4 +1,4 @@
import loaderUtils from 'next/dist/compiled/loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils3'
import path from 'path'
import { webpack } from 'next/dist/compiled/webpack/webpack'

Expand Down
Expand Up @@ -5,7 +5,7 @@
import { fileURLToPath } from 'url'
import path from 'path'

import { urlToRequest } from 'next/dist/compiled/loader-utils'
import { urlToRequest } from 'next/dist/compiled/loader-utils3'
import modulesValues from 'next/dist/compiled/postcss-modules-values'
import localByDefault from 'next/dist/compiled/postcss-modules-local-by-default'
import extractImports from 'next/dist/compiled/postcss-modules-extract-imports'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack/loaders/next-image-loader.js
@@ -1,4 +1,4 @@
import loaderUtils from 'next/dist/compiled/loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils3'
import { resizeImage, getImageSize } from '../../../server/image-optimizer'

const BLUR_IMG_SIZE = 8
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack/plugins/copy-file-plugin.ts
@@ -1,5 +1,5 @@
import { promises as fs } from 'fs'
import loaderUtils from 'next/dist/compiled/loader-utils'
import loaderUtils from 'next/dist/compiled/loader-utils3'
import { sources, webpack } from 'next/dist/compiled/webpack/webpack'

const PLUGIN_NAME = 'CopyFilePlugin'
Expand Down
3 changes: 3 additions & 0 deletions packages/next/cli/next-lint.ts
Expand Up @@ -30,6 +30,7 @@ const eslintOptions = (args: arg.Spec, defaultCacheLocation: string) => ({
args['--report-unused-disable-directives'] || null,
cache: !Boolean(args['--no-cache']),
cacheLocation: args['--cache-location'] || defaultCacheLocation,
cacheStrategy: args['--cache-strategy'] || 'metadata',
errorOnUnmatchedPattern: args['--error-on-unmatched-pattern']
? Boolean(args['--error-on-unmatched-pattern'])
: false,
Expand Down Expand Up @@ -67,6 +68,7 @@ const nextLint: cliCommand = async (argv) => {
'--cache': Boolean, // Although cache is enabled by default, this dummy flag still exists to not cause any breaking changes
'--no-cache': Boolean,
'--cache-location': String,
'--cache-strategy': String,
'--error-on-unmatched-pattern': Boolean,
'--format': String,

Expand Down Expand Up @@ -134,6 +136,7 @@ const nextLint: cliCommand = async (argv) => {
Caching:
--no-cache Disable caching
--cache-location path::String Path to the cache file or directory - default: .eslintcache
--cache-strategy String Strategy to use for detecting changed files in the cache, either metadata or content - default: metadata
Miscellaneous:
--error-on-unmatched-pattern Show errors when any file patterns are unmatched - default: false
Expand Down
6 changes: 3 additions & 3 deletions packages/next/client/head-manager.ts
Expand Up @@ -60,10 +60,10 @@ function updateElements(type: string, components: JSX.Element[]): void {
for (
let i = 0, j = headCountEl.previousElementSibling;
i < headCount;
i++, j = j!.previousElementSibling
i++, j = j?.previousElementSibling || null
) {
if (j?.tagName?.toLowerCase() === type) {
oldTags.push(j!)
oldTags.push(j)
}
}
const newTags = (components.map(reactElementToDOM) as HTMLElement[]).filter(
Expand All @@ -79,7 +79,7 @@ function updateElements(type: string, components: JSX.Element[]): void {
}
)

oldTags.forEach((t) => t.parentNode!.removeChild(t))
oldTags.forEach((t) => t.parentNode?.removeChild(t))
newTags.forEach((t) => headEl.insertBefore(t, headCountEl))
headCountEl.content = (headCount - oldTags.length + newTags.length).toString()
}
Expand Down
1 change: 0 additions & 1 deletion packages/next/compiled/loader-utils/loader-utils.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/loader-utils/package.json

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions packages/next/compiled/loader-utils2/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/next/compiled/loader-utils2/package.json
@@ -0,0 +1 @@
{"name":"loader-utils","main":"index.js","author":"Tobias Koppers @sokra","license":"MIT"}
20 changes: 20 additions & 0 deletions packages/next/compiled/loader-utils3/LICENSE
@@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions packages/next/compiled/loader-utils3/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/next/compiled/loader-utils3/package.json
@@ -0,0 +1 @@
{"name":"loader-utils","main":"index.js","author":"Tobias Koppers @sokra","license":"MIT"}
2 changes: 1 addition & 1 deletion packages/next/compiled/resolve-url-loader/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/sass-loader/cjs.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/next/lib/typescript/writeConfigurationDefaults.ts
Expand Up @@ -38,7 +38,7 @@ function getDesiredCompilerOptions(
// 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()
esModuleInterop: {
value: true,
reason: 'requirement for babel',
reason: 'requirement for SWC / babel',
},
module: {
parsedValue: ts.ModuleKind.ESNext,
Expand All @@ -60,7 +60,7 @@ function getDesiredCompilerOptions(
resolveJsonModule: { value: true, reason: 'to match webpack resolution' },
isolatedModules: {
value: true,
reason: 'requirement for babel',
reason: 'requirement for SWC / Babel',
},
jsx: {
parsedValue: ts.JsxEmit.Preserve,
Expand Down
3 changes: 2 additions & 1 deletion packages/next/package.json
Expand Up @@ -224,7 +224,8 @@
"is-wsl": "2.2.0",
"json5": "2.2.0",
"jsonwebtoken": "8.5.1",
"loader-utils": "3.1.0",
"loader-utils2": "npm:loader-utils@2.0.0",
"loader-utils3": "npm:loader-utils@3.1.3",
"lodash.curry": "4.1.1",
"lru-cache": "5.1.1",
"micromatch": "4.0.4",
Expand Down
31 changes: 24 additions & 7 deletions packages/next/taskfile.js
Expand Up @@ -356,12 +356,21 @@ export async function ncc_jsonwebtoken(task, opts) {
.target('compiled/jsonwebtoken')
}
// eslint-disable-next-line camelcase
externals['loader-utils'] = 'next/dist/compiled/loader-utils'
export async function ncc_loader_utils(task, opts) {
externals['loader-utils'] = 'error loader-utils version not specified'
externals['loader-utils2'] = 'next/dist/compiled/loader-utils2'
export async function ncc_loader_utils2(task, opts) {
await task
.source(opts.src || 'bundles/loader-utils.js')
.ncc({ packageName: 'loader-utils', externals })
.target('compiled/loader-utils')
.source(opts.src || relative(__dirname, require.resolve('loader-utils2')))
.ncc({ packageName: 'loader-utils2', externals })
.target('compiled/loader-utils2')
}
// eslint-disable-next-line camelcase
externals['loader-utils3'] = 'next/dist/compiled/loader-utils3'
export async function ncc_loader_utils3(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('loader-utils3')))
.ncc({ packageName: 'loader-utils3', externals })
.target('compiled/loader-utils3')
}
// eslint-disable-next-line camelcase
externals['lodash.curry'] = 'next/dist/compiled/lodash.curry'
Expand Down Expand Up @@ -613,7 +622,13 @@ export async function ncc_resolve_url_loader(task, opts) {
.source(
opts.src || relative(__dirname, require.resolve('resolve-url-loader'))
)
.ncc({ packageName: 'resolve-url-loader', externals })
.ncc({
packageName: 'resolve-url-loader',
externals: {
...externals,
'loader-utils': externals['loader-utils2'], // actually loader-utils@1 but that is compatible
},
})
.target('compiled/resolve-url-loader')
}
// eslint-disable-next-line camelcase
Expand All @@ -631,6 +646,7 @@ export async function ncc_sass_loader(task, opts) {
externals: {
...externals,
'schema-utils': externals['schema-utils3'],
'loader-utils': externals['loader-utils2'],
},
target: 'es5',
})
Expand Down Expand Up @@ -958,7 +974,8 @@ export async function ncc(task, opts) {
'ncc_is_wsl',
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_loader_utils',
'ncc_loader_utils2',
'ncc_loader_utils3',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_nanoid',
Expand Down
2 changes: 1 addition & 1 deletion packages/next/types/webpack.d.ts
Expand Up @@ -24,7 +24,7 @@
/// <reference types="node" />

declare module 'mini-css-extract-plugin'
declare module 'next/dist/compiled/loader-utils'
declare module 'next/dist/compiled/loader-utils3'

declare module 'next/dist/compiled/webpack/webpack' {
import webpackSources from 'webpack-sources1'
Expand Down
4 changes: 2 additions & 2 deletions test/integration/css-features/test/index.test.js
Expand Up @@ -197,7 +197,7 @@ describe('CSS Modules: Import Global CSS', () => {
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')

expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`"a .styles_foo__31qlD{all:initial}"`
`"a .styles_foo__Io_Us{all:initial}"`
)
})
})
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('CSS Modules: Import Exports', () => {
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')

expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`".styles_blk__2ns7r{color:#000}"`
`".styles_blk__CqbFg{color:#000}"`
)
})
})
Expand Down

0 comments on commit 79c1b3b

Please sign in to comment.