Commit graph

450 commits

Author SHA1 Message Date
JJ Kasper
5422ee04be Update to replace asPath for static pages in dev mode (#8388)
* Update to replace asPath for static pages in dev mode

* Run lint-fix

* Simplify test a bit
2019-08-16 12:53:47 -04:00
Luis Fernando Alvarez D
0b15540a48 Don't look up for TS files in dev (#8374)
* Only read for typescript files if there's no tsconfig

* Update verifyTypeScriptSetup.ts

* Remove the recursive check for TS files

* Remove unused import

* Updated tests

* Add a check for the content of tsConfig

* Clean up

* utf8
2019-08-15 11:27:02 -04:00
Joe Haddad
3c611822ab
Create a unique instance of transform-define (#8371) 2019-08-14 14:10:55 -04:00
JJ Kasper
874b5338d2 Add tests for typeof window replacing (#8361)
* Add tests for typeof window replacing

* Update test for typeof window replace from a node_module
2019-08-13 22:44:10 -04:00
JJ Kasper
7c09f713ca Fix chunking tests failing from timeout being too low (#8360) 2019-08-13 21:50:34 -04:00
JJ Kasper
57d91f7d38 Fix AppTree type not allowing extra props (#8352) 2019-08-13 16:15:44 -04:00
JJ Kasper
8c19d78a08 Also provide AppTree in NextPageContext (#8223)
* Also provide AppTree in NextPageContext

* Don't predefine AppTree as null in ctx

* Make update smaller

* Don’t reassign variable

* Add test for AppTree in NextPageContext

* Update utils.ts
2019-08-13 11:33:48 +02:00
Lukáš Huvar
7e1d54cc09 Add warning for disabled minification during build (#8337)
* Add warning for disabled minification

* Adding err.sh

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove example

* Update packages/next/build/index.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Update index.test.js
2019-08-12 23:13:12 -04:00
Alex Castle
3b31f957a1 Use 'initial' setting for SplitChunksPlugin (#8293)
* Use 'initial' setting for SplitChunksPlugin

* Initial chunking integration test shell

* Create integration tests for granular chunks build output
2019-08-12 20:35:33 -04:00
JJ Kasper
9993092ddd Add test for AMP errors during auto prerendering (#8335)
* Add test for AMP errors during auto-prerendering

* bump

* Add stats-app config for dynamic port

* bump

* bump
2019-08-12 17:13:41 -04:00
Joe Haddad
ab0384deef Fix TypeScript setup with empty file (#8332)
New versions of TypeScript now throw an error when no matching TypeScript files are found. We still want to setup in this case.

-----

Closes #8324
2019-08-12 11:40:53 +02:00
Natalie Marleny
06876f1be0 fix: Warn when user specifies prefetch option as true (#8233)
* Warn when user specifies prefetch option as `true`

* Update index.test.js
2019-08-12 00:26:25 -04:00
JJ Kasper
77c5e36ba7 Escape output names for modern bundles to prevent replacing (#8232)
* Escape output names for modern bundles

* Update escaping for modern bundle
2019-08-11 23:32:18 -04:00
Adam Misiorny
3eca88609a Prevent false positive experimental warning (#8284)
* Prevent false positive experimental warning

* Add tests for experimental warning
2019-08-11 22:26:37 -04:00
JJ Kasper
fc7e235f2c Followup optimizations for new experimentalPrerender (#8287)
* Add checking for hybrid AMP during static check

* Update to always hit server for prerender data

* Add removing of SPR code when not used

* Add checking for hybrid AMP during static check

* Update to always hit server for prerender data

* Add removing of SPR code when not used

* Update dead code elimination
2019-08-11 21:56:57 -04:00
Luis Fernando Alvarez D
36aabe05a2 Show warning if next export detects an API route (#8257)
* Throw error if next export detects an api route

* Moved the test to the export tests

* Added missing comma

* Move the API route comment

* Add comma after replace

* Show a warning instead
2019-08-12 00:37:20 +02:00
Lukáš Huvar
869bf0f16c Remove 405 from render method (#8323)
* Revert 405 on pages

* Modify tests
2019-08-11 15:42:40 +02:00
JJ Kasper
a4889f964e
Update handling of ref in next/link (#8254) 2019-08-08 13:11:17 -05:00
Alex Castle
3e8b36e879 Experimental: Granular build chunking (#7696)
* Refactor SplitChunksPlugin configs and add experimental chunking strategy

* Use typeDefs for SplitChunksConfig

* Modify build manifest plugin to create runtime build manifest

* Add support for granular chunks to page-loader

* Ensure normal behavior if experimental granularChunks flag is false

* Update client build manifest to remove iife & implicit global

* Factor out '/_next/' prepending into getDependencies

* Update packages/next/build/webpack-config.ts filepath regex

Co-Authored-By: Jason Miller <developit@users.noreply.github.com>

* Simplify dependency load ordering in page-loader.js

* Use SHA1 hash to shorten filenames for dependency modules

* Add scheduler to framework cacheGroup in webpack-config

* Update page loader to not duplicate script tags with query parameters

* Ensure no slashes end up in the file hashes

* Add prop-types to framework chunk

* Fix issue with mis-attributed events

* Increase modern build size budget--possibly decrement after consulting with @janicklasralph

* Use module.rawRequest for lib chunks

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Dasherize lib chunk names

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Fix typescript errors, reorganize lib name logic

* Dasherize rawRequest, short circuit name logic when rawRequest found

* Add `scheduler` package to test regex

* Fix a nit

* Adjust build manifest plugin

* Shorten key name

* Extract createPreloadLink helper

* Extract getDependencies helper

* Move method

* Minimize diff

* Minimize diff x2

* Fix Array.from polyfill

* Simplify page loader code

* Remove async=false for script tags

* Code golf `getDependencies` implementation

* Require lib chunks be in node_modules

* Update packages/next/build/webpack-config.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Replace remaining missed windows compat regex

* Trim client manifest

* Prevent duplicate link preload tags

* Revert size test changes

* Squash manifest size even further

* Add comment for clarity

* Code golfing 🏌️‍♂️

* Correctly select modern dependencies

* Ship separate modern client manifest when module/module enabled

* Update packages/next/build/webpack/plugins/build-manifest-plugin.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove unneccessary filter from page-loader

* Add lookbehind to file extension regex in page-loader

* v9.0.3

* Update examples for Apollo with AppTree (#8180)

* Update examples for Apollo with AppTree

* Fix apolloClient being overwritten when rendering AppTree

* Golf page-loader (#8190)

* Remove lookbehind for module replacement

* Wait for build manifest promise before page load or prefetch

* Updating modern-only chunks inside the right entry point

* Fixing ts errors

* Rename variable

* Revert "Wait for build manifest promise before page load or prefetch"

This reverts commit c370528c6888ba7fa71162a0854534ed280224ef.

* Use proper typedef for webpack chunk

* Re-enable promisified client build manifest

* Fix bug in getDependencies map

* Insert check for granularChunks in page-loader

* Increase size limit temporarily for granular chunks

* Add 50ms delay to flaky test

* Set env.__NEXT_GRANULAR_CHUNKS in webpack config

* Reset size limit to 187

* Set process.env.__NEXT_GRANULAR_CHUNKS to false if selectivePageBuilding

* Update test/integration/production/test/index.test.js

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Do not create promise if not using chunking PR
2019-08-08 13:14:33 -04:00
Jason Miller
fa5be4971a Bugfix: Babel targets value can be a String (#8268)
* Fix modern SSR build when Babel configuration uses a String value for "targets". Fixes #8255.

* Add custom babelrc integration tests
2019-08-08 15:38:51 +02:00
JJ Kasper
8e4509caf2 Add warning for invalid href being passed to router (#8231)
* Add warning for bad href being passed to router

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Inline invalidHref for better code elimination
2019-08-07 10:47:13 -04:00
JJ Kasper
ca13752e24
Implement experimentalPrerender option (#7983)
* Revert "Remove Old Prerender Implementation (#8218)"

This reverts commit 2ab300dd81.

* Add contentHandler for page config

* Rename config from contentHandler to re-use
experimentalPrerender

* Remove un-needed changes

* Replace backslashes for manifest

* Update manifest output format

* Make prerender: true enable SPR behavior and update
to merge prerender-manifest for flying-shuttle

* Fix output path for / prerender file

* Add dynamic routes to test suite

* Add generating and previewing of skeletons
for prerendered dynamic routes

* remove inline prerender option

* update to not replace getInitialProps which allows
nested getInitialProps and add query when fetching prerender

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove legacy prerender option

* Apply suggestions from review

* Apply more suggestions from review

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Add handling of error when parsing json

* Update handling of moving exported pages

* Rename nextPreviewSkeleton to _nextPreviewSkeleton

* bump
2019-08-06 15:26:01 -05:00
Lukáš Huvar
abcaba7f7d
Add warning for API export (#8250) 2019-08-06 00:46:02 +02:00
Joe Haddad
b31c296730
Experimental: Serverless Trace target (#8246)
* Experimental: Serverless Trace target
The Serverless Trace target produces Serverless-handler wrapped entrypoints, but does not bundle all of `node_modules`.

This behavior increases bundling performance to be more akin to `target: 'server'`.

This mode is expected to be used with smart platforms (like [ZEIT Now](https://zeit.co/now) that can trace a program to its minimum dependencies.

* Use more generic variables

* Add asset relocator for production mode of serverless trace

* Verify Firebase compatiblity

* Revert "Add asset relocator for production mode of serverless trace"

This reverts commit 8404f1dcf28b60edab41a56c94b38dcd3fddec20.

* Add serverless trace tests

* Add _isLikeServerless helper

* Make constants

* Fix export

* Update packages/next-server/server/config.ts

Co-Authored-By: JJ Kasper <jj@jjsweb.site>

* Use a global helper for is like serverless

* Update import for isTargetLikeServerless

* Update packages/next/build/index.ts

Co-Authored-By: JJ Kasper <jj@jjsweb.site>
2019-08-05 18:26:20 -04:00
JJ Kasper
6ddb5ee341 Update to check browserName instead of browser.log (#8234)
* Update to check browserName instead of browser.log

* Fix browserName check for some tests
2019-08-04 15:44:32 +02:00
Joe Haddad
2ab300dd81
Remove Old Prerender Implementation (#8218)
* Remove Prerender Implementation

* Fix PageConfig

* Fix next server

* Fix two more files

* Fix render

* Fix render

* Try to fix up page config

* Correct build file

* Switch back static checker

* Turn stuff back

* Add missing newline

* Revert changes

* Add missing newline

* Fix types
2019-08-02 10:28:03 -04:00
JJ Kasper
e7d96f77bd
Add test for dynamic routing/webpack HMR bug (#8061)
* Add failing test for dynamic routing/webpack HMR bug

* Remove un-used args from onDemandEntryHandler

* update to latest webpack with escaping
2019-08-01 11:17:42 -05:00
JJ Kasper
4850bd03ef Provide AppTree to getInitialProps for getDataFromTree (#7732)
* Provide AppContainer to getInitialProps for getDataFromTree

* Update to only pass AppTree component instead of AppContainer

* Clean up props and remove extra imports

* Make updates from review

* De-dupe AppTree a bit

* Re-use wrapApp in router

* Remove un-needed change

* revert changes to examples until on stable

* Add test for AppTree
2019-07-30 14:00:19 -04:00
Lukáš Huvar
3e03fee278 Fix build only server-side /api/index.js (#8167)
* Build error for index API routes

* Fix server build
2019-07-30 13:52:43 +01:00
Jason Miller
9659b4b555 Optional Server Compression (#8066)
* Add `compress` option to enable gzip compression in `next start`.

* Add compress option, defaulting to true

* Disable compression for serverless target

* Pin compression dep

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Pin compression types

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* lockfile update for locked compression deps

* simplify compression middleware application

* add test for compression
2019-07-29 14:35:09 -04:00
JJ Kasper
4bcf6aabe7 Allow manually setting amphtml and canonical links (#8129) 2019-07-29 08:18:23 +01:00
Piotr Tomasik
78775954f2 fix regex to not match any string with double underscore (#8153)
* fix regex to not match any string with double underscore

* add test for __ in env name and make existing test more descriptive.
2019-07-29 08:17:10 +01:00
JJ Kasper
13fa2828c2 Add missing key prop for array elements in _document (#8132)
* Add missing keys for array elements

* Add test for missing key prop in app-document
2019-07-27 10:34:29 +02:00
Lukáš Huvar
cc6fe5fdf9 Fixes problem with API and wrong regex (#8126)
* Fixes regex for client bundel. Fixes #8115

* Add test

* Update test/integration/api-support/test/index.test.js

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Update test/integration/api-support/test/index.test.js

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>
2019-07-26 17:02:12 +02:00
Olivier Tassinari
71f9288a54 Fix onError prop-type warning in Link (#8021)
The warning

> Warning: Failed prop type: Link: unknown props found: onError

can happen in this case:

```tsx
import * as React from 'react';
import NextLink, { LinkProps as NextLinkProps } from 'next/link';

type NextComposedProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & NextLinkProps;

const NextComposed = React.forwardRef<HTMLAnchorElement, NextComposedProps>((props, ref) => {
  const { as, href, replace, scroll, passHref, shallow, prefetch, onError, ...other } = props;

  return (
    <NextLink
      href={href}
      prefetch={prefetch}
      as={as}
      replace={replace}
      scroll={scroll}
      shallow={shallow}
      passHref={passHref}
      onError={onError}
    >
      <a ref={ref} {...other} />
    </NextLink>
  );
});
```

*Taken from Material-UI Next.js integration example*
2019-07-25 18:52:27 +00:00
Lukáš Huvar
bbcb448e87 Fix index.js for API routes (#8112)
This fixes the problem with `/pages/api/index.js` not creating serverless function. Fixes #8111
2019-07-25 17:39:29 +00:00
Gerald Monaco
e68307df3a Add next-head-count & remove next-head class (#8020)
Fixes #3494

Removes `class="next-head"` from the children of the `<Head>` component. Instead, a single sentinel meta element named `next-head-count` is appended. The content is the number of contiguous elements immediately preceding the sentinel that _would have had_ the `class="next-head"` attribute.

During an update, instead of searching for `class="next-head"`, the sentinel is located and the N previous elements are considered candidates for `oldTags`. New elements are inserted before the sentinel, and finally the sentinel is updated to reflect the new count.
2019-07-25 16:39:09 +00:00
Lukáš Huvar
3ee5ec4412 Configuration for body parsing size limit (#7896)
This PR introduces the possibility to change the size of the parsed body. This brings features like:
- Adjusting the size of the incoming message
- Better security
2019-07-25 15:43:55 +00:00
Janicklas Ralph
f4e6149d1c Experimental module/nomodule support (#7704)
* Module/nomodule implementation based on RFC 7563

* Remove comment

* Fixing issue with building amp pages

* Fixing test cases for serverless mode

* Adding safari 10 nomodule fix. Preloading modern js by default

* Fixing size-limit integration test

* Bug fix

* Adding testcase for modern build

* Trigger rebuild

* Setting default crossOrigin value

* Moving modern config option inside experimental flag

* Adding nomodule attribute to safari-fix script

* Changing safari10NomoduleFix default value to true

* Removing safari-fix flag

* Changing .es6 to .module

* Disable modern default

* Removing default crossOrigin value. Setting modern flag to false by default. Fixed test cases

* Remove confusing defaults and mark required instead

* Adjust blacklist

* Move behavior of page marking

* Fixing childCompiler errors not being captured

* Tweak names

* Revert

* whoops

* Fixing bug with page-loader.js

* Changing modern babel cache name

* Rename helper

* Iterate over both bundles

* Correctly clamp bundle sizes

* Revert test

* Add modern mode tests

* Fix test

* test

* test2
2019-07-24 22:16:32 -04:00
Joe Haddad
aac5121466
Apply missing formatting (#8079)
* Reapply missing formatting

* Fix lint
2019-07-23 14:33:49 -04:00
Joe Haddad
104d18c607
Rewrite Create Next App (#8030)
* Completely rewrite Create Next App

* Sort imports

* Show what package manager is being used

* Fix project name suggestion

* Update tests for new implementation

* Use normal prepublish command for on-install

* Upgrade Node version

* Switch to 8.16

* Disable v8 cache

* Swap out update check package and fix CLI boot
2019-07-19 15:55:30 -04:00
JJ Kasper
1cbb5958ec Fix syntax error in ie11 from next-server/amp (#8032) 2019-07-18 22:09:41 -04:00
Joe Haddad
4eb8aba692
Add Create Next App package (#8018)
* Add Create Next App package

* Fix Create Next App tests

* Fix company name

* Update package.json
2019-07-17 16:53:56 -04:00
Lukáš Huvar
fce7e4eaee Avoid sending user errors to client (#8005)
* Avoid sending user error to client Closes #7526

* Small improvments

* Update sending errors
2019-07-16 17:35:13 -07:00
Lukáš Huvar
d84f2919e6 Make tests for both async and sync GIP (#7999) 2019-07-16 09:43:23 -07:00
Joe Haddad
f43ae7363e
Adjust test names for send (#7996)
* Adjust test names for `serve`

* Clarify names more
2019-07-16 07:40:02 -07:00
Adam Misiorny
90280c864b Add support for 412 Precondition Failed status for static files (#7944)
* Add support for Precondition Failed status for static files

* Add test

* Trigger tests

* Update next-server.ts
2019-07-16 13:30:29 +02:00
Lukáš Huvar
718a36e127 Fix build for API routes conflict pages (#7992)
* Fixes #7991

* Fix tests
2019-07-16 12:59:09 +02:00
JJ Kasper
a10b3dff33 Add default value for pageConfig for custom _error (#7984)
* Add default value for pageConfig for custom _error

* Add serverless mode for custom-error test
2019-07-15 17:06:16 -07:00
Lukáš Huvar
c6928dcfd8 Fix GIP type in /_error page (#7952) 2019-07-15 16:16:40 -07:00