diff --git a/lerna.json b/lerna.json index 3f04044ac8dd..0d8fbcd8427b 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "11.1.1-canary.13" + "version": "11.1.1-canary.14" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 0bbf50b71d70..576175ffdeca 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "11.1.1-canary.13", + "version": "11.1.1-canary.14", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 3ddc47a29269..0bf87f2b2226 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -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", @@ -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", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 7387076b5f59..f7e31c64a34b 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -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", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 1e7765a95716..afcea6cef2ef 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -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": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 8d889390c1f4..57b258ed2999 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -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", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 3498aa1d9167..a40e64be8c45 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "11.1.1-canary.13", + "version": "11.1.1-canary.14", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index e99f4c7e6f2b..07b3d75e96d5 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -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": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 9ea931290b2c..48b736978878 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -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" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index fb583ba3f4ff..c61f66a61ed2 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -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", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index e9737db02291..b75be468a787 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -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", diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 061b19351fe1..cf26b1dfcd9f 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -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} ${ @@ -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 diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index 26a2386dd891..86bdc3f6a275 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -156,6 +156,7 @@ window.__NEXT_P = [] const headManager: { mountedInstances: Set updateHead: (head: JSX.Element[]) => void + getIsSsr?: () => boolean } = initHeadManager() const appElement: HTMLElement | null = document.getElementById('__next') @@ -163,6 +164,9 @@ 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 diff --git a/packages/next/client/script.tsx b/packages/next/client/script.tsx index bd26a8b85733..302991bf3468 100644 --- a/packages/next/client/script.tsx +++ b/packages/next/client/script.tsx @@ -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') { @@ -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) } } diff --git a/packages/next/package.json b/packages/next/package.json index 254800426912..7f866b711c7e 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -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", @@ -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", @@ -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", diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index 48d577978e2f..d62edf36c62b 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -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 rewrites?: () => Promise< @@ -139,6 +145,12 @@ export const defaultConfig: NextConfig = { env: {}, webpack: null, webpackDevMiddleware: null, + eslint: { + ignoreDuringBuilds: false, + }, + typescript: { + ignoreBuildErrors: false, + }, distDir: '.next', cleanDistDir: true, assetPrefix: '', diff --git a/packages/next/shared/lib/head-manager-context.ts b/packages/next/shared/lib/head-manager-context.ts index 6a0c85acfbd7..7388a1da7b09 100644 --- a/packages/next/shared/lib/head-manager-context.ts +++ b/packages/next/shared/lib/head-manager-context.ts @@ -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') { diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index a5d5a097bfe0..a53af7fd39c9 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -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", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 002499bc94c3..c0c0d745dd04 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -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", diff --git a/test/integration/script-loader/pages/page3.js b/test/integration/script-loader/pages/page3.js index 58453214b172..592bd84b16fe 100644 --- a/test/integration/script-loader/pages/page3.js +++ b/test/integration/script-loader/pages/page3.js @@ -4,11 +4,10 @@ const Page = () => { return (