From 3a1aa554c5fa5a95e2b4d408c1cbfee69f201cc1 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 14:18:42 +0100 Subject: [PATCH 01/10] Enable pages/404.js support (#10572) --- packages/next/next-server/server/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/next-server/server/config.ts b/packages/next/next-server/server/config.ts index 9d675c14d2ded..657f51022a9b7 100644 --- a/packages/next/next-server/server/config.ts +++ b/packages/next/next-server/server/config.ts @@ -53,7 +53,7 @@ const defaultConfig: { [key: string]: any } = { workerThreads: false, basePath: '', static404: true, - pages404: false, + pages404: true, }, future: { excludeDefaultMomentLocales: false, From 743bf5d3454ef9fccde30f63973c58e3d62c9888 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 14:35:12 +0100 Subject: [PATCH 02/10] Enable scss/sass support (#10571) Co-authored-by: Joe Haddad --- packages/next/next-server/server/config.ts | 2 +- test/integration/scss-fixtures/next.config.js | 1 - test/integration/typescript/next.config.js | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/next/next-server/server/config.ts b/packages/next/next-server/server/config.ts index 657f51022a9b7..962ead43c2402 100644 --- a/packages/next/next-server/server/config.ts +++ b/packages/next/next-server/server/config.ts @@ -42,7 +42,7 @@ const defaultConfig: { [key: string]: any } = { (os.cpus() || { length: 1 }).length) - 1 ), css: true, - scss: false, + scss: true, documentMiddleware: false, granularChunks: true, modern: false, diff --git a/test/integration/scss-fixtures/next.config.js b/test/integration/scss-fixtures/next.config.js index b97156a83b09e..2a0ee47afec3c 100644 --- a/test/integration/scss-fixtures/next.config.js +++ b/test/integration/scss-fixtures/next.config.js @@ -3,7 +3,6 @@ module.exports = { // Make sure entries are not getting disposed. maxInactiveAge: 1000 * 60 * 60, }, - experimental: { scss: true }, webpack(cfg) { cfg.devtool = 'source-map' return cfg diff --git a/test/integration/typescript/next.config.js b/test/integration/typescript/next.config.js index 5adba078e31d0..cc17cf48c578f 100644 --- a/test/integration/typescript/next.config.js +++ b/test/integration/typescript/next.config.js @@ -3,5 +3,4 @@ module.exports = { // Make sure entries are not getting disposed. maxInactiveAge: 1000 * 60 * 60, }, - experimental: { scss: true }, } From 5e23e3545655307576e7d2f827ba2b402889d69d Mon Sep 17 00:00:00 2001 From: Gordey Date: Tue, 18 Feb 2020 21:24:57 +0600 Subject: [PATCH 03/10] Add missin create permission for faunadb example (#10575) --- examples/with-graphql-faunadb/scripts/setup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-graphql-faunadb/scripts/setup.js b/examples/with-graphql-faunadb/scripts/setup.js index a313a6e0b631a..8b1f65045e19a 100644 --- a/examples/with-graphql-faunadb/scripts/setup.js +++ b/examples/with-graphql-faunadb/scripts/setup.js @@ -52,7 +52,7 @@ readline.question(`Please provide the FaunaDB admin key\n`, adminKey => { privileges: [ { resource: q.Collection('GuestbookEntry'), - actions: { read: true, write: true }, + actions: { read: true, write: true, create: true }, }, { resource: q.Index('entries'), From 04c5737e3c847f850bee672f863ed6be972d05a4 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 16:33:28 +0100 Subject: [PATCH 04/10] v9.2.3-canary.0 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-google-analytics/package.json | 2 +- packages/next-plugin-material-ui/package.json | 2 +- packages/next-plugin-sentry/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next/package.json | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lerna.json b/lerna.json index b3727d336277a..8db5ba4a1ec8e 100644 --- a/lerna.json +++ b/lerna.json @@ -12,5 +12,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "9.2.2" + "version": "9.2.3-canary.0" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 05b9d8e9e6bac..af8ac3035f785 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "9.2.2", + "version": "9.2.3-canary.0", "keywords": [ "react", "next", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index f81e4cdee06ab..d353bec9e1534 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "9.2.2", + "version": "9.2.3-canary.0", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 45da6718d3b7f..71c2fb7215c39 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "9.2.2", + "version": "9.2.3-canary.0", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-google-analytics/package.json b/packages/next-plugin-google-analytics/package.json index 0d1fe421fc04c..65b2d42f4cee1 100644 --- a/packages/next-plugin-google-analytics/package.json +++ b/packages/next-plugin-google-analytics/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-google-analytics", - "version": "9.2.2", + "version": "9.2.3-canary.0", "nextjs": { "name": "Google Analytics", "required-env": [ diff --git a/packages/next-plugin-material-ui/package.json b/packages/next-plugin-material-ui/package.json index e2e1f3019392f..b4b779c2f2157 100644 --- a/packages/next-plugin-material-ui/package.json +++ b/packages/next-plugin-material-ui/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-material-ui", - "version": "9.2.2", + "version": "9.2.3-canary.0", "nextjs": { "name": "Material UI", "required-env": [] diff --git a/packages/next-plugin-sentry/package.json b/packages/next-plugin-sentry/package.json index a700face8ea43..9210aa15db36e 100644 --- a/packages/next-plugin-sentry/package.json +++ b/packages/next-plugin-sentry/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-sentry", - "version": "9.2.2", + "version": "9.2.3-canary.0", "nextjs": { "name": "Sentry", "required-env": [ diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index d76ca1ed32b2a..61a0ee9dbe727 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "9.2.2", + "version": "9.2.3-canary.0", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next/package.json b/packages/next/package.json index 5ae1e9c5dea8f..f84528b5b61fb 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "9.2.2", + "version": "9.2.3-canary.0", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -74,7 +74,7 @@ "@babel/runtime": "7.7.2", "@babel/runtime-corejs2": "7.7.2", "@babel/types": "7.7.4", - "@next/polyfill-nomodule": "9.2.2", + "@next/polyfill-nomodule": "9.2.3-canary.0", "amphtml-validator": "1.0.23", "async-retry": "1.2.3", "async-sema": "3.0.0", From 72823f04e738a5e51786ce44976a498fad48653c Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 18 Feb 2020 12:22:51 -0500 Subject: [PATCH 05/10] Re-add Sass Docs (#10364) * Re-add Sass Docs * Update built-in-css-support.md * Apply lint-fix Co-authored-by: JJ Kasper --- docs/basic-features/built-in-css-support.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/basic-features/built-in-css-support.md b/docs/basic-features/built-in-css-support.md index e1848b6ca8384..7574eefe934eb 100644 --- a/docs/basic-features/built-in-css-support.md +++ b/docs/basic-features/built-in-css-support.md @@ -158,11 +158,23 @@ export default HelloWorld Please see the [styled-jsx documentation](https://github.com/zeit/styled-jsx) for more examples. -## Sass, Less and Stylus Support +## Sass Support -To support importing `.scss`, `.sass`, `.less`, or `.styl` files you can use the following plugins: +Next.js allows you to import Sass using both the `.scss` and `.sass` extensions. +You can use component-level Sass via CSS Modules and the `.module.scss` or `.module.sass` extension. + +Before you can use Next.js' built-in Sass support, be sure to install [`sass`](https://github.com/sass/sass): + +```bash +npm install sass +``` + +Sass support has the same benefits and restrictions as the built-in CSS support detailed above. + +## Less and Stylus Support + +To support importing `.less` or `.styl` files you can use the following plugins: -- [@zeit/next-sass](https://github.com/zeit/next-plugins/tree/master/packages/next-sass) - [@zeit/next-less](https://github.com/zeit/next-plugins/tree/master/packages/next-less) - [@zeit/next-stylus](https://github.com/zeit/next-plugins/tree/master/packages/next-stylus) From 0222a09cd0f631f54a15a91ac01512e97269426e Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 19:26:55 +0100 Subject: [PATCH 06/10] Enable polyfillsOptimization (#10574) * Enable polyfillsOptimization * Update sizes * Commons is no longer there * Update test --- packages/next/build/babel/preset.ts | 6 +-- packages/next/build/webpack-config.ts | 44 ++----------------- .../webpack/loaders/next-babel-loader.js | 6 +-- packages/next/client/index.js | 17 ++----- packages/next/client/polyfills-nomodule.js | 1 - packages/next/client/polyfills.js | 4 +- packages/next/package.json | 5 +-- packages/next/taskfile-babel.js | 5 --- .../bundle-size-profiling/next.config.js | 3 -- .../modern-mode/test/index.test.js | 9 +--- .../polyfilling-minimal/next.config.js | 6 +-- .../integration/size-limit/test/index.test.js | 4 +- test/unit/next-babel.test.js | 2 +- yarn.lock | 10 +---- 14 files changed, 18 insertions(+), 104 deletions(-) delete mode 100644 packages/next/client/polyfills-nomodule.js diff --git a/packages/next/build/babel/preset.ts b/packages/next/build/babel/preset.ts index 6980c11c4b8dd..a244e4e00ae6b 100644 --- a/packages/next/build/babel/preset.ts +++ b/packages/next/build/babel/preset.ts @@ -64,9 +64,7 @@ module.exports = ( const supportsESM = api.caller(supportsStaticESM) const isServer = api.caller((caller: any) => !!caller && caller.isServer) const isModern = api.caller((caller: any) => !!caller && caller.isModern) - const isPolyfillsOptimization = api.caller( - (caller: any) => !!caller && caller.polyfillsOptimization - ) + const isLaxModern = isModern || (options['preset-env']?.targets && @@ -155,7 +153,7 @@ module.exports = ( !isServer && [ require('@babel/plugin-transform-runtime'), { - corejs: isPolyfillsOptimization ? false : 2, + corejs: false, helpers: true, regenerator: true, useESModules: supportsESM && presetEnvConfig.modules !== 'commonjs', diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 5799e871ab3c0..c65cdb2caf031 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -54,10 +54,7 @@ const escapePathVariables = (value: any) => { : value } -function getOptimizedAliases( - isServer: boolean, - polyfillsOptimization: boolean -): { [pkg: string]: string } { +function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } { if (isServer) { return {} } @@ -68,12 +65,6 @@ function getOptimizedAliases( const shimAssign = path.join(__dirname, 'polyfills', 'object.assign') return Object.assign( {}, - // Polyfill: Window#fetch - polyfillsOptimization - ? undefined - : { - __next_polyfill__fetch: require.resolve('whatwg-fetch'), - }, { unfetch$: stubWindowFetch, 'isomorphic-unfetch$': stubWindowFetch, @@ -84,13 +75,6 @@ function getOptimizedAliases( 'whatwg-fetch.js' ), }, - polyfillsOptimization - ? undefined - : { - // Polyfill: Object.assign - __next_polyfill__object_assign: require.resolve('object-assign'), - '@babel/runtime-corejs2/core-js/object/assign': stubObjectAssign, - }, { 'object-assign$': stubObjectAssign, @@ -168,7 +152,6 @@ export default async function getBaseWebpackConfig( babelPresetPlugins, hasModern: !!config.experimental.modern, development: dev, - polyfillsOptimization: !!config.experimental.polyfillsOptimization, }, }, // Backwards compat @@ -215,9 +198,7 @@ export default async function getBaseWebpackConfig( ), [CLIENT_STATIC_FILES_RUNTIME_POLYFILLS]: path.join( NEXT_PROJECT_ROOT_DIST_CLIENT, - config.experimental.polyfillsOptimization - ? 'polyfills-nomodule.js' - : 'polyfills.js' + 'polyfills.js' ), } as ClientEntries) : undefined @@ -267,17 +248,7 @@ export default async function getBaseWebpackConfig( next: NEXT_PROJECT_ROOT, [PAGES_DIR_ALIAS]: pagesDir, [DOT_NEXT_ALIAS]: distDir, - ...getOptimizedAliases( - isServer, - !!config.experimental.polyfillsOptimization - ), - - // Temporary to allow runtime-corejs2 to be stubbed in experimental polyfillsOptimization - ...(config.experimental.polyfillsOptimization - ? { - '@babel/runtime-corejs2': '@babel/runtime', - } - : undefined), + ...getOptimizedAliases(isServer), }, mainFields: isServer ? ['main', 'module'] : ['browser', 'module', 'main'], plugins: [PnpWebpackPlugin], @@ -528,11 +499,7 @@ export default async function getBaseWebpackConfig( !res.match(/next[/\\]dist[/\\]next-server[/\\]/) && (res.match(/[/\\]next[/\\]dist[/\\]/) || // This is the @babel/plugin-transform-runtime "helpers: true" option - res.match(/node_modules[/\\]@babel[/\\]runtime[/\\]/) || - (!config.experimental.polyfillsOptimization && - res.match( - /node_modules[/\\]@babel[/\\]runtime-corejs2[/\\]/ - ))) + res.match(/node_modules[/\\]@babel[/\\]runtime[/\\]/)) ) { return callback() } @@ -728,9 +695,6 @@ export default async function getBaseWebpackConfig( 'process.env.__NEXT_MODERN_BUILD': JSON.stringify( config.experimental.modern && !dev ), - 'process.env.__NEXT_POLYFILLS_OPTIMIZATION': JSON.stringify( - !!config.experimental.polyfillsOptimization - ), 'process.env.__NEXT_GRANULAR_CHUNKS': JSON.stringify( config.experimental.granularChunks && !dev ), diff --git a/packages/next/build/webpack/loaders/next-babel-loader.js b/packages/next/build/webpack/loaders/next-babel-loader.js index 8faf81c78fa77..91e71f573730c 100644 --- a/packages/next/build/webpack/loaders/next-babel-loader.js +++ b/packages/next/build/webpack/loaders/next-babel-loader.js @@ -59,7 +59,6 @@ module.exports = babelLoader.custom(babel => { hasModern: opts.hasModern, babelPresetPlugins: opts.babelPresetPlugins, development: opts.development, - polyfillsOptimization: opts.polyfillsOptimization, } const filename = join(opts.cwd, 'noop.js') const loader = Object.assign( @@ -72,7 +71,7 @@ module.exports = babelLoader.custom(babel => { (opts.isServer ? '-server' : '') + (opts.isModern ? '-modern' : '') + (opts.hasModern ? '-has-modern' : '') + - (opts.polyfillsOptimization ? '-new-polyfills' : '') + + '-new-polyfills' + (opts.development ? '-development' : '-production') + JSON.stringify( babel.loadPartialConfig({ @@ -95,7 +94,6 @@ module.exports = babelLoader.custom(babel => { delete loader.hasModern delete loader.pagesDir delete loader.babelPresetPlugins - delete loader.polyfillsOptimization delete loader.development return { loader, custom } }, @@ -110,7 +108,6 @@ module.exports = babelLoader.custom(babel => { pagesDir, babelPresetPlugins, development, - polyfillsOptimization, }, } ) { @@ -134,7 +131,6 @@ module.exports = babelLoader.custom(babel => { options.caller.isServer = isServer options.caller.isModern = isModern - options.caller.polyfillsOptimization = polyfillsOptimization options.caller.isDev = development options.plugins = options.plugins || [] diff --git a/packages/next/client/index.js b/packages/next/client/index.js index c69fedcff8c84..8cd2473aa15c6 100644 --- a/packages/next/client/index.js +++ b/packages/next/client/index.js @@ -14,20 +14,9 @@ import { isDynamicRoute } from '../next-server/lib/router/utils/is-dynamic' /// -if (process.env.__NEXT_POLYFILLS_OPTIMIZATION) { - if (!('finally' in Promise.prototype)) { - // eslint-disable-next-line no-extend-native - Promise.prototype.finally = require('finally-polyfill') - } -} else { - // Polyfill Promise globally - // This is needed because Webpack's dynamic loading(common chunks) code - // depends on Promise. - // So, we need to polyfill it. - // See: https://webpack.js.org/guides/code-splitting/#dynamic-imports - if (!self.Promise) { - self.Promise = require('@babel/runtime-corejs2/core-js/promise') - } +if (!('finally' in Promise.prototype)) { + // eslint-disable-next-line no-extend-native + Promise.prototype.finally = require('finally-polyfill') } const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent) diff --git a/packages/next/client/polyfills-nomodule.js b/packages/next/client/polyfills-nomodule.js deleted file mode 100644 index 5682d2a0577ab..0000000000000 --- a/packages/next/client/polyfills-nomodule.js +++ /dev/null @@ -1 +0,0 @@ -import '@next/polyfill-nomodule' diff --git a/packages/next/client/polyfills.js b/packages/next/client/polyfills.js index 49e4345b6e602..5682d2a0577ab 100644 --- a/packages/next/client/polyfills.js +++ b/packages/next/client/polyfills.js @@ -1,3 +1 @@ -import '__next_polyfill__fetch' -import 'url-polyfill' -Object.assign = require('__next_polyfill__object_assign') +import '@next/polyfill-nomodule' diff --git a/packages/next/package.json b/packages/next/package.json index f84528b5b61fb..d2e796d1a9723 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -72,7 +72,6 @@ "@babel/preset-react": "7.7.0", "@babel/preset-typescript": "7.7.2", "@babel/runtime": "7.7.2", - "@babel/runtime-corejs2": "7.7.2", "@babel/types": "7.7.4", "@next/polyfill-nomodule": "9.2.3-canary.0", "amphtml-validator": "1.0.23", @@ -117,7 +116,6 @@ "mini-css-extract-plugin": "0.8.0", "mkdirp": "0.5.1", "node-fetch": "2.6.0", - "object-assign": "4.1.1", "ora": "3.4.0", "path-to-regexp": "6.1.0", "pnp-webpack-plugin": "1.5.0", @@ -148,8 +146,7 @@ "webpack": "4.41.2", "webpack-dev-middleware": "3.7.0", "webpack-hot-middleware": "2.25.0", - "webpack-sources": "1.4.3", - "whatwg-fetch": "3.0.0" + "webpack-sources": "1.4.3" }, "peerDependencies": { "react": "^16.6.0", diff --git a/packages/next/taskfile-babel.js b/packages/next/taskfile-babel.js index d31ced3d8bde1..7c49c16968c97 100644 --- a/packages/next/taskfile-babel.js +++ b/packages/next/taskfile-babel.js @@ -95,11 +95,6 @@ module.exports = function(task) { const output = transform(file.data, options) const ext = extname(file.base) - output.code = output.code.replace( - /@babel\/runtime\//g, - '@babel/runtime-corejs2/' - ) - // Replace `.ts|.tsx` with `.js` in files with an extension if (ext) { const extRegex = new RegExp(ext.replace('.', '\\.') + '$', 'i') diff --git a/test/integration/bundle-size-profiling/next.config.js b/test/integration/bundle-size-profiling/next.config.js index 4d15dcc1bb368..484d359b92306 100644 --- a/test/integration/bundle-size-profiling/next.config.js +++ b/test/integration/bundle-size-profiling/next.config.js @@ -1,7 +1,4 @@ module.exports = { - experimental: { - polyfillsOptimization: true, - }, webpack(config, options) { if (!options.isServer) { config.profile = true diff --git a/test/integration/modern-mode/test/index.test.js b/test/integration/modern-mode/test/index.test.js index 52ae6c8324d4c..2d73aa8de1dd5 100644 --- a/test/integration/modern-mode/test/index.test.js +++ b/test/integration/modern-mode/test/index.test.js @@ -40,14 +40,7 @@ describe('Modern Mode', () => { it('should generate client side modern and legacy build files', async () => { const buildId = readFileSync(join(appDir, '.next/BUILD_ID'), 'utf8') - const expectedFiles = [ - 'index', - '_app', - '_error', - 'main', - 'webpack', - 'commons', - ] + const expectedFiles = ['index', '_app', '_error', 'main', 'webpack'] const buildFiles = [ ...readdirSync(join(appDir, '.next/static', buildId, 'pages')), ...readdirSync(join(appDir, '.next/static/runtime')).map( diff --git a/test/integration/polyfilling-minimal/next.config.js b/test/integration/polyfilling-minimal/next.config.js index 92edca3df0328..4ba52ba2c8df6 100644 --- a/test/integration/polyfilling-minimal/next.config.js +++ b/test/integration/polyfilling-minimal/next.config.js @@ -1,5 +1 @@ -module.exports = { - experimental: { - polyfillsOptimization: true, - }, -} +module.exports = {} diff --git a/test/integration/size-limit/test/index.test.js b/test/integration/size-limit/test/index.test.js index 5cec5c5e90726..7a2fc3f4ea534 100644 --- a/test/integration/size-limit/test/index.test.js +++ b/test/integration/size-limit/test/index.test.js @@ -80,7 +80,7 @@ describe('Production response size', () => { ) // These numbers are without gzip compression! - const delta = responseSizesBytes - 233 * 1024 + const delta = responseSizesBytes - 241 * 1024 expect(delta).toBeLessThanOrEqual(1024) // don't increase size more than 1kb expect(delta).toBeGreaterThanOrEqual(-1024) // don't decrease size more than 1kb without updating target }) @@ -100,7 +100,7 @@ describe('Production response size', () => { ) // These numbers are without gzip compression! - const delta = responseSizesBytes - 201 * 1024 + const delta = responseSizesBytes - 171 * 1024 expect(delta).toBeLessThanOrEqual(1024) // don't increase size more than 1kb expect(delta).toBeGreaterThanOrEqual(-1024) // don't decrease size more than 1kb without updating target }) diff --git a/test/unit/next-babel.test.js b/test/unit/next-babel.test.js index ecd76a2d0c903..5dddb43b3f48c 100644 --- a/test/unit/next-babel.test.js +++ b/test/unit/next-babel.test.js @@ -69,7 +69,7 @@ describe('next/babel', () => { expect(output).toMatch(`__jsx("a",{href:"/"`) expect(babel(`const a = ()=>home`)).toMatchInlineSnapshot( - `"\\"use strict\\";var _interopRequireDefault=require(\\"@babel/runtime-corejs2/helpers/interopRequireDefault\\");var _react=_interopRequireDefault(require(\\"react\\"));var __jsx=_react[\\"default\\"].createElement;var a=function a(){return __jsx(\\"a\\",{href:\\"/\\"},\\"home\\");};"` + `"\\"use strict\\";var _interopRequireDefault=require(\\"@babel/runtime/helpers/interopRequireDefault\\");var _react=_interopRequireDefault(require(\\"react\\"));var __jsx=_react[\\"default\\"].createElement;var a=function a(){return __jsx(\\"a\\",{href:\\"/\\"},\\"home\\");};"` ) }) diff --git a/yarn.lock b/yarn.lock index 4685fc13441d7..56b5c8032f164 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1036,14 +1036,6 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-typescript" "^7.7.4" -"@babel/runtime-corejs2@7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.7.2.tgz#5a8c4e2f8688ce58adc9eb1d8320b6e7341f96ce" - integrity sha512-GfVnHchOBvIMsweQ13l4jd9lT4brkevnavnVOej5g2y7PpTRY+R4pcQlCjWMZoUla5rMLFzaS/Ll2s59cB1TqQ== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.2" - "@babel/runtime@7.7.2": version "7.7.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.2.tgz#111a78002a5c25fc8e3361bedc9529c696b85a6a" @@ -1099,7 +1091,7 @@ globals "^11.1.0" lodash "^4.17.13" -"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.1", "@babel/types@^7.7.2", "@babel/types@^7.7.4": +"@babel/types@7.7.4", "@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.1", "@babel/types@^7.7.2", "@babel/types@^7.7.4": version "7.7.4" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.4.tgz#516570d539e44ddf308c07569c258ff94fde9193" integrity sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA== From b5c70e86392c1aaf679a0de394059a095f4e52df Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 19:36:48 +0100 Subject: [PATCH 07/10] Revert "Re-add Sass Docs (#10364)" (#10577) This reverts commit 72823f04e738a5e51786ce44976a498fad48653c. --- docs/basic-features/built-in-css-support.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/basic-features/built-in-css-support.md b/docs/basic-features/built-in-css-support.md index 7574eefe934eb..e1848b6ca8384 100644 --- a/docs/basic-features/built-in-css-support.md +++ b/docs/basic-features/built-in-css-support.md @@ -158,23 +158,11 @@ export default HelloWorld Please see the [styled-jsx documentation](https://github.com/zeit/styled-jsx) for more examples. -## Sass Support +## Sass, Less and Stylus Support -Next.js allows you to import Sass using both the `.scss` and `.sass` extensions. -You can use component-level Sass via CSS Modules and the `.module.scss` or `.module.sass` extension. - -Before you can use Next.js' built-in Sass support, be sure to install [`sass`](https://github.com/sass/sass): - -```bash -npm install sass -``` - -Sass support has the same benefits and restrictions as the built-in CSS support detailed above. - -## Less and Stylus Support - -To support importing `.less` or `.styl` files you can use the following plugins: +To support importing `.scss`, `.sass`, `.less`, or `.styl` files you can use the following plugins: +- [@zeit/next-sass](https://github.com/zeit/next-plugins/tree/master/packages/next-sass) - [@zeit/next-less](https://github.com/zeit/next-plugins/tree/master/packages/next-less) - [@zeit/next-stylus](https://github.com/zeit/next-plugins/tree/master/packages/next-stylus) From c706e1af842b8652f4b127f2100692bd144e4864 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 18 Feb 2020 20:04:41 +0100 Subject: [PATCH 08/10] v9.2.3-canary.1 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-google-analytics/package.json | 2 +- packages/next-plugin-material-ui/package.json | 2 +- packages/next-plugin-sentry/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next/package.json | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lerna.json b/lerna.json index 8db5ba4a1ec8e..2d50b980a4c5f 100644 --- a/lerna.json +++ b/lerna.json @@ -12,5 +12,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "9.2.3-canary.0" + "version": "9.2.3-canary.1" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index af8ac3035f785..d03ba18f9001c 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "keywords": [ "react", "next", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index d353bec9e1534..be2b25d5c7f66 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 71c2fb7215c39..0a82ef32af76b 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-google-analytics/package.json b/packages/next-plugin-google-analytics/package.json index 65b2d42f4cee1..856506f8146fa 100644 --- a/packages/next-plugin-google-analytics/package.json +++ b/packages/next-plugin-google-analytics/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-google-analytics", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "nextjs": { "name": "Google Analytics", "required-env": [ diff --git a/packages/next-plugin-material-ui/package.json b/packages/next-plugin-material-ui/package.json index b4b779c2f2157..fb60cce758481 100644 --- a/packages/next-plugin-material-ui/package.json +++ b/packages/next-plugin-material-ui/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-material-ui", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "nextjs": { "name": "Material UI", "required-env": [] diff --git a/packages/next-plugin-sentry/package.json b/packages/next-plugin-sentry/package.json index 9210aa15db36e..2a3c2e942ecdf 100644 --- a/packages/next-plugin-sentry/package.json +++ b/packages/next-plugin-sentry/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-sentry", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "nextjs": { "name": "Sentry", "required-env": [ diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 61a0ee9dbe727..e95420fbc1804 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next/package.json b/packages/next/package.json index d2e796d1a9723..53ba03a3eb0c3 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "9.2.3-canary.0", + "version": "9.2.3-canary.1", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -73,7 +73,7 @@ "@babel/preset-typescript": "7.7.2", "@babel/runtime": "7.7.2", "@babel/types": "7.7.4", - "@next/polyfill-nomodule": "9.2.3-canary.0", + "@next/polyfill-nomodule": "9.2.3-canary.1", "amphtml-validator": "1.0.23", "async-retry": "1.2.3", "async-sema": "3.0.0", From c66f2f757c042847db44fe15fe31e3cf0e75da0d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 18 Feb 2020 14:11:52 -0600 Subject: [PATCH 09/10] Decrease number of expected preloads in safari (#10578) --- test/integration/production/test/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index a0f198f583e9c..e66fa416a6a58 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -477,7 +477,7 @@ describe('Production Usage', () => { if (browserName === 'safari') { const elements = await browser.elementsByCss('link[rel=preload]') // 4 page preloads and 5 existing preloads for _app, commons, main, etc - expect(elements.length).toBe(13) + expect(elements.length).toBe(11) } else { const elements = await browser.elementsByCss('link[rel=prefetch]') expect(elements.length).toBe(4) From db04cc57c1dfbaaabdc2935dc1769e4cc253fb6e Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 18 Feb 2020 15:28:29 -0600 Subject: [PATCH 10/10] Make sure to handle rejection when prefetching pages (#10579) * Make sure to handle rejection when prefetching pages * Update comment * Make sure to show prefetch error in development still --- packages/next/client/link.tsx | 10 +++++++++- .../preload-viewport/pages/invalid-prefetch.js | 9 +++++++++ .../preload-viewport/test/index.test.js | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/integration/preload-viewport/pages/invalid-prefetch.js diff --git a/packages/next/client/link.tsx b/packages/next/client/link.tsx index d45531791a95f..9f846681accb0 100644 --- a/packages/next/client/link.tsx +++ b/packages/next/client/link.tsx @@ -209,7 +209,15 @@ class Link extends Component { if (!this.p || typeof window === 'undefined') return // Prefetch the JSON page if asked (only in the client) const [href, asPath] = this.getPaths() - Router.prefetch(href, asPath, options) + // We need to handle a prefetch error here since we may be + // loading with priority which can reject but we don't + // want to force navigation since this is only a prefetch + Router.prefetch(href, asPath, options).catch(err => { + if (process.env.NODE_ENV !== 'production') { + // rethrow to show invalid URL errors + throw err + } + }) prefetched[href] = true } diff --git a/test/integration/preload-viewport/pages/invalid-prefetch.js b/test/integration/preload-viewport/pages/invalid-prefetch.js new file mode 100644 index 0000000000000..a01f7638d841d --- /dev/null +++ b/test/integration/preload-viewport/pages/invalid-prefetch.js @@ -0,0 +1,9 @@ +import Link from 'next/link' + +export default () => ( + <> + + I'm broken... + + +) diff --git a/test/integration/preload-viewport/test/index.test.js b/test/integration/preload-viewport/test/index.test.js index 81b035e2dbe85..0df30ea2464f5 100644 --- a/test/integration/preload-viewport/test/index.test.js +++ b/test/integration/preload-viewport/test/index.test.js @@ -163,6 +163,21 @@ describe('Prefetching Links in viewport', () => { } }) + it('should not have unhandledRejection when failing to prefetch on link', async () => { + const browser = await webdriver(appPort, '/') + await browser.eval(`(function() { + window.addEventListener('unhandledrejection', function (err) { + window.hadUnhandledReject = true; + }) + window.next.router.push('/invalid-prefetch'); + })()`) + + expect(await browser.eval('window.hadUnhandledReject')).toBeFalsy() + + await browser.elementByCss('#invalid-link').moveTo() + expect(await browser.eval('window.hadUnhandledReject')).toBeFalsy() + }) + it('should not prefetch when prefetch is explicitly set to false', async () => { const browser = await webdriver(appPort, '/opt-out')