Skip to content

Commit

Permalink
Merge branch 'canary' into update/locales-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Aug 24, 2021
2 parents 294807e + fd1c56e commit 69d9792
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 30 deletions.
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": "11.1.1-canary.13"
"version": "11.1.1-canary.14"
}
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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "11.1.1-canary.13",
"@next/eslint-plugin-next": "11.1.1-canary.14",
"@rushstack/eslint-patch": "^1.0.6",
"@typescript-eslint/parser": "^4.20.0",
"eslint-import-resolver-node": "^0.3.4",
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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default async function build(
telemetry.record(events)
)

const ignoreTypeScriptErrors = Boolean(config.typescript?.ignoreBuildErrors)
const ignoreTypeScriptErrors = Boolean(config.typescript.ignoreBuildErrors)
const typeCheckStart = process.hrtime()
const typeCheckingSpinner = createSpinner({
prefixText: `${Log.prefixes.info} ${
Expand Down Expand Up @@ -216,7 +216,7 @@ export default async function build(
typeCheckingSpinner.stopAndPersist()
}

const ignoreESLint = Boolean(config.eslint?.ignoreDuringBuilds)
const ignoreESLint = Boolean(config.eslint.ignoreDuringBuilds)
const eslintCacheDir = path.join(cacheDir, 'eslint/')
if (!ignoreESLint && runLint) {
await nextBuildSpan
Expand Down
4 changes: 4 additions & 0 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,17 @@ window.__NEXT_P = []
const headManager: {
mountedInstances: Set<unknown>
updateHead: (head: JSX.Element[]) => void
getIsSsr?: () => boolean
} = initHeadManager()
const appElement: HTMLElement | null = document.getElementById('__next')

let lastRenderReject: (() => void) | null
let webpackHMR: any
export let router: Router
let CachedApp: AppComponent, onPerfEntry: (metric: any) => void
headManager.getIsSsr = () => {
return router.isSsr
}

class Container extends React.Component<{
fn: (err: Error, info?: any) => void
Expand Down
7 changes: 5 additions & 2 deletions packages/next/client/script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Script(props: ScriptProps): JSX.Element | null {
} = props

// Context is available only during SSR
const { updateScripts, scripts } = useContext(HeadManagerContext)
const { updateScripts, scripts, getIsSsr } = useContext(HeadManagerContext)

useEffect(() => {
if (strategy === 'afterInteractive') {
Expand All @@ -161,7 +161,10 @@ function Script(props: ScriptProps): JSX.Element | null {
},
])
updateScripts(scripts)
} else {
} else if (getIsSsr && getIsSsr()) {
// Script has already loaded during SSR
LoadCache.add(restProps.id || src)
} else if (getIsSsr && !getIsSsr()) {
loadScript(props)
}
}
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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -66,10 +66,10 @@
"dependencies": {
"@babel/runtime": "7.15.3",
"@hapi/accept": "5.0.2",
"@next/env": "11.1.1-canary.13",
"@next/polyfill-module": "11.1.1-canary.13",
"@next/react-dev-overlay": "11.1.1-canary.13",
"@next/react-refresh-utils": "11.1.1-canary.13",
"@next/env": "11.1.1-canary.14",
"@next/polyfill-module": "11.1.1-canary.14",
"@next/react-dev-overlay": "11.1.1-canary.14",
"@next/react-refresh-utils": "11.1.1-canary.14",
"@node-rs/helper": "1.2.1",
"assert": "2.0.0",
"ast-types": "0.13.2",
Expand Down Expand Up @@ -154,7 +154,7 @@
"@babel/traverse": "7.15.0",
"@babel/types": "7.15.0",
"@napi-rs/cli": "1.1.0",
"@next/polyfill-nomodule": "11.1.1-canary.13",
"@next/polyfill-nomodule": "11.1.1-canary.14",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/next/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export interface ESLintConfig {
ignoreDuringBuilds?: boolean
}

export interface TypeScriptConfig {
/** Do not run TypeScript during production builds (`next build`). */
ignoreBuildErrors?: boolean
}

export type NextConfig = { [key: string]: any } & {
i18n?: I18NConfig | null

eslint?: ESLintConfig
typescript?: TypeScriptConfig

headers?: () => Promise<Header[]>
rewrites?: () => Promise<
Expand Down Expand Up @@ -139,6 +145,12 @@ export const defaultConfig: NextConfig = {
env: {},
webpack: null,
webpackDevMiddleware: null,
eslint: {
ignoreDuringBuilds: false,
},
typescript: {
ignoreBuildErrors: false,
},
distDir: '.next',
cleanDistDir: true,
assetPrefix: '',
Expand Down
1 change: 1 addition & 0 deletions packages/next/shared/lib/head-manager-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const HeadManagerContext: React.Context<{
mountedInstances?: any
updateScripts?: (state: any) => void
scripts?: any
getIsSsr?: () => boolean
}> = React.createContext({})

if (process.env.NODE_ENV !== 'production') {
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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"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": "11.1.1-canary.13",
"version": "11.1.1-canary.14",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
9 changes: 4 additions & 5 deletions test/integration/script-loader/pages/page3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ const Page = () => {
return (
<div class="container">
<Script id="inline-script">
{`(window.onload = function () {
const newDiv = document.createElement('div')
newDiv.id = 'onload-div'
document.querySelector('body').appendChild(newDiv)
})`}
{`const newDiv = document.createElement('div')
newDiv.id = 'onload-div'
document.querySelector('body').appendChild(newDiv)
`}
</Script>
<Script
id="scriptLazyOnload"
Expand Down
13 changes: 12 additions & 1 deletion test/integration/script-loader/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,25 @@ describe('Script Loader', () => {
try {
browser = await webdriver(appPort, '/')

// beforeInteractive scripts should load once
let documentBIScripts = await browser.elementsByCss(
'[src$="documentBeforeInteractive"]'
)
expect(documentBIScripts.length).toBe(1)

await browser.waitForElementByCss('[href="/page1"]')
await browser.click('[href="/page1"]')

await browser.waitForElementByCss('.container')
await waitFor(1000)

const script = await browser.elementById('scriptBeforeInteractive')

// Ensure beforeInteractive script isn't duplicated on navigation
documentBIScripts = await browser.elementsByCss(
'[src$="documentBeforeInteractive"]'
)
expect(documentBIScripts.length).toBe(1)

// Renders script tag
expect(script).toBeDefined()
} finally {
Expand Down

0 comments on commit 69d9792

Please sign in to comment.