Commit graph

1215 commits

Author SHA1 Message Date
JJ Kasper
3dec50001e
Add debug flag for extra build output (#16399)
This adds a `-d` or `--debug` flag which enables outputting additional build output information like the rewrites, redirects, and headers

Fixes #15281
2020-08-20 15:43:38 +00:00
Tim Neutkens
08ab3ac6c1
Fix mini-css-plugin webpack 5 deprecation warnings (#16390)
Solves the warnings coming from mini-css-plugin in webpack 5.

Fixes #15947
2020-08-20 13:56:52 +00:00
Tim Neutkens
dab55b473c
Add serialization for mini-css-plugin webpack 5 caching (#16379) 2020-08-20 12:38:39 +02:00
JJ Kasper
67482914c6
Normalize request URL/asPath for fallback SSG pages (#16352)
This interpolates the dynamic values and rebuilds the request URL for fallback SSG pages since the proxy uses the output path for non-prerendered pages on Vercel which can cause inconsistent request URL/`asPath` values for SSG pages. This also adds tests to ensure the `asPath` is correctly updated

Fixes: https://github.com/vercel/next.js/issues/16269
2020-08-19 15:23:02 +00:00
Tim Neutkens
0fbc9d23ef
Add experimental webpack 5 cache option (#16307)
Don't use this yet as it's still being developed. This is a first iteration that enables the webpack cache. There's still more to do here, for example if css modules are used there's currently a bug where webpack does not save the cache for browser compilation (impacting build performance). @sokra is going to look into that issue.
2020-08-18 15:46:55 +02:00
Kevin Mårtensson
aa4b87e357
Handle cases where config is exported after its declaration (#16211)
AMP will still not work correctly when switching between non-AMP and AMP pages in development mode because of https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/plugins/next-page-config.ts#L116-L120.

Fixes #15704.
2020-08-17 17:24:18 +00:00
Tim Neutkens
bbbbb3502d
Make css-minimizer compatible with webpack 5 (#16250) 2020-08-17 12:59:44 +02:00
JJ Kasper
1b4d463cc8
Update rewrite params query appending (#16189)
This updates to not automatically append params to the query for rewrites if one or more of the params are already used in the destination's path. No other behavior is being changed and if the user still wants the params in the query after using them in the destination's path they can manually add them like with redirects.

Closes: https://github.com/vercel/next.js/issues/15626
2020-08-14 18:51:58 +00:00
Joe Haddad
3597978d7f
Modify low priority files in manifest (#16181)
This pull request edits the `BuildManifest` that is sent to `/_document` instead of modifying a single input array to decouple its implementation details.

Optimally, we'd eliminate the `files` key all together.

---

Related to #16182
2020-08-14 04:30:25 +00:00
JJ Kasper
8a489e24bc
Add initial handling for dynamic route href resolving and rewrites on the client (#15231)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-08-13 14:39:36 +02:00
Joe Haddad
9e65c6a958
Strongly type PageLoader (#16132)
Fixes #16131
2020-08-12 20:42:05 +00:00
Prateek Bhatnagar
2ddfd84411
Improvements - Font optimizations (#16031)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-10 14:06:38 -04:00
Tim Neutkens
37d2d15b6e
Resolve aliases modules (#16033)
Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
2020-08-10 11:45:10 +02:00
Tim Neutkens
843d58425b
Add browser polyfils for Node.js modules (webpack 5 backwards compat) (#16022)
This adds the following Node.js core polyfills only when the import is used:

- `path`
- `stream`
- `vm`
- `crypto`
- `buffer`

Fixes #15948

We'll have a separate issue about adding warnings for the usage of these modules in the browser, some polyfills like crypto are quite heavy and generally not needed for most applications (included accidentally through node_modules).
2020-08-10 01:26:21 +00:00
JJ Kasper
b1ef76df31
Fix asPath normalizing for non-dynamic pages (#15960) 2020-08-07 09:01:34 +02:00
Joe Haddad
882288b532
Warn when Fast Refresh is disabled (React <16.10) (#15931) 2020-08-06 10:41:11 -04:00
Joris
0fd1958ae4
Disallow re-export all exports from Next.js pages (#14325)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-05 16:21:40 -04:00
JJ Kasper
7d7a8fc300
Normalize serverless asPath value (#15914)
Since we now use query parameters to pass dynamic route params while routing on Vercel, this makes sure we normalize the request URL before populating the `asPath`

Fixes: https://github.com/vercel/next.js/issues/15879
2020-08-05 19:29:38 +00:00
Tim Neutkens
405e42e41e
Enhance module not found error (#15860)
Adds handling for module not found errors exposed by webpack. This ensures you see the actual stack line and code instead of a short message where you don't know where to go.

### Previous

<img width="794" alt="Screen Shot 2020-08-05 at 18 02 06" src="https://user-images.githubusercontent.com/6324199/89435935-d5542c00-d745-11ea-9ca7-c67f553364f9.png">


### New

<img width="769" alt="Screen Shot 2020-08-05 at 14 20 23" src="https://user-images.githubusercontent.com/6324199/89412212-f6595480-d726-11ea-81a3-398ab7036338.png">


Fixes #14711
2020-08-05 19:11:35 +00:00
Alex Castle
b6060fa4a5
Add experimental image post-processing (#15875)
This PR adds a second experimental post-processing step for the framework introduced by @prateekbh in #14746. The image post-processing step scans the rendered document for the first few images and uses a simple heuristic to determine if the images should be automatically preloaded.

Analysis of quite a few production Next apps has shown that a lot of sites are taking a substantial hit to their [LCP](https://web.dev/lcp/) score because an image that's part of the "hero" element on the page is not preloaded and is getting downloaded with lower priority than the JavaScript bundles. This post-processor should automatically fix that for a lot of sites, without causing any real performance effects in cases where it fails to identify the hero image.

This feature is behind an experimental flag, and will be subject to quite a bit of experimentation and tweaking before it's ready to be made a default setting.
2020-08-05 17:49:44 +00:00
Joe Haddad
754ec6642a
Run Fast Refresh Loader in Babel Loader (#15851)
Next.js plugins like `@next/mdx` inject additional webpack loaders to compile files, but they omit the necessary loader for Fast Refresh to work.

Instead of making these files deopt out of Fast Refresh, we can automatically detect and inject the loader in these cases.

Fixes #13574
2020-08-04 21:24:56 +00:00
Joe Haddad
e818389999
Add support for fallback: 'blocking' (#15672)
By popular request, this pull request adds support for returning `fallback: 'blocking'` from `getStaticPaths`.

This new mode will cause unknown paths to be rendered on-demand ("SSR") without the static (placeholder) fallback.

This feature is **currently experimental and should not be used in production yet**. It's currently flagged behind `unstable_`:

```
fallback: 'unstable_blocking'
```

TODO:

- [x] Next.js tests
- [ ] Add Vercel support
- [ ] Vercel tests

---

Fixes #15637
2020-08-04 15:10:31 +00:00
Darsh Patel
96a66c4bd3
incremental static generation and regeneration support in build manifest (#14365)
The icon is just something I thought might look good, can certainly be changed.
I've currently added incremental static generation support

Edit: Updated screenshot after 8037981
![Screenshot 2020-08-04 at 1 51 14 PM](https://user-images.githubusercontent.com/11258286/89270960-afe9f400-d659-11ea-8f18-197dc53b8beb.png)





Fixes: #14204
2020-08-04 08:42:18 +00:00
Jonathan G
6c59cbb46a
[Feature] Progress bar for static build (#15297)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-08-04 09:58:23 +02:00
Prateek Bhatnagar
1ea8bdcdc7
Bug fix: Font optimization (#15644)
- Fixes the serverless build for font optimizations
2020-08-04 07:54:08 +00:00
Kristóf Poduszló
aef6726eb8
Add missing nomodule polyfills and suggest using features only up to ES2019 for browser compatibility (#15772)
These changes aim to resolve most of the concerns raised in #15756. It adds missing polyfills for legacy browsers up until ES2019:

- Number.{parseFloat,parseInt}
- ~Math.{acosh,asinh,atanh,cbrt,clz32,cosh,expm1,fround,hypot,imul,log10p,log1p,log2,sign,sinh,tanh,trunc}~ _[Removed as these are [not widely used](https://github.com/vercel/next.js/pull/15772#discussion_r463957931)]_
  - While these may seem to weigh a lot, they barely add 1 kB to the resulting bundle:
    <img width="492" alt="gzip: 32 kB vs. 30.9 kB, Brotli: 28.8 kB vs. 27.8 kB" src="https://user-images.githubusercontent.com/14854048/89100961-1376e600-d3fc-11ea-90fd-3e6632b70220.png">
- ~Object.fromEntries~ _[Removed as [it's rarely used in user code](https://github.com/vercel/next.js/pull/15772#discussion_r463984612)]_

Also, the following features are now supported with build-time transforms:

- ~`globalThis` (gets transformed into `window` in browser environments)~ _[Removed as it [could break existing applications](https://github.com/vercel/next.js/pull/15772#discussion_r463956269)]_
- `export * as ns from 'module'`

The suggested TypeScript library version has been set to ES2018, so the features below become unavailable in type-checked files (they're not evenly supported by module-compatible browsers, either):

- Object.fromEntries
- String.prototype.matchAll
- String.prototype.replaceAll
- Promise.any + AggregateError
- WeakRef

As for the `import.meta` support, [webpack v5 seems to fix that](https://github.com/webpack/webpack/pull/11075), so it should eventually become an issue of the past.

---

Fixes #15756
2020-08-04 06:03:52 +00:00
Jan Potoms
b87e4989e2
Rename exportTrailingSlash to existing trailingSlash property (#15768)
In terms of url rewriting, `trailingSlash` supports everything `exportTrailingSlash` does. We can just share all other code paths and deprecate `exportTrailingSlash`.

This PR shows a deprecation warning when `exportTrailingSlash` is used.

Also fixes https://github.com/vercel/next.js/issues/15774

We can update the tests now or later. (I kept them the same to prove it's non-breaking)

To do:
- [x] Do we want to keep this? => nope 841d4efc51/packages/next/next-server/lib/router/router.ts (L329)
- [x] I kept `exportTrailingSlash` here. Do we want to rename that as well? => nope 2d9d649d49/packages/next/build/index.ts (L959)
2020-08-03 14:03:11 +00:00
Tim Neutkens
60f1d58c83
Fix some webpack 5 deprecation warnings (#15797)
- Use latest terser version (still 1 warning in the stable version which is an open PR)
- Add emitOnErrors instead of noEmitOnErrors
- Added trace-deprecations for Next.js core development
2020-08-03 12:57:17 +00:00
Tim Neutkens
210a6980d2
Solve large portion of webpack 5 deprecation warnings (#15806)
- Using `namedChunks` where possible, this will also allow for faster access to the chunks as we no longer have to look them up like we did before using `find`
- Using the new asset hooks introduced in the latest webpack beta
- Using the new externals function signature
2020-08-03 12:26:23 +00:00
Rafau
bcd1ba622e
[webpack5] Complile for ES5 (#15708)
I think this is necessary for IE11.

via [Webpack docs](https://webpack.js.org/migrate/5/#turn-off-es2015-syntax-in-runtime-code-if-necessary)


> By default, webpack's runtime code uses ES2015 syntax to build smaller bundles. If your build targets environments that don't support this syntax (like IE11), you'll need to set output.ecmaVersion: 5 to revert to ES5 syntax.


Thank you
2020-07-31 08:50:54 +00:00
Joe Haddad
3d98171dab
Test webpack 5 beta (#15645) 2020-07-29 19:19:32 -04:00
JJ Kasper
dd6a08980a
Normalize missing optional value on Vercel (#15593)
This updates collecting dynamic route params on Vercel to make sure that missing optional dynamic routes are undefined. Additional tests for this mode have also been added to ensure the params are being collected properly

Closes: https://github.com/vercel/next.js/issues/15579
2020-07-29 14:19:25 +00:00
Prateek Bhatnagar
fb81ecb2bd
Font optimizations (#14746)
Co-authored-by: atcastle <atcastle@gmail.com>
2020-07-28 12:19:28 +02:00
Jean Helou
17420c785c
improves baseUrl resolution in typescript monorepos (#13542) 2020-07-28 12:00:27 +02:00
Tim Neutkens
fdfc508a61
Add polyfill for process and Buffer in webpack 5 (#15499) 2020-07-28 11:33:21 +02:00
Gerald Monaco
71bc0db92a
Combine sendPayload and sendHTML (#15475) 2020-07-27 16:19:30 -04:00
Joe Haddad
a11d99390a
Stabilize Trailing Slash API (#15331)
Closes #15330
2020-07-20 16:16:59 +00:00
Tim Neutkens
e57b2091aa
Bring over fixes from #15185 (#15326)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-20 11:14:02 -04:00
Tim Neutkens
aa62fa7f42
Add test for main.js in webpack.config.js (#15311)
This particular variable was not being read correctly. Added a test for the behavior.

Fixes #15261
2020-07-20 02:16:50 +00:00
Necmettin Karakaya
c2f38f2af0
[Fix] common misspelling errors (#15288)
For reference: https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-07-19 04:38:20 +00:00
Tim Neutkens
a33bb5bec5
Fix app-document-import-order test for webpack 5 (#15224) 2020-07-17 10:38:06 +02:00
Tim Neutkens
1fe612e882
Make sure the correct chunk names are used in webpack 5 (#15204) 2020-07-15 19:33:41 -04:00
Tim Neutkens
14babe5b3f
Make type checking compatible with webpack 5 (#15158)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-15 13:56:27 -04:00
Joe Haddad
8222d571e7
Correctly fetch data for root route (#15149)
This PR corrects the data fetching behavior for optional root routes.

---

Fixes #14923
2020-07-14 18:58:02 +00:00
Jan Potoms
c9492a8cc9
Relax encoding on dynamic prerendered routes (#14717)
It should be enough to encode the characters that `path-to-regexp` uses as path delimiters (`/#?`).

Fixes https://github.com/vercel/next.js/issues/14691
2020-07-13 14:42:27 +00:00
JJ Kasper
2d9d649d49
Add handling for custom-routes with basePath (#15041)
This adds handling for custom-routes with `basePath` to automatically add the `basePath` for custom-routes `source` and `destination` unless `basePath: false` is set for the route. 

Closes: https://github.com/vercel/next.js/issues/14782
2020-07-12 19:03:49 +00:00
Tim Neutkens
8a8ef641d8
Update ignored patterns for webpack 4 (#15096)
Found while working on figuring out this bug: https://twitter.com/timneutkens/status/1282129714627448832

 I noticed that the node_modules got passed by the ignore still because when chokidar identifies a ignore pattern is a glob it treats the glob as-is instead of appending `/**` to the glob
2020-07-12 14:03:17 +02:00
Tim Neutkens
525fc360ae
Exclude node_modules in watchOptions (#15020) 2020-07-09 19:58:39 +02:00
Tim Neutkens
ab4a90b0d9
Add filename to error in webpack 5 (#14977)
Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>
2020-07-09 14:31:06 +02:00
Tim Neutkens
10408241f7
Make serverless-plugin compatible with webpack 5 (#15010)
Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>
2020-07-09 14:30:40 +02:00
Darsh Patel
6d7cf2a934
Convert profiling mode from configuration option to CLI switch (#14920)
Removed Option to enable `ReactProductionProfiling` from configuration and added a CLI switch for the same.
Users can now do `next build --profile`  to enable react production profiling. 
Also added a warning to notify users about the performance impact

Fixes: #14688
2020-07-09 11:39:12 +00:00
Jan Potoms
33ebda1b7d
Fix root route optional catch-all prerendering (#14986)
Fixes https://github.com/vercel/next.js/issues/14964
2020-07-09 04:21:49 +00:00
JJ Kasper
16590f7606
Make sure routeKeys are PCRE compliant (#14987)
This adds additional checks against the routeKeys used to build the named regexes for dynamic routes to ensure they follow PCRE rules for named capture groups

x-ref: https://github.com/vercel/vercel/pull/4813
2020-07-08 18:45:53 +00:00
Jan Potoms
3623d444c1
Fix basepath browser back/forward issue (#14861)
Discovered while working on https://github.com/vercel/next.js/pull/14848

when asPath is the same but href is different it should use `replaceState` instead of `pushState`, so that browser back/forward behavior is preserved. Currently it's comparing a path that includes basepath with one that excludes  it, so `pushState` is always used. This makes sure the behavior is the same as when running next.js without a basepath
2020-07-07 05:24:38 +00:00
JJ Kasper
38bd1a024c
Re-enable scroll restoration behind flag (#14046)
This updates the scroll position saving to occur as the scroll position changes instead of trying to do it when the navigation is changing since the `popState` event doesn't allow us to update the leaving history state once the `popState` has occurred. 

The order of events that was previously attempted to save scroll position on a `popState` event (back/forward navigation)

1. history.state is already updated with state from `popState`
2. we replace state with the currently rendered page adding scroll info
3. we replace state again with the `popState` event state overriding scroll info

Using this approach the above event order is no longer in conflict since we don't attempt to populate the state with scroll position while it's leaving the state and instead do it while it is still the active state in history

This approach resembles existing solutions:
https://www.npmjs.com/package/scroll-behavior
https://twitter.com/ryanflorence/status/1029121580855488512

Fixes: https://github.com/vercel/next.js/issues/13990
Fixes: #12530
x-ref: https://github.com/vercel/next.js/pull/14075
2020-07-06 14:27:45 +00:00
Tim Neutkens
c5cc6072d0
Use single webpack runtimeChunk for Node.js compilation (#14722)
Webpack 5 supports a single runtimechunk for the Node.js compilation, this solves sharing modules between entrypoints.
2020-07-01 15:34:00 +00:00
Tim Neutkens
260707de68
Add etag support for getServerSideProps/getStaticProps pages (#14760)
Fixes #11711

Also cleaned up some extra code.

This was already supported on the Vercel edge network.
2020-07-01 14:59:18 +00:00
JJ Kasper
dd644945ea
Fix encoding for env files in serverless mode (#14750)
This makes sure to base64 encode the `.env*` file contents before passing them in the URL for the serverless-loader since `!` is a special character in this case which can cause webpack to fail to build

Closes: https://github.com/vercel/next.js/issues/14749
2020-06-30 21:33:37 +00:00
Joe Haddad
ea1f45a388
Add no-anon-default-export Babel lint rule (#14519)
Fixes #12291 

![image](https://user-images.githubusercontent.com/616428/85499698-176b4900-b5b0-11ea-8a5d-a7f0b4c20307.png)
2020-06-30 13:05:29 +00:00
Yang Sun
a8d2c1ee95
modify global css import error message (#14639)
Fixes #14464
2020-06-30 05:25:02 +00:00
Jan Potoms
ab7010711f
Avoid pulling extra code in the bundles for trailingSlash logic (#14696)
* avoid pulling code in the bundle for `trailingSlash` logic when it's not enabled
* avoid cloning the url an extra time if normalizing the path doesn't change it
2020-06-30 04:06:39 +00:00
Joe Haddad
923afd68d4
Upgrade CSSNano Version (#14638)
Fixes #14632
Fixes #14690
2020-06-29 21:29:53 +00:00
Joe Haddad
1d0e7a8a9a
Enable Optional Catch-All by Default (#14687)
Closes #14682
2020-06-29 18:50:32 +00:00
Tim Neutkens
327f6eed41
Clean up plugins (#14676)
Preparation for a larger rewrite
2020-06-29 14:26:49 +00:00
Tim Neutkens
83de34239c
Convert incremental generation cache to a class (#14660)
We've been meaning to change this code for a while 👍

- Changed the name from spr to incremental
- Changed the code to be a class instead of using module scope variables
2020-06-28 20:58:43 +00:00
Todor Totev
1aed9eaac1
Introduce react profiling production flag (#13873)
Closes [13709](https://github.com/vercel/next.js/issues/13709).

The solution works, **(tested and confirmed with true and false flags with the latest next version)** though I am quite sure this is not the most elegant and proper way to implement it. I have spent the good part of yesterday and today's morning in order to make it more generic but since it's my first time working with anything related to webpack I have struggled miserably. Last, but not least I'm unsure if this is the most proper naming for the flag.

Please, let me know what you want me to change and I'll get it done asap.
2020-06-28 11:23:29 +00:00
Tim Neutkens
b4b68c0b85
Use assetEmitted hook instead of afterEmit (#14626)
Makes sure this works correctly with webpack 5.
2020-06-27 17:16:55 +00:00
Jan Potoms
bd24b70d60
Fix trailing slash handling in exporting pages with getStaticPaths (#14620)
Fixes https://github.com/vercel/next.js/issues/14573
2020-06-27 11:59:27 +00:00
Tim Neutkens
ae542b8525
Use entry option instead of custom make hook (#14527)
Simplifies on-demand-entries a bit.
2020-06-26 04:26:09 +00:00
James Mosier
435bf65784
Warn/revert custom devtool in development mode (#14285)
Warn users and revert their `devtool` when they manually change the `devtool` in development mode. For this addition, I check to ensure the `devtool` is custom (i.e. different than what is set by Next) and has a value (`false` is fine as a custom `devtool`!).

As described in [this issue (13963)](https://github.com/vercel/next.js/issues/13963), changing the `devtool` in development mode can cause issues with performance.

Fixes #13963
2020-06-24 04:15:57 +00:00
Jan Potoms
574e9d285a
Remove deprecated plugin in favor of the option (#14503)
Not sure if it's still there for a reason, but from  the types for `NoEmitOnErrorsPlugin`
```js
/* @deprecated use config.optimization.noEmitOnErrors */
```
2020-06-23 17:44:51 +00:00
Tim Neutkens
be2a63238a
Webpack 5 build compat (#14498)
Initial PR to make `next build` work with webpack 5, still needs more work to make sure runtimeChunk and such are shared between pages.

- No longer needs the custom ChunkNamesPlugin as the default behavior was changed
- Dropping AMP First client page bundles is now compatible
2020-06-23 15:47:50 +00:00
Jan Potoms
2142b76e6b
Normalize trailing slashes (#13333)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-06-23 13:38:49 +02:00
JJ Kasper
fca768d3d2
Update to rely on dynamic param values from proxy (#12608)
This updates to rely on query values from the proxy when capable to ensure the correct values are provided. This does not remove the `x-now-route-matches` as this is still needed until the values are provided in the query instead for iSSG

x-ref: https://github.com/zeit/now/pull/4196
x-ref: https://github.com/zeit/next.js/pull/12250
x-ref:

Tested against the following updated fixtures from https://github.com/vercel/vercel/pull/4682 with https://github.com/ijjk/next-update-loader

- 08-custom-routes-catchall
- 10-export-cache-headers
- 16-base-path
- 22-ssg-v2
- 23-custom-routes-verbose
2020-06-23 05:31:32 +00:00
Tim Neutkens
6c2ce70608
Remove buildId from server-side files (#14413)
Gets rid of the custom function for naming files by removing buildId from the file paths.
2020-06-22 21:12:36 +00:00
Joe Haddad
67ff62507d
Do not remove no-FOUC styles too early (#14448)
We previously used to remove our FOUC helper inside of the style injection to ensure content was shown as fast as possible.

This behavior, however, was problematic for a few reasons:

1. Large JavaScript chunks would take longer than an animation frame to parse, causing FOUC
1. Rendering would sometimes complete before an animation frame, causing improper effects

To fix the latter, we started removing the no FOUC helper **before** rendering, however, we never fixed the former by removing the dead code.

There's not a great way to test this because the FOUC is so fast and flaky, however, this code really shouldn't exist and isn't likely to be re-added (regress).

Also, we already have FOUC tests that occasionally flake, probably due to this.


Fixes #12448
Fixes #13058
Fixes #11195
Fixes #10404
2020-06-22 14:10:19 +00:00
Tim Neutkens
bef9b56109
Update filename generation for client-side compilation (#14279)
Updates the way filenames are generated for browser compilation.
Notably:
- All entry bundles now have hashes in production, this includes pages (previously pages used a buildId in the path)
- The AmpFiles no longer depends on hardcoded bundle names, it uses the buildManifest instead (internals)
- All cases where we match the page name from the chunk/entrypoint name now use the same function `getRouteFromEntrypoint` (internals)
- In development we no longer include the "faked" `buildId` set to `development` for page files, instead we just use the `/_next/static/pages` path (was `/_next/static/development/pages`). This was changed as it caused unneeded complexity and makes generating the bundles easier (internals)
- Updated tons of tests to be more resilient to these changes by relying on the buildManifest instead of hardcoded paths (internals)

Follow up of these PRs:
https://github.com/vercel/next.js/pull/13759
https://github.com/vercel/next.js/pull/13870
https://github.com/vercel/next.js/pull/13937
https://github.com/vercel/next.js/pull/14130
https://github.com/vercel/next.js/pull/14176
https://github.com/vercel/next.js/pull/14268


Fixes #6303
Fixes #12087 
Fixes #1948
Fixes #4368
Fixes #4255
Fixes #2548
2020-06-20 19:59:47 +00:00
JJ Kasper
f92571d502
De-experimentalize basePath config (#14283)
This moves the experimental `basePath` config out of the `experimental` section to prepare it for being stable
2020-06-18 10:10:20 +00:00
stefanprobst
279ae19c7e
docs: update links to docs site (#14305)
this updates some links to the docs site to their new location
2020-06-18 09:54:07 +00:00
Tim Neutkens
1fc0aae589
Prepare for webpack 5 upgrade (#14268)
Tweaked the config that can already be updated a bit.
2020-06-17 15:00:29 +00:00
Joe Haddad
7ce000b328
WSL should be considered Windows for HMR option (#14254)
This toggles the separate Windows `devtool` setting for WSL. We cannot test this as we do not have access to WSL in our current test setup suite, however, this is a temporary patch that should be fixed with the webpack 5 upgrade, so I do not feel strongly about testing it.

---

Fixes #14253
2020-06-17 12:59:00 +00:00
JJ Kasper
a9a7319ee3
Refactor moveExportedPages to use getPagePath (#14247)
Updates to not build the path from scratch here and relies on `getPagePath` instead

Closes: https://github.com/vercel/next.js/issues/14223
2020-06-17 03:40:07 +00:00
JJ Kasper
08d7755e68
Update routeKeys to handle non-word characters (#12801)
This updates the named regexes output in the `routes-manifest` and the associated `routeKeys` to not use any non-word characters as this breaks the named regexes e.g. `"Invalid regular expression: "^/(?<data\-provider\-id>[^/]+?)(?:/)?$"`

x-ref: https://github.com/zeit/now/pull/4355
2020-06-16 13:49:13 +00:00
Tim Neutkens
ea6b8dac40
use requirePage for /_document and /_app (#14176) 2020-06-15 10:41:17 -04:00
Tim Neutkens
27f653bb3d
Clean up AMP bundle removal (#14130)
Drops the entrypoint instead of removing the underlying file.
2020-06-14 12:49:46 +00:00
JJ Kasper
3d6d033a5b
Normalize asPath between SSR and CSR with basePath (#14040)
To make `asPath` consistent with `basePath` handling this makes sure it is always stripped including on the client under the `asPath` value and from `req.url` in the `serverless-loader`. Additional tests have been added for this behavior to ensure we don't regress on this

Closes: https://github.com/vercel/next.js/issues/14037
Closes: https://github.com/vercel/next.js/issues/14039
2020-06-11 14:06:06 +00:00
Tim Neutkens
76fddcd7ef
Use chunkhash instead of buildId for pages (#13937)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-06-11 10:57:24 +02:00
Joe Haddad
91664d1d02
Eliminate public folder enumeration (#14042)
This builds off of @timneutkens's PR instead of updating it because it's his `canary` branch.

Updated to still `stat`, as it's the only way to test the difference between a file and directory. 

---

Closes #13506
Fixes #12235
2020-06-10 20:35:34 +00:00
Joe Haddad
d874329d11
Prioritize webpack bootstrapping first (#13987)
Webpack will randomly execute script order if its runtime is not prioritized before chunks execute.

This seems to be somehow triggered in #13870 because of slightly different script ordering.

This had actually broke CSS, which is why our tests are failing 50% of the time:

Without this PR:
![image](https://user-images.githubusercontent.com/616428/84221491-57f0a000-aaa3-11ea-9dff-c27c87d29ac5.png)

However, it's still problematic to use `async` in development since we rely on script execution order. So, this PR disables `async` in development.

We're exploring `defer` in the future anyway (over `async`), which will be ordered, so I don't mind diverging between dev and prod in this way.

---

Fixes #13911
2020-06-10 04:41:59 +00:00
Jan Potoms
9da99bcb66
Prepare custom routes loading for adding additional routes (#13857)
Extracted from https://github.com/vercel/next.js/pull/13333, the same exact code lives in that PR as well, but we can merge this separately if it makes reviewing https://github.com/vercel/next.js/pull/13333 easier

This PR does 3 things 
- deduplicate code from build and next-dev-server that loads custom routes from next.config.js  (`loadCustomRoutes`)
- in `loadCustomRoutes`, load these rewrites, headers and redirects configs concurrently instead of sequentially.
- in next-server, make `this.customRoutes` always defined, this allows us to remove the big `if` around its initialization code in `generateRoutes`, which in turn makes it possible to reuse this code for other routing than user defined routes, which is how https://github.com/vercel/next.js/pull/13333 adds its redirects.
2020-06-09 20:16:23 +00:00
Tim Neutkens
2169c0ce97
Use buildManifest to load page JS (#13870)
Initial work to use chunkhashes instead of buildid for the page files in production. This does not change the calculation of the filename itself initially.
2020-06-08 18:11:00 +00:00
Jan Potoms
08b2e9b3ba
Remove some leftovers after index page updates (#13876) 2020-06-08 16:17:03 +02:00
Tim Neutkens
e125d905a0
Clean up render.tsx options (#13759)
Went through and removed a bunch of internal options which are just pass-through values of buildManifest

Closes #13851
2020-06-06 23:00:03 +00:00
Jan Potoms
1b36f0c029
Fix pages/index.js and pages/index/index.js behavior (#13699)
Disambiguate between pages/index.js and pages/index/index.js so that they resolve differently.
It all started with a bug in pagesmanifest that propagated throughout the codebase. After fixing pagesmanifest I was able to remove a few hacks here and there and more logic is shared now. especially the logic that resolves an entrypoint back into a route path. To sum up what happened:

- `getRouteFromEntrypoint` is the inverse operation of `getPageFile` that's under `pages/_document.tsx`
- `denormalizePagePath` is the inverse operation of `normalizePagePath`.

Everything is refactored in terms of these operations, that makes their behavior uniform and easier to update/patch in a central place. Before there were subtle differences between those that made `index/index.js` hard to handle.

Some potential follow up on this PR:
- [`hot-reloader`](https://github.com/vercel/next.js/pull/13699/files#diff-6161346d2c5f4b7abc87059d8768c44bR207) still has one place that does very similar behavior to `getRouteFromEntrypoint`. It can probably be rewritten in terms of `getRouteFromEntrypoint`.
- There are a few places where `denormalizePagePath(normalizePagePath(...))` is happening. This is a sign that `normalizePagePath` is doing some validation that is independent of its rewriting logic. That should probably be factored out in its own function. after that I should probably investigate whether `normalizePagePath` is even still needed at all.
- a lot of code is doing `.replace(/\\/g, '')`. If wanted, that could be replaced with `normalizePathSep`.
- It looks to me like some logic that's spread across the project can be centralized in 4 functions 
  - `getRouteFromEntrypoint` (part of this PR)
  - its inverse `getEntrypointFromRoute` (already exists in `_document.tsx` as `getPageFile`)
  - `getRouteFromPageFile` 
  - its inverse `getPageFileFromRoute` (already exists as `findPageFile ` in `server/lib/find-page-file.ts`)

  It could be beneficial to structure the code to keep these fuctionalities close together and name them similarly.
 - revise `index.amp` handling in pagesmanifest. I left it alone in this PR to keep it scoped, but it may be broken wrt nested index files as well. It might even make sense to reshape the pagesmanifest altogether to handle html/json/amp/... better
2020-06-04 17:32:45 +00:00
Tim Neutkens
0fc344e6a3
Remove unused variable (#13716)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-06-03 11:58:58 -04:00
Tim Neutkens
08e7fa16db
Get rid of autodll (#13669)
Prepares for the upgrade to webpack 5
2020-06-02 19:20:37 +00:00
Joe Haddad
a92e976231
Remove remaining granular chunks references (#13672)
This removes remaining references to `granularChunks` in configs, error messages, and comments.

Also removed the `process.env.__NEXT_GRANULAR_CHUNKS` value.

---

Follow up to: https://github.com/vercel/next.js/pull/13663
2020-06-02 14:45:07 +00:00
Tim Neutkens
0769a82acc
Remove granularChunks experimental option as it was launched (#13663)
The option was released a few months ago so we can get rid of this option.
2020-06-02 14:13:11 +00:00
Tim Neutkens
31b3e46b8f
Use inclusive naming for variables / examples (#13657)
https://twitter.com/vercel/status/1267650234236252161

The variables for the launchEditor feature were kept consistent with Create React App so it's probably a good idea for them to change them too: https://github.com/facebook/create-react-app/search?q=WINDOWS_FILE_NAME_WHITELIST

Prior discussions on this topic:
- https://github.com/hashicorp/consul/issues/7901
- https://github.com/styled-system/styled-system/issues/391
- https://github.com/go-sql-driver/mysql/pull/1116
- https://github.com/lagom/lagom/issues/2532
- https://github.com/grafana/grafana/issues/18841
2020-06-02 13:52:41 +00:00
Joe Haddad
15cdb4f408
Propagate Serverless Errors to Platform (#12841)
In serverless mode, it's best practice to propagate an unhandled error so that the function is disposed instead of recycled. This helps fix the "bad state" problem.
2020-06-01 23:12:45 +00:00
Tim Neutkens
b124ed2e14
Added no-shadow rule to eslint (#13645)
Was going through _document and noticed some variable shadowing going on. Added a rule for it to our eslint configuration and went through all warnings with @Timer.
2020-06-01 21:00:22 +00:00
Jan Potoms
8bac412845
make getStaticPaths work with optional catch-all routes (#13559)
Fixes https://github.com/vercel/next.js/issues/13524

To do:
- [x] fix dev mode
- [x] there's a ~route ordering or~ trailing slash issue with top level catch-all (current tests reflect that)
- [x] in this test `/get-static-paths/whatever` should fall back to `/[[...optionalName]].js` since `fallback` is `false` in its `getStaticPaths` method. ~Currently seems to 500~ must have been a glitch
- [x] add tests for `null`, `undefined` ~and `false`~ behavior as well (if decided these are valid)
- [x] ~add tests for string params as well~ this is not allowed for catch-all routes
- [x] test behavior when fallback is enabled and a top level catch-all exists
2020-06-01 17:08:34 +00:00
Tim Neutkens
fef3b8c2ce
Update babel config found log to new logging output (#13550)
Updates the message to be in line with .env loading.
2020-05-29 15:08:28 +00:00
Joe Haddad
92a12a2e20
Replace fork-ts-checker-webpack-plugin with faster alternative (#13529)
This removes `fork-ts-checker-webpack-plugin` and instead directly calls the TypeScript API.

This is approximately 10x faster.

Base build: 7s (no TypeScript features enabled)

- `fork-ts-checker-webpack-plugin@3.1.1`: 90s, computer sounds like an airplane
- `fork-ts-checker-webpack-plugin@4.1.6`: 84s, computer did **not** sound like an airplane
- `fork-ts-checker-webpack-plugin@5.0.0-alpha.14`: 90s, regressed
- `npx tsc -p tsconfig.json --noEmit`: 12s (time: `18.57s user 0.97s system 169% cpu 11.525 total`)
- **This PR**: 22s, expected to get better when we run this as a side-car

All of these tests were run 3 times and repeat-accurate within +/- 0.5s.
2020-05-29 08:16:22 +00:00
Joe Haddad
30fbd9adc9
Speedup tests (#13461)
This PR checks if our tests can be ran faster by disabling source maps unless they're used for the purpose of testing.
2020-05-29 07:57:51 +00:00
Joe Haddad
c64cb60a8e
Fail production build quickly (#13496)
By default, webpack will proceed to run loaders and plugins on all files, even after an error has been encountered during the build process.

This means you might need to wait minutes to see a syntax error encountered in one of your source files. This PR fixes that.
2020-05-28 22:51:30 +00:00
Joe Haddad
bee8c31b87
Lint for invalid imports (#13482)
This adds a lint rule to ensure we don't import dev dependencies by accident.
2020-05-28 08:23:10 +00:00
Joe Haddad
b7e17e09e5
Update references to zeit/next.js (#13463) 2020-05-27 17:51:11 -04:00
JJ Kasper
e2619359ec
Add warning when reserved pages are nested (#13449)
This adds a warning when a user has nested a reserved page `_error`, `_app`, or `_document` in their pages directory since it causes it to not be picked up and used by Next.js in the expected way

x-ref: https://github.com/zeit/next.js/pull/13425

<details>
<summary>Example of warning</summary>

<img width="927" alt="Screen Shot 2020-05-27 at 10 39 09" src="https://user-images.githubusercontent.com/22380829/83042315-24276c00-a007-11ea-9dc4-cabcc93571d2.png">
</details>
2020-05-27 16:45:53 +00:00
JJ Kasper
83bc82e40a
Fix auto export opting out from _error edge case (#13425)
This fixes an edge case where an application can seemingly randomly be opted out of the automatic static optimization from having an `_error` file that isn't directly nested under the `pages` folder e.g. `pages/hello/_error.js`. 

Since in serverless mode we use the `_app` export from the first serverless page, if this `_error.js` file is used to check for custom `getIniitalProps` in `_app` and the `_error.js` page had a custom `getInitialProps` itself it would cause the check to fail opting the application out of the static optimization. 

This fixes it by having the check be explicit instead of relying on the bundle name and it also adds regression tests for this. It might be good to also add a warning when `_error` or `_app` are not directly nested under the pages folder in a follow up PR
2020-05-27 05:31:57 +00:00
Joe Haddad
8b72b9e2de
[Experimental] Do not type check twice (#13419)
The experimental modern mode runs the type checking plugin twice, which **occasionally** suffers from a race condition that hangs the build.

This PR fixes type checking to only be run once.

While this test cannot 100% reproduce/capture the race condition, I don't feel strongly about the test case:

- We're planning on eliminating this type checking plugin ASAP (for a faster alternative)
- Modern mode implementation as-is will probably go away with webpack 5
2020-05-27 02:58:16 +00:00
JJ Kasper
fafa16f350
Bundle env configs in serverless mode (#13406)
As discussed this adds bundling of `.env` files in `serverless` mode so that the environment values are also available when deploying with this target

closes: https://github.com/zeit/next.js/issues/13332
2020-05-26 19:01:57 +00:00
Fabio Benedetti
235b3befcc
fix(client-routing): page render (#13305)
Fixes https://github.com/zeit/next.js/issues/12935
2020-05-26 17:50:06 +00:00
Jan Potoms
2e1a322d6f
Add a few extra types (#13363)
Added a few extra types here and there while I was digging through the code
2020-05-25 21:15:56 +00:00
Jairo Tylera
e66bcfa838
Add support for sass-loader prependData option (#12277)
This PR adds support for prepending sass code before the actual entry file.

It's common for developers to import their sass mixins and variables once on their project config so they don't need to import them on every file that requires it. Frameworks like gatsby and nuxt.js already support that handy feature.

The way it works is:

```
/// next.config.js
module.exports = {
  experimental: {
    sassOptions: {
      prependData: `
        /// Scss code that you want to be
        /// prepended to every single scss file.
      `,
    },
  },
}
```

Fixes #11617 and duplicates
2020-05-23 13:37:48 +00:00
Joe Haddad
3f11daa9c0
Use correct chalk import (#13235)
This PR imports our bundled dependency instead of re-adding it to install-time.

---

Closes #13166
2020-05-22 15:56:32 +00:00
Joe Haddad
3d852d895f
Better formatted Sass errors (#13211)
https://twitter.com/timer150/status/1263689549898829829
2020-05-22 05:25:02 +00:00
Maxi Gimenez
57535b5afc
chore(next/build/babel): missing types (#13189) 2020-05-21 12:57:04 +00:00
Joe Haddad
7c7fd3e863
Record presence of reportWebVitals (#13155)
Closes #12897
2020-05-20 18:44:39 +00:00
Joe Haddad
74d7e3585c
Eliminate array destructuring assignment (#13151)
While we're at it, we should fix this too.

x-ref: #13144
2020-05-20 17:13:31 +00:00
Joe Haddad
92a159d939
Correctly eliminate destructuring assignment (#13144)
This eliminates code referenced via destructuring assignment, as reported by @styfle.
2020-05-20 15:57:18 +00:00
Janicklas Ralph
a17ace8eba
GranularChunks conformance check (#11710)
Adding a conformance plugin the make sure users don't undo the benefits of the granularChunks config.

The plugin makes sure that minSize, maxInitialRequests values aren't overridden. Also ensures the cacheGroups - vendors, framework, libs, common, shared are maintained.

The warning and error messages do not break the build with this change. They only display a message.

cc - @prateekbh, @atcastle
2020-05-20 06:40:23 +00:00
Joe Haddad
d64e2e1cbe
Use eval-source-map for Server Side Errors (#13123)
This switches to faster source maps in development for the server-side compilation on macOS.

We still need to figure out a story for Windows.
2020-05-20 05:00:50 +00:00
Dave Cardwell
07084d4819
[Experimental] Only consider files within plugins (#12943)
I have a plugin with a src folder structure following jest’s recommended practice of including a `__tests__` folder:

```
$ find src/
src/
src/document-html-props-server.ts
src/__tests__
src/__tests__/document-html-props-server.unit.ts
```

collect-plugins.ts [reads the src directory](960c18da53/packages/next/build/plugins/collect-plugins.ts (L65)) and finds:
```js
[ '__tests__', 'document-html-props-server.ts' ]
```

…which it then [converts to](960c18da53/packages/next/build/plugins/collect-plugins.ts (L76-L80)):
```js
[ '', 'document-html-props-server' ]
```

…and finally [outputs](960c18da53/packages/next/build/plugins/collect-plugins.ts (L90-L96)):
```
Next.js Plugin: {my plugin} listed invalid middleware
```

This pull request makes collect-plugins.ts only consider files, so my __tests__ directory and its contents are ignored.
2020-05-20 04:05:29 +00:00
Slawek Kolodziej
7f604a504b
Fix building server-side generated AMP pages (#13046) 2020-05-19 07:58:50 -04:00
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Joe Haddad
6d6ce94f68
An empty jsconfig.json should not fail the build (#13051) 2020-05-18 12:31:15 -04:00
Jan Potoms
3b382a08d5
Improve jsconfig.json error message (#13053) 2020-05-18 12:07:08 -04:00
Jan Potoms
f8125c9ed7
[Experimental] Implement optional catch all routes (#12887) 2020-05-18 09:47:13 -04:00
Tim Neutkens
dfe6d14859
[Experimental] Add support for production browser source maps (#13018) 2020-05-17 16:30:42 -04:00
Joe Haddad
9576d5414d
Update Babel Cache Key (#12989) 2020-05-16 17:52:52 -04:00
Joe Haddad
202ea6fbd9
Support eliminating memoized functions (#12953) 2020-05-15 17:14:46 -04:00
Joe Haddad
7edc815a38
Elimination has to run before other plugins (#12949) 2020-05-15 16:51:29 -04:00
Joe Haddad
0d49f22e11
Remove react-error-overlay (#12942) 2020-05-15 14:14:44 -04:00
Joe Haddad
9c79955047
Strip out dead code for ignoreDevErrors (#12941) 2020-05-15 13:30:01 -04:00
Joe Haddad
3bd2711c19
[Fast Refresh] Improve responsiveness on Windows (#12909) 2020-05-15 08:30:23 -04:00
Joe Haddad
b931cbecbf
Simplify CSS Errors (#12852) 2020-05-13 17:18:45 -04:00
Joe Haddad
f1423518b9
Better Babel syntax errors (#12821) 2020-05-13 11:43:41 -04:00
Tim Neutkens
64c7571e01
Fix edge case in fetch polyfill (#12832)
* Add tests for getStaticPaths

* Fix edge case in fetch polyfill

Fixes #12794

* Correct typo in tests
2020-05-13 13:10:47 +02:00
Joe Haddad
a3a61b4546
Bump Babel cache key (#12822) 2020-05-13 11:18:23 +02:00
Tim Neutkens
93c81494c6
Make fetch polyfill work with ky-universal (#12804) 2020-05-12 15:58:21 -04:00
Tim Neutkens
467b2c7ebc
Enable sassOptions support in next.config.js (#12685) 2020-05-10 22:11:48 -04:00
Joe Haddad
f54e05f776
[Fast Refresh] Reorder Loaders (#12671) 2020-05-09 18:37:04 -04:00
JJ Kasper
92edfb953d
Cont. Update performance relayer and remove unstable prefix (#12665)
* updates relayer, uses web-vital lib, removes fid polyfill and removes unstable prefix from relayer

* simplify logic, fix null check

* update docs

* Update tests

* Rename relayWebVitals to reportWebVitals

Co-authored-by: housseindjirdeh <houssein@google.com>
2020-05-09 21:48:52 +02:00
Simon Knott
be02fe183f
Allow @babel/preset-typescript to be configured (#11840)
* Allow `@babel/preset-typescript` to be configured

Some usages, e.g. [getting parameter decorators to work properly](https://github.com/WarnerHooh/babel-plugin-parameter-decorator/pull/19), require configuring `@babel/preset-typescript`.

This commit adds that functionality to `next/babel`.

* Add unit test for babel/preset allowing to pass options to @babel/preset-typescript

* Add integration test for onlyRemoveTypeImports

* Update babel dependencies

* Update to compatible typescript version and fix types

* Fix linting and run pre-nccing

* Update size-limit test

* Add additional tests

* Re-Apply delta to be calculated using -262

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-05-09 17:12:02 +02:00
Joe Haddad
e173967b9f
[Fast Refresh] New Compile Error Overlay (#12543) 2020-05-05 23:46:07 -04:00
Joe Haddad
48140d5bb7
Disable Comment Extraction (#12496) 2020-05-05 11:39:36 -04:00
Joe Haddad
adb14c9556
Disable cache warning on supported platforms (#12495) 2020-05-05 11:04:57 -04:00
Joe Haddad
e0449a5b9c
[Fast Refresh] New Overlay for Prerender Error (#12485) 2020-05-04 17:16:03 -04:00
matamatanot
05e93e1520
Use fs.promises instead of promisify (#12026) 2020-05-02 00:10:19 -04:00
Joe Haddad
23941cdca2
[Fast Refresh] Skip Environment Check (#12359) 2020-04-30 12:58:22 -04:00
Joe Haddad
fbea795ad9
[Fast Refresh] Redesigned Runtime Error Experience (#12222) 2020-04-30 10:50:25 -04:00
Tim Neutkens
4c8ff7c8e0
Polyfill fetch by default (#12353) 2020-04-30 16:35:48 +02:00
JJ Kasper
88fd9a0dd2
Update jsconfig paths fix for windows (#12328) 2020-04-29 17:56:18 -04:00
Tim Neutkens
0713ba4e78
Fix wildcard paths causing infinite resolving (#12318) 2020-04-29 17:04:42 +02:00
Tim Neutkens
e907e4791c
New logging output (#12169)
* Add new logger output

* Fix tests

* Fix tests

* Update next start log for consistency

* Fix cli tests

* Fix tsconfig tests

* Update plugins test

* Fix invalid-custom-routes tests

* Revert "Fix invalid-custom-routes tests"

This reverts commit 8e8eec11dd21feb2186163856207bb974110c13e.

* Revert "Update plugins test"

This reverts commit 3f09270509ea52a1b4f0515cee8e4e711f7e1b16.

* Revert "Fix tsconfig tests"

This reverts commit a4c23bb120e81a15ea50dc6ad1ad097368ef3be6.

* Revert "Fix cli tests"

This reverts commit ff3a321d29bd9afb09f7cf550823010a08a54ae1.

* Revert "Update next start log for consistency"

This reverts commit 481509d8f713a918b7a125e4b7f7bc5c5990c2e1.

* Revert "Fix tests"

This reverts commit 6fb2cb59f79fdf8495fc7288c1c18ece75279ed7.

* Revert "Fix tests"

This reverts commit 9d37298dbc20392a33338cf45166ad86c556de4b.

* Fix tests

* Update next start message

* Update packages/next/build/output/log.ts

Co-Authored-By: Joe Haddad <timer@zeit.co>

* Fix tests

Co-authored-by: Joe Haddad <timer@zeit.co>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-29 04:49:28 -04:00
JJ Kasper
52686690a9
Add namedRegex and routeKeys to routes manifest (#12250) 2020-04-28 09:59:47 +02:00
Joe Haddad
937884b64e
Fix CSS Identifier Cleaning (#12239) 2020-04-27 10:35:10 -04:00
JJ Kasper
3094016cc3
Downgrade terser to fix invalid minifying (#12178) 2020-04-26 15:16:43 -04:00
Tim Neutkens
5d8968f64a
Remove launched experimental options (#12197) 2020-04-25 21:00:41 +02:00
Tim Neutkens
555ba60544
Run tsconfig paths resolver before PnP (#12104) 2020-04-24 15:50:36 +02:00
JJ Kasper
5d13e55a4a
Ensure modern AMP client page bundles are removed (#12138) 2020-04-23 21:16:35 +02:00
Joe Haddad
5d8709946a
[internal] Dedupe monorepo deps (#12093)
* Dedupe webpack

* Dedupe deps

* Update compiled deps
2020-04-22 01:25:43 -04:00
Joe Haddad
d8c71b1537
Evaluate App before Page in Dev for CSS Ordering (#12090) 2020-04-21 23:55:02 -04:00
Joe Haddad
07b24e6fa1
Upgrade webpack (#12082)
* Upgrade webpack

* rebundle
2020-04-21 16:05:29 -04:00
JJ Kasper
4d193ea33b
Update to only apply experimental process.env stub in developm… (#12055) 2020-04-20 20:25:36 +02:00
Joe Haddad
73b859d53e
Add module.hot.invalidate() to webpack HMR (#12038) 2020-04-20 01:26:27 -04:00
Joe Haddad
450d4bd0f3
Experimental: React Refresh Support (#12008)
* Add Fast Refresh Support

* Add Basic Acceptance Test

* Increase delay

* fix version

* Ignore test files

* Update packages/next/build/webpack/loaders/next-babel-loader.js

* Copy tests

* Redo test style

* drop directory

* fix compile

* fix remove function

* Update helpers
2020-04-19 13:58:31 -04:00
Joe Haddad
4619996d4e
Resolve TypeScript Extension in Correct Order (#12014) 2020-04-19 01:12:36 -04:00
Joe Haddad
55ffb96a36
refactor(next-client-pages-loader): allow toggling router HMR (#11989)
* refactor(next-client-pages-loader): allow toggling router HMR

* Turn on

* Toggle dev properly

* Fix Test Run Order
2020-04-17 22:19:37 -04:00
Joe Haddad
3edfe51861
Strongly Type Usage of Client Pages Loader (#11985) 2020-04-17 16:53:43 -04:00
Joe Haddad
48e2c19de0
Serialize JSON Warnings Before Event (#11976) 2020-04-17 13:38:09 -04:00
Tim Neutkens
511cf748ee
Enable "paths" support by default (#11970)
* Enable "paths" support by default

* Enable NEXT_PUBLIC_ prefix exposing the variable globally

Part of #11106
2020-04-17 16:28:17 +02:00
Tim Neutkens
29c697b36b
Add initial configuration changes for webpack 5 (#11917)
* Disable PnP plugin in webpack 5

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Use full hashes for hot update names

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Disable autodll in webpack 5

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Disable HashedModuleIdsPlugin in webpack 5

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Use regexes for ignoreplugin as it only supports regexes in webpack 5

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* webpack 4 supports resourceRegExp and contextRegExp

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Remove webpack 4 specific properties from the webpack 5 config

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Add library option for webpack 5 support

Co-Authored-By: Zack Jackson <zackary.l.jackson@gmail.com>

* Fix TypeScript Errors

Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-15 14:25:02 -04:00
Joe Haddad
fe09c10383
Upgrade terser-webpack-plugin for Webpack 5 (#11922)
* Upgrade `terser-webpack-plugin` for Webpack 5

* Upgrade again

* cacache cannot be bundled

* cacache cannot be bundled

* fix file

* remove cacache dep

* Update LICENSE
2020-04-15 14:20:25 -04:00
JJ Kasper
20c7b5c50d
Add initial process.env stubbing for new env support (#11893)
* Add initial process.env stubbing for new env support

* Fix server process.env being stubbed in production

* bump

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-15 02:42:37 -04:00
JJ Kasper
2b116cea29
Ensure module not found error is shown with jsconfig paths (#11889)
* Ensure correct module not found error is shown with jsconfig paths

* bump
2020-04-15 02:33:05 -04:00
Scott Parker
67e6cae448
Correct Global and Local CSS Loading Order in Dev (#11901)
* Global styles now load before local in dev

* fix lint

* Adjust tests

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-15 02:32:25 -04:00
JJ Kasper
2b488ab1e1
Fix NEXT_PUBLIC env values not being inlined (#11896)
* Clean up env tests a bit

* Fix NEXT_PUBLIC env values not being inlined

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-15 02:32:03 -04:00
Joe Haddad
b1aa594a80
Handle Potential Promise Rejection in Serverless (#11882) 2020-04-14 11:43:46 -04:00
Joe Haddad
841cd6c4d7
Fix Situation Where Build Can Hang Indefinitely (#11881) 2020-04-14 10:25:24 -04:00
JJ Kasper
d3e308a79f
Add basePath in link component and add/remove it consistently (#9988)
* Add basePath in link component and add/remove it consistently

* Update to not use regex for delBasePath

* Expose addBasePath as router method

* Revert "Expose addBasePath as router method"

This reverts commit 40fed596195c6affabf837e42d472452768e13a3.

* Expose basePath as router field

* Apply suggestion

* Expose basePath as router field

* remove un-used vars

* Update externals

* Apply lint fix

* Update size-limit test

* Update prefetch
2020-04-14 09:50:39 +02:00
Houssein Djirdeh
04ceba4309
Adds first input delay performance metric (#8884)
* measures fid

* updates typings, fixes logic, updates per review comments

* update to es5

* separate clearMeasures

* use relayer

* creates fid polyfll render helper + simplifies measure

* switch to dynamic import

* creates fid experimental flag

* removes unecessary time-to-first-input metric

* removes hydration measure removes

* default flag to false

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-13 14:46:46 -04:00
JJ Kasper
37c98faa01
Make sure to pass through query values for custom routes (#11812) 2020-04-11 12:57:52 +02:00
Joe Haddad
1199c235b1
Externalize next-server from Server Builds (#11819)
* Externalize  from Server Builds

* Windows Compatibility for Plugins

* Only check for windows path on windows

* add comments
2020-04-11 12:36:06 +02:00
JJ Kasper
cd1a2a5949
Handle more invalid CSS class characters (#11809)
* Handle more invalid CSS class characters

* Remove old comment
2020-04-10 10:37:24 -05:00
JJ Kasper
ab4ba0418c
Replace brackets in CSS classes for dynamic routes (#11795) 2020-04-10 12:32:55 +02:00
JJ Kasper
0648c35508
Update auto export opt-out warning and err.sh (#11801) 2020-04-10 12:31:19 +02:00
Joe Haddad
2704387d2e
Add New Provider (#11757) 2020-04-08 16:20:28 -04:00
JJ Kasper
cad2a75649
Make sure to handle "next" import gracefully (#11733)
* Make sure to handle "next" import gracefully

* Update test file
2020-04-07 15:13:01 -04:00
Aaron Reisman
8f4e265f76
Fix Utility Types (#11077) 2020-04-06 17:59:44 +02:00
Aaron Reisman
7a61fb7fdf
Cleanup Build Output Types (#11076) 2020-04-06 17:59:36 +02:00
Aaron Reisman
bddd1ce53e
Update compiler.ts Improve TypeScript typings (#11074)
Improve TypeScript typings
2020-04-06 17:58:35 +02:00
matamatanot
6821d1f8f7
import from compiled (#11684)
Co-authored-by: “kosuke_matano” <kosuke_matano@cyberagent.co.jp>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-04-06 10:24:37 -04:00
JJ Kasper
1cdc607968
Warn when user has pages/_error but no pages/404 (#11603)
* Warn when user has pages/_error but no pages/404

* Update test

* Update custom-error-no-custom-404.md

* Apply suggestions from code review

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

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-04-05 13:19:14 +02:00
JJ Kasper
56118439b7
Update to make sure to respond with 400 for invalid URLs (#11561)
* Update to make sure to respond with 400 for invalid URLs

* Update response text for 400 API error
2020-04-02 09:24:32 +02:00
JJ Kasper
3f6bd47dfb
Update build output with renamed column (#11401)
* Update build output with renamed column

* Update build output test

* Update naming of column

Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-04-01 11:39:25 +02:00
JJ Kasper
d61eced9a6
Update to make sure AMP only bundles are always removed in pro… (#11527) 2020-04-01 10:24:44 +02:00
Tim Neutkens
b8d075ef0e
Update environment support (#11524)
* Remove req.env

* Rename NEXT_APP_ to NEXT_PUBLIC_

* Remove key exposing env config

* Update tests

* Update NEXT_APP_ test to NEXT_PUBLIC_
2020-03-31 17:53:50 +02:00
Guy Bedford
755dc40969 postcss loaders 2020-03-30 16:26:25 -04:00
Guy Bedford
a3ec26d30a ignore-loader 2020-03-30 16:26:25 -04:00
Guy Bedford
8dad5abd66 file-loader 2020-03-30 16:26:25 -04:00
Guy Bedford
c855a3828e babel-loader, cache-loader 2020-03-30 16:26:25 -04:00
Guy Bedford
84a46dfb8c thread-loader 2020-03-30 16:26:25 -04:00
Guy Bedford
40f6bdef32 autodll-webpack-plugin 2020-03-30 16:26:25 -04:00
Guy Bedford
35a6710cdb babel revert 2020-03-30 16:26:25 -04:00
Guy Bedford
c16f60067b path-to-regexp 2020-03-30 16:26:25 -04:00
Guy Bedford
9c2e43a382 find-up 2020-03-30 16:26:25 -04:00
Guy Bedford
202fcbff7a terser 2020-03-30 16:26:25 -04:00
Guy Bedford
7194bfc6a6 string-hash, strip-ansi 2020-03-30 16:26:25 -04:00
Guy Bedford
caa5da7c41 source-map, manifest type fix 2020-03-30 16:26:25 -04:00
Guy Bedford
9615bbd83d recast, babel core sharing 2020-03-30 16:26:25 -04:00
Guy Bedford
26dca225d6 node-fetch, ora 2020-03-30 16:26:25 -04:00
Guy Bedford
4adf4b3300 lodash.curry 2020-03-30 16:26:25 -04:00
Guy Bedford
3b36a3711c json5 2020-03-30 16:26:25 -04:00
Guy Bedford
a34766ab62 gzip-size 2020-03-30 16:26:25 -04:00
Guy Bedford
6a8455e713 escape-string-regexp 2020-03-30 16:26:25 -04:00
Guy Bedford
a9a704e727 devalue 2020-03-30 16:26:25 -04:00
Guy Bedford
af40b5b2f8 chalk, ci-info 2020-03-30 16:26:25 -04:00
Guy Bedford
90a0cef87e browserslist 2020-03-30 16:26:25 -04:00
Guy Bedford
5619f990cf refactor ncc optimization, babel optimization 2020-03-30 16:26:25 -04:00
Tim Neutkens
e7ea27645d Add support for comments in tsconfig.json
Fixes #11390
2020-03-27 11:20:13 +01:00
JJ Kasper
d8155b22ff
Add initial support for new env handling (#10525)
* Add initial support for new env config file

* Fix serverless processEnv call when no env is provided

* Add missing await for test method

* Update env config to .env.json and add dotenv loading

* ncc dotenv package

* Update type

* Update with new discussed behavior removing .env.json

* Update hot-reloader createEntrypoints

* Make sure .env is loaded before next.config.js

* Add tests for all separate .env files

* Remove comments

* Add override tests

* Add test for overriding env vars based on local environment

* Add support for .env.test

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Use chalk for env loaded message

* Remove constant as it’s not needed

* Update test

* Update errsh, taskr, and CNA template ignores

* Make sure to only consider undefined missing

* Remove old .env ignore

* Update to not populate process.env with loaded env

* Add experimental flag and add loading of global env values

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-03-26 13:32:41 +01:00
Tim Neutkens
7774101ad1
Skip paths that are routed to a .d.ts file (#11322) 2020-03-24 12:25:58 +01:00
Joe Haddad
f19dcf9b6e
Add Numeric Separator Support for TypeScript (#11308)
* Add Numeric Separator Support for TypeScript

* Check for number in render
2020-03-23 17:41:35 -05:00
Tim Neutkens
7fce52b905
Add support for paths in tsconfig.json and jsconfig.json (#11293)
* Add support for tsconfig/json `paths` option

* Add tests for paths in tsconfig.json

* Don't apply aliases when paths is empty

* Clean up unused methods and link to TypeScript license

* Add tests for jsconfig

* Put feature under an experimental flag

* Enable to see if tests pass

* Update types

* Add feature under an experimental flag
2020-03-23 10:45:51 -04:00
Dulmandakh
d3fb262958
remove mkdirp, bump fs-extra to 9.0.0 (#11251)
* bump mkdirp to 1.0.3, which support promise

* fix mkdirp in spr-cache.ts

* bump fs-extra to 9.0.0

* remove mkdirp
2020-03-21 17:02:05 +01:00
JJ Kasper
c14d983d54
Ensure hybrid AMP works correctly with SSG (#11205)
* Ensure hybrid AMP works correctly with SSG

* Strip AMP from query when not needed
2020-03-20 09:46:52 +01:00
Tim Neutkens
38e42cd4bb
Add support for baseUrl option in tsconfig and jsconfig (#11203)
* Add support for baseUrl option in tsconfig and jsconfig

* Move jsconfigPath

* Remove filter
2020-03-19 17:34:24 +01:00
JJ Kasper
e28e8ada98
Group CSS files in shared build output separate from JS files (#11184)
* Group CSS files in shared build output separate from JS files

* Fix buildId not being replaced in shared by all
2020-03-19 09:25:10 +01:00
JJ Kasper
836f68aa67
Add CSS file to build output (#11145)
* Remove filtering CSS from build output

* Add displaying page specific CSS files and including them in page size
2020-03-18 09:47:39 +01:00
JJ Kasper
ea7c1e1dcf
Add support for SCSS options (#11063)
* Add support for SCSS includePaths

* Support sassOptions instead of just includePaths

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-03-16 10:55:16 +01:00
Aaron Reisman
85e9ce1b0b
Update preset.ts: Remove any and use updated Node.js types (#11075)
Remove any and use updated Node.js types
2020-03-15 12:22:53 +01:00
JJ Kasper
71f97198d1
Add support for static 404 when _error does not have custom GIP (#11062)
* Add support for static 404 when _error does not have custom GIP

* Update tests
2020-03-14 09:58:20 +01:00
Joe Haddad
18036d4e51
Correct Cache-Control Behavior for GS(S)P (#11022)
* Correct Cache-Control Behavior for GS(S)P

* remove old line

* fix test
2020-03-13 10:40:10 +01:00
JJ Kasper
ccb6ce7ed4
Add support for getStaticProps in pages/404 (#10984)
* Make sure to not show pages/404 GIP error from _app having GIP

* Add error for getStaticProps in pages/404 too

* Add support for getStaticProps in pages/404

* Update test
2020-03-12 10:48:14 +01:00
JJ Kasper
fde1ce2924
Add warning when built-in CSS/SCSS support is disabled (#10942) 2020-03-10 14:29:40 -04:00
Joe Haddad
8443a809f3
Verify GS(S)P Serializability (#10857)
* Verify GS(S)P Serializability

* Add support for cyclic refs

* Add unit tests

* Test for error in development mode

* Fix prerender preview tests

* Fix gssp preview tests

* fix 2x test cases

* Add desired test

* fix some more tests

* Fix route manifest expect

* Fix test expects

* Test that `getServerSideProps` does not error in production

* Test that getStaticProps is not checked in production

* Test serialization check during build

* Fix export detection for serverless

* Update test/unit/is-serializable-props.test.js

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-09 13:30:44 -04:00
JJ Kasper
b274fe39d3
Update method for attaching GS(S)P identifier to page (#10859)
* Update to use separate export instead of attaching to Component to identify GS(S)P pages

* Handle initialProps being undefined
2020-03-05 23:15:10 -05:00
Joe Haddad
a5d0cb9d80
Measure getStaticProps, getServerSideProps (#10800)
* Measure `getStaticProps`, `getServerSideProps`

* Test new fields
2020-03-02 19:01:12 -05:00
Prateek Bhatnagar
16672a4353
Adding conformance checks (#10314)
* adding tests  for rect sync conformance check

* adding test for react sync script conformance check

* reverting yarn lock changes

* adding duplicate polyfill conformance

* bug fixes in dulpicate polyfill conformance check

* adding settings capability to conformance plugin

* removing minification check from server build

* bug fix

* settings for react sync script check
2020-03-02 22:53:18 +01:00
JJ Kasper
9ec3dae607
Fix next/config module mismatch in new serverless mode (#10792)
* Add failing test case

* Update serverless-loader require to fix config module mismatch

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-03-02 12:38:16 -05:00
Joe Haddad
990eda2c88
Prefetch SSG Data (#10127)
* Prefetch SSG Data

* Update packages/next/client/page-loader.js

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

* Revert router.ts

* Revert link.tsx

* undo change

* mimmic existing

* simplify

* Prefetch href and asPath

* fix load

* dedupe prefetchAs

* Inject script tag on hover

* comment prefetchAs

* minify code

* introduce lazy files

* Add some breathing room

* correct default type

* Prefetch non-dynamic data

* Prefetch dynamic route data

* Fix size test

* Humanize code

* add tests

* Disable code

* Only generate modern version in modern mode

* Extract function helper

* add comments

* Filter out dynamic route to simplify manifest size

* add test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-02 12:14:40 -05:00
Joe Haddad
e608c86b59
Separate Low Priority Files from Main Files (#10756)
* Separate Low Priority Files from Main Files

* Fix tests
2020-02-29 17:09:42 -05:00
Janicklas Ralph
7848615bd6
Fix url-polyfill dep and re-enable native-url (#10726)
* Adding native-url package

* Bumping native-url version

* Upgrading native-url

* Logging stats object for debugging

* Logging stats object for debugging

* Adding try catch to the error lines

* Experimenting with regex

* Experimenting with regex

* Experimenting with regex

* Testing regex changes

* Fixing defer-script test case to not include polyfill.js

* Meging changes with existing polyfill work

* Bumping version

* adjust webpack config

* Reduce size in size test

* Remove 1kb from legacy

* Bumping native-url version, includes fix for IE11

* Update lock file

* Updating native-url, fixes issue on IE11

* Fix sourcemap being added in document

* Adding Router as an app level dep. Fixes Router not being added as a dep to pages without Link when granularChunks is enabled

* Fix typescript error

* Fix modern + granularChunks hydration failing

* Fix TS error

* Update native-url version

* Adding native-url with safari fix

* Update url-polyfill in polyfill-nomodule package

* Remove url-polyfill from next package.json

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-27 22:08:58 -05:00
JJ Kasper
c9d9f1131c
Remove unstable_ prefix from new methods (#10723)
* Rename getServerProps to getServerSideProps

* Remove unstable_ prefix from new methods

* Add error when legacy methods are detected

* Add legacy methods for babel transform

* Add unstable_getServerSideProps also

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>

* Update types import

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-27 11:57:39 -06:00
JJ Kasper
2789e7e0c2
Rename getServerProps to getServerSideProps (#10722) 2020-02-27 11:04:30 -06:00
Joe Haddad
663f5c4b6e
Fix Error Message 2020-02-27 09:25:17 -05:00
Joe Haddad
47ff1eb95a
Ability to Disable SSG Fallback (#10701)
* Ability to Disable SSG Fallback

* Throw error when value is missing

* Fix existing tests

* Adjust error message

* Do not render fallback at build time for `fallback: false` page

* Fix existing fallback behavior

* fix build

* fix version

* fix some tests

* Fix last test

* Add docs for get static paths

* Add explicit mode tests

* test for fallback error message
2020-02-27 13:23:28 +01:00
JJ Kasper
6dea45bdc9
Add dataRoutes field to routes-manifest for SSG and serverProps routes (#10622)
* Add dataRoutes field to routes-manifest for SSG and serverProps routes

* Update routes-manifest test
2020-02-26 14:35:02 -05:00
JJ Kasper
395714a475
Update url prop handling for pages with new data methods (#10653)
* Make sure to show error when url prop is returned for a page

* Update test and handle undefined pageProps

* Handle empty props

* Apply suggestions from code review

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

* Update tests

* Update to not add url prop for SSG/SSP pages

* Update errsh for reserved prop

* Update errsh wording some more

* Update tests and to warn instead of error

* Update reserved prop warning

* Include page in url prop warning

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-26 13:26:55 -05:00
JJ Kasper
364b4fe797
Make sure rewrites are handled in serverless mode correctly (#10697)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-26 13:14:34 -05:00
JJ Kasper
40abd708e1
Show better error when non-array is returned from custom-routes (#10670)
* Show better error when non-array is returned from custom-routes

* bump

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-24 17:01:02 -05:00
JJ Kasper
f17e170c3d
Add calling getStaticPaths in development before showing fallback (#10611)
* Add calling getStaticPaths in development before showing fallback

* Move staticPathsWorker to next-dev-server

* Make sure to clear require cache in worker process

* bump

* Remove staticPathsCache member

* Update numWorkers for staticPathsWorker
2020-02-24 16:36:59 -05:00
Joe Haddad
c3d914919a
Fix Double URL Encoding for Serverless (#10663) 2020-02-24 13:06:11 -05:00
Joe Haddad
89c792f67f
Preview Mode Should Not Cache (#10636)
* Preview Mode Should Not Cache

* add import

* fix import

* add tests

* Add real serverless mode tests
2020-02-22 10:26:39 +01:00
Joe Haddad
40217b75b9
Revert "Re-Enable Native url Module (#10530)" (#10623)
This reverts commit b329f6a2d6.
2020-02-21 01:16:07 -05:00
JJ Kasper
f5cb1a69d7
Add error messages for dynamic SSG page without getStaticPaths (#10620)
* Add error messages for dynamic SSG page without getStaticPaths

* Update error check

* Update test file

* Update another test file

* Adjust

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-21 00:57:10 -05:00
Janicklas Ralph
b329f6a2d6
Re-Enable Native url Module (#10530)
* Adding native-url package

* Bumping native-url version

* Upgrading native-url

* Logging stats object for debugging

* Logging stats object for debugging

* Adding try catch to the error lines

* Experimenting with regex

* Experimenting with regex

* Experimenting with regex

* Testing regex changes

* Fixing defer-script test case to not include polyfill.js

* Meging changes with existing polyfill work

* Bumping version

* adjust webpack config

* Reduce size in size test

* Remove 1kb from legacy

* Bumping native-url version, includes fix for IE11

* Update lock file

* Updating native-url, fixes issue on IE11

* Fix sourcemap being added in document

* Adding Router as an app level dep. Fixes Router not being added as a dep to pages without Link when granularChunks is enabled

* Fix typescript error

* Fix modern + granularChunks hydration failing

* Fix TS error

* Update native-url version

* Adding native-url with safari fix

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-21 00:25:49 -05:00
Tim Neutkens
e9e1a2b900
Disable setImmediate polyfill (#10612)
* Disable setImmediate polyfill

* Update size-limit

Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-02-20 12:52:28 -05:00
JJ Kasper
db445db790
Add err.sh for invalid getStaticPaths return value (#10605)
* Add err.sh for invalid getStaticPaths return value

* Update error link

* Apply suggestions from code review

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-02-20 10:05:49 +01:00
Tim Neutkens
9a0d82b4d9
Clean up landed experimental flags (#10593)
* Clean up landed experimental flags

* Remove check for experimental flags from build too

* Remove /_errors/404 in favor of /404

* Remove unneeded check for pathname

* Update test paths

* Fix test

* Update test

* Remove test for disabled config

* Set pages404 always to true

Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-02-19 14:54:38 -05:00
Joe Haddad
5e12e5f56a
Emit ES5 Friendly Code in Program#exit Visitor (#10591)
* Emit ES5 Friendly Code in Program#exit Visitor

* Document reasoning

* updt

* Update next-ssg-transform.ts
2020-02-19 11:29:30 -05:00
JJ Kasper
2a0843349c
Update error message for invalid return value from getStaticPaths (#10580) 2020-02-19 00:20:45 -06:00
Tim Neutkens
0222a09cd0
Enable polyfillsOptimization (#10574)
* Enable polyfillsOptimization

* Update sizes

* Commons is no longer there

* Update test
2020-02-18 19:26:55 +01:00
Jan Potoms
3f691eaa45
Remove ts-ignore where possible (#10541)
* Remove ts-ignore where possible

And replace by typecasts

* More accurate types

* bend cliententries in a correct shape earlier on

* comment becomes unnecessary

* add webpack overload to allow for the next.js use case

* Avoid changing public interface

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-17 16:16:19 -05:00
Joe Haddad
1c247b5cf1
Check next.config.js settings (#10425)
* Check next.config.js settings

* Add tests

* test package.json case too
2020-02-14 15:42:44 -05:00
Joe Haddad
71019e70d3
Remove native-url Again (#10526)
* Remove `native-url` Again

* update comment

* update sizes
2020-02-13 17:54:25 -05:00
JJ Kasper
4617950457
Add handling for default as named export in SSG transform (#10486)
* Add failing SSG syntax

* Add handling for default as named export in SSG transform

* Revert [comment].js

* Revert index.js

* adjust

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-13 00:25:44 -05:00
Jan Potoms
0b12e2e859
Improve error for invalid page configurations (#10441)
* Remove any type and fix edge cases

Removed the "as any" and use the @babel/types typeguards instead. This revealed some edge cases that would just error.

* Remove ts-ignore

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-12 23:39:51 -05:00
Joe Haddad
e38e3dd55a
Adjust SSG Loading Behavior (#10510)
* Adjust SSG Loading Behavior

* Update expected preview behavior

* Rename two corrections

* Only use skeleton in production for now

* Fix "should SSR SPR page correctly" test

* fix tests

* fix trailing comment letter

* disable test for now
2020-02-12 20:06:07 -05:00
Joe Haddad
3cb3498324
SSG Preview Mode (#10459)
* checkpoint: api impl

* Add support for tryGetPreviewData

* snapshot: server(less) support

* Add X-Prerender-Bypass-Mode header support

* Pass preview data to getStaticProps call

* add TODO

* setPreviewData

* 100k iterations

* Handle jwt error

* Write out preview values

* forgot file

* set preview props

* Send preview props

* add preview props

* Pass around more data

* update yarn lock

* Fail on Invalid Prerender Manifest

* Make Missing Prerender Manifest Fatal

* fix ts errors

* fix test

* Fix setting cookies + maxage

* Secure is not needed as we encrypt necessary data

* Set on domain root

* Set cookie max ages

* Render a fallback on-demand for non-dynamic pages

* Test preview mode

* remove old build

* remove snapshots

* Add serverless tests

* use afterAll

* Remove object assigns

* fix cookie spread

* add comment
2020-02-11 20:16:42 -05:00
Joe Haddad
79fb13e587
Builds with Warnings Still Complete (#10498) 2020-02-11 17:09:00 -05:00
Joe Haddad
14f33dd54f
Make Missing Prerender Manifest Fatal (#10485)
* Fail on Invalid Prerender Manifest

* Make Missing Prerender Manifest Fatal

* fix test
2020-02-10 17:43:34 -05:00
JJ Kasper
f6e7a38101
Add paths field for unstable_getStaticPaths (#10454)
* Add paths field for unstable_getStaticPaths

* Make sure to specify page in getStaticPaths errors
2020-02-07 22:09:54 -05:00
JJ Kasper
9dc0afd9b9
Redesign custom-routes output and show headers in output (#10444) 2020-02-07 16:06:02 +01:00
JJ Kasper
3099f0881a
Add initial SSG fallback handling (#10424)
* Add initial SSG fallback handling

* Remove extra changes and update fallback handling

* Remove extra timeout for testing

* Update SSG tests in dynamic-routing suite

* Add racing to decide between rendering fallback and data

* Update size-limit test

* Update comment

* Make sure to follow correct route change order

* Make comment more verbose for racing

* Revert getStaticData to only return Promise

* Make sure to update URL on fallback

* Add retrying for data, de-dupe initial fallback request, and merge fallback replace

* Update to add preload for fallback pages data

* Add test for data preload link

* Use pre-built fallback in production mode

* Remove preload link for fallback from _document

* Update to make sure fallback is rendered correctly for serverless
2020-02-07 14:09:06 +01:00
JJ Kasper
238202ec11
Make missing param error message more specific (#10433) 2020-02-05 15:27:22 -06:00
JJ Kasper
a4c507d5b4
Update to use existing util to de-dupe path check (#10431)
* Update to use existing util to de-dupe path check

* Update error message for requested/resolved mismatch

* Use correct dataRoute value for prerender manifest

* Fix pageUrl having double slash on Windows
2020-02-05 22:10:39 +01:00
JJ Kasper
5ae7fe534e
De-dupe paths returned in getStaticPaths (#10423)
* De-dupe paths returned in getStaticPaths

* Remove warning
2020-02-04 21:55:11 -05:00
JJ Kasper
ec39aa46dc
Update optimize event with static 404 status (#10420)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-04 15:10:40 -05:00
Joe Haddad
ecd628b7e0
Re-enable native-url (#10419)
* Re-enable `native-url`

* update sizes
2020-02-04 14:58:22 -05:00
Alex Castle
21fea2ce61
Modify splitChunksPlugin to give shared CSS chunks different names (#10408)
* Modify splitChunksPlugin to give shared CSS chunks different names

* fix lint

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-04 14:22:26 -05:00
Joe Haddad
bc81379618
Detect Invalid Pages Before Optimize (#10418) 2020-02-04 13:55:43 -05:00
Luis Alvarez D
909ab3b179
Check for invalid pages (#10403)
* Updated event

* adjust regex

* adjust regexp more

* Better test file regex

* add tests

* Update index.test.js

* Rename test file

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-04 10:46:22 -05:00
Joe Haddad
3d507abe0c
Remove Old Records (#10398) 2020-02-03 11:41:43 -05:00
JJ Kasper
c01534c92e
Make sure runtime config is set before any imports for serverless (#10386)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-02 22:33:53 -05:00
Luis Durão
a433b9be6a
Fix bug in catch-all routes with SSG (#10379)
* Fix bug in catch-all routes with SSG

* fix slash

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-02 22:07:45 -05:00
JJ Kasper
db90ffe1ea
Implement experimental pages/404.js for custom 404 page (#10329)
* Implement experimental pages/404.js for custom 404 page

* Make sure to show error for getInitialProps in pages/404 in dev mode also

* Update routes-manifest tests for new value

* Make sure page404 is boolean in routes-manifest

* Rename variables for consistency

* Make sure to only use 404 page for 404 error
2020-02-01 15:47:42 +01:00
JJ Kasper
afc278f567
Add support for runtimeConfigs in serverless mode (#10365)
* Add support for runtimeConfigs in serverless mode

* Update test
2020-02-01 14:24:22 +01:00
Tim Neutkens
e35005c214
[Experimental] Nomodule polyfills chunk (#10212)
* Polyfill Promise in polyfills chunk

* Override promise polyfill to use built-in

* Update sizes

* Update polyfills

* Test

* Add dep

* Use iife

* Unscope

* Revert "Unscope"

This reverts commit ab26bcefd551c544d5b3c577b7ce91e5ecfb9bb9.

* trigger

* Remove unused code

* Set helpers to true

* Update yarn.lock

* Fix test

* Update polyfills size

* Add comment

* Add back comment

* Put polyfills optimization under experimental flag

* Fix filename

* bring back promise for backwards compat until experimental feature is landed

* fix resolve alias check

* correct loader

* fix logic branches

* adjust !!

* adjust cache key

* Conditionally branch polyfill

* fix promise polyfill branching

* Re-add runtime

* fix base object

* fix yarn lock

* Add cache key

* correctly set caller

* add basic test

* Increment h=>i

* increment to j just in case

Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-30 01:04:29 -05:00
Alexander Dreith
bd3662b52b Fix preprocessor loader error (#10235)
* Run resolve-url-loader after sass-loader

* Add regression test

* Update test to match

* Revert global.ts

* Make `preProcessors` readonly

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-28 16:31:38 -05:00
JJ Kasper
c24daa2172 Add initial support for unstable_getServerProps (#10077)
* Add support for unstable_getServerProps

* Apply suggestions from review

* Add no-cache header and update types

* Revert sharing of load-components type

* Add catchall test and update routes-manifest field

* Update header check

* Update to pass query for getServerProps data requests

* Update to not cache getServerProps requests

* Rename server side props identifier

* Update to nest props for getServerProps

* Add no-cache header in serverless-loader also

* Update to throw error for mixed SSG/serverProps earlier

* Add comment explaining params chosing in serverless-loader

* Update invalidKeysMsg to return a string and inline throwing

* Inline throwing mixed SSG/serverProps error

* Update setting cache header in serverless-loader

* Add separate getServerData method in router

* Update checkIsSSG -> isDataIdentifier

* Refactor router getData back to ternary

* Apply suggestions to build/index.ts

* drop return

* De-dupe extra escape regex

* Add param test
2020-01-27 17:50:59 -05:00
Joe Haddad
abd69ec4be
Fix Experimental Modern Mode with CSS (#10289) 2020-01-27 15:32:45 -05:00
James Mosier
c9dc17b852 Added support for BigInt to API routes (#10215)
* Added support for bigint to API routes

Closes #7980

* added BigInt test to get result

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-27 08:19:49 -05:00
JJ Kasper
2ff2e9e12c Update _next/data URL handling in serverless-loader (#10261)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-24 23:34:00 -05:00
JJ Kasper
f143ca63be Update SSG types and clean up RenderOpts type (#10259)
* Update SSG types and clean up RenderOpts type

* Move SSG types back to internal module
2020-01-24 23:25:11 -05:00
JJ Kasper
e079cce41c
Update static check vars and fix types (#10260)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-24 17:41:00 -06:00
JJ Kasper
8579888cec De-dupe escape-regex with escape-string-regexp (#10257)
* De-dupe escape-regex with escape-string-regex

* Un de-dupe for client-side file
2020-01-24 18:27:39 -05:00
Joe Haddad
3f9b930815
Error on Invalid PostCSS Shape (#10244)
* Error on Invalid PostCSS Shape

* Add link to docs
2020-01-23 16:27:07 -05:00
Prateek Bhatnagar
0edd6a031a Adding conformance webpack plugin (#9716)
* adding Conformance Plugin behind a flag

* fixing compiler ts error

* fixing spelling errors 🤦🏻‍♂️

* addressing comments

* bug fix

* making it const enum

* reverting const enum

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-23 16:09:12 -05:00
Joe Haddad
32ded0539e
PostCSS Error When Exporting Function (#10242)
* PostCSS Error When Exporting Function

* Update postcss-function.md
2020-01-23 15:39:50 -05:00
Joe Haddad
c713741f51
Explain Ignored PostCSS Plugin (#10240) 2020-01-23 15:28:37 -05:00
Joe Haddad
3c3186efb5
Revert "feat(build): Transpile assuming higher version of runt… (#10233)
This reverts commit 6b87b2b541.
2020-01-23 09:04:46 -05:00
Alexander Dreith
8449ebc221 [Experimental] Add built-in Sass support (#10133)
* Add built-in Sass support

* Add copy of CSS tests for SCSS

* Fix failing tests

* Fix url-loader tests

* Remove css file generated by tests

* Fix nprogress import for css file

* Fix SCSS modules (still 2 tests that need investigating)

* Update documentation for Sass support

* Fix plain CSS import test

* Fix formatting with prettier fix

* Update test output to reflect scss usage

* Revert "Fix plain CSS import test"

This reverts commit 380319d9d0c4bfb19e28c210262ccd82d19f3556.

# Conflicts:
#	test/integration/scss-modules/test/index.test.js

* Update loader structure

* Resolve loaders before passing to compile function

* Remove dead filter  code

* Arrange loaders in order and push to array

* Fix loader order bug

* Fix global Sass loader and make module prepocessor optional

* Adjust Sass Modules Implementation

* Fix typo

* Adjust regexps

* Use regexes

* Simplify global setup

* Adjust comments

* fix regex

* Simplify identifier file

* Update Sass Instructions

* Remove unneeded fixtures

* Adjust global tests

* Remove wrapper

* Update source maps

* Flag scss behavior

* Fix css property value

* Update fixtures with Sass vars

* Turn on Scss support

* fix HMR test

* Fix snapshots

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-22 15:26:51 -05:00
Joe Haddad
f67f99a295 Extract CSS Loaders into Separate Files (#10210) 2020-01-22 09:50:27 -06:00
Joe Haddad
4a2236dac3
Dedupe CSS Regexes (#10206) 2020-01-22 09:50:30 -05:00
Joe Haddad
a3f1d65eba
Fix ESLint Ignores and Extract Fn (#10205) 2020-01-22 09:32:51 -05:00
Tim Neutkens
fa65442cad Disable core-js for server-side build (#10189)
* Disable core-js in server-side build

* Update cache-key

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-21 09:47:20 -05:00
JJ Kasper
5f5c5e4e9e Add support for catch-all routes with SSG (#10175)
* Add support for catchall routes with SSG

* Add test for invalid catchall param in getStaticPaths
2020-01-20 16:44:50 -05:00
Sebastian Silbermann
6b87b2b541 feat(build): Transpile assuming higher version of runtime (#9511)
* feat(build): Transpile assuming higher version of runtime

* Use runtime version from manifest

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-20 21:40:59 +01:00
Joe Haddad
2e668e6b31
Remove native-url (#10176)
* Remove `native-url`

* Increase sizes
2020-01-20 14:47:42 -05:00
JJ Kasper
e04e5a5c15 Add initial support for static 404 page (#10113)
* Add initial support for static 404 page

* Apply suggestions from code review

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

* Simplify custom error page check

* Add comment explaining reason for custom app check

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-01-20 15:10:24 +01:00
JJ Kasper
5a9a478cc8
Fix hydration with custom _app and granular chunks (#10144)
* Add failing hydration test

* Add importing of next/router to _app

* Fix type

* Update _app check for windows

* Remove babel fix

* Update to use webpack to require next/router
2020-01-17 14:13:51 -06:00
JJ Kasper
22e015f7b6 Support unnamed parameters in custom-routes correctly (#9920)
* Support unnamed parameters in custom-routes correctly

* Update unnamed params checking to be strict

* Removed un-used regexKeys

* Update test routes

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-16 17:38:38 -05:00
Josh Larson
80ed74bcae Add specific warning for require() PostCSS plugin (#10121) 2020-01-16 00:09:56 -05:00
Joe Haddad
57ec121d48
Rename Build SPR to SSG (#10114) 2020-01-15 15:57:07 -05:00
Joe Haddad
41195b69e1
Fix Legacy CSS with Granular Chunks (#10101) 2020-01-14 23:02:49 -05:00
JJ Kasper
fff897d766 Apply some renames for SSG related code (#10099)
* Rename some spr related stuff to ssg

* Update packages/next/lib/constants.ts

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 20:22:15 -05:00
Joe Haddad
d9d9545f30
Error on CSS in Custom Document (#10091) 2020-01-14 14:53:42 -05:00
Joe Haddad
2d76c4a9bb
Replace __NEXT_SPR with __N_SSG Identifier (#10090) 2020-01-14 14:40:20 -05:00
JJ Kasper
84264f8179 Add required permanent: boolean field to redirect (#10044)
* Add permanent field for redirects

* Update printing redirect status code

* Don't add permanent to routes-manifest

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 13:28:48 -05:00
Janicklas Ralph
415a9b6d1e Fix modern + granularChunk hydration failing (#9727)
* Adding native-url package

* Bumping native-url version

* Upgrading native-url

* Logging stats object for debugging

* Logging stats object for debugging

* Adding try catch to the error lines

* Experimenting with regex

* Experimenting with regex

* Experimenting with regex

* Testing regex changes

* Fixing defer-script test case to not include polyfill.js

* Meging changes with existing polyfill work

* Bumping version

* adjust webpack config

* Reduce size in size test

* Remove 1kb from legacy

* Bumping native-url version, includes fix for IE11

* Update lock file

* Updating native-url, fixes issue on IE11

* Fix sourcemap being added in document

* Adding Router as an app level dep. Fixes Router not being added as a dep to pages without Link when granularChunks is enabled

* Fix typescript error

* Fix modern + granularChunks hydration failing

* Fix TS error

* Update native-url version

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 13:10:16 -05:00
James George
7f25fb6cf6 chore: Minor code refactor to eliminate redundant code (#10051) 2020-01-14 10:40:45 +01:00
Joe Haddad
9f6fdb95f2
Ignore CSS Ordering Warnings (#10068) 2020-01-13 07:48:24 -05:00
Joe Haddad
a7a924f2a4 Disable New CSS For Sass, Less, and Stylus (#10043) 2020-01-10 15:07:06 -06:00
Joe Haddad
243c038222
docs(errors): CSS Modules Imported by a Dependency (#10034) 2020-01-10 11:45:01 -05:00
Joe Haddad
dd020fb888
docs(errors): CSS Imported by a Dependency (#10032) 2020-01-10 10:40:28 -05:00
Joe Haddad
fa81a4df83 Add Links to Global CSS Error (#10031)
* Add Links to Global CSS Error

* Add Example
2020-01-10 09:31:38 -06:00
Joe Haddad
5d3303f50a
Ensure Build Output Does Not Contain <buildId> (#10021)
* Ensure Build Output Does Not Contain `<buildId>`

* use posix join for common file
2020-01-09 17:31:03 -05:00
Joe Haddad
345efa3ea8 Keep Chunk Hash in Build Output (#10020) 2020-01-09 15:44:47 -06:00
Joe Haddad
0fd15ad6ba
Separate Self Size and First Load Size (#10014)
* Separate Self Size and First Load Size

* Tweak tests
2020-01-09 13:49:52 -05:00
Afzal Sayed
58b2d9e208 Use optional chaining syntax (#9975)
* Use optional chaining syntax

* Changes as per review

* Bug fix
2020-01-08 11:30:53 -05:00
Joe Haddad
1c6f0874ce Test That Custom Properties Are Not Compiled (#9984)
* Fix Browserslist Loading

* Fix Browserslist Integration for CSS

* Add missing file

* Test That Custom Properties Are Not Compiled

* Disable custom properties transform
2020-01-08 12:06:16 +01:00
Joe Haddad
8686fca6a4
Fix Browserslist Integration for CSS (#9985)
* Fix Browserslist Loading

* Fix Browserslist Integration for CSS

* Add missing file
2020-01-07 16:59:58 -05:00
Joe Haddad
2757826cf7
Use <script defer> by default, matching <script type=module> (#9966)
* Use `<script defer>` by default, matching `<script module>` behavior

* remove old test
2020-01-06 14:55:08 -05:00
Felix Mosheev
dea80b8565 Allow libs that ends with next/dist such as i18next, next-i18next, react-i18next to be external (#9956)
fixes #9022

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-06 14:27:36 -05:00
Tim Neutkens
1fd57d22d5
Remove experiment (#9945)
* Remove experiment

* Add back ssr-prepass for serverless test

* Update size as they both decreased

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-04 17:40:18 +01:00
Joe Haddad
878ee56bb9
Fix New CSS Support Media Paths (#9916)
* Fix CSS Media Paths

* update test

* Use absolute path

* Add new tests

* fix import
2020-01-03 12:45:04 -05:00
Tim Neutkens
c8799f9e7d
Enable catchAllRouting by default (#9922) 2020-01-03 16:51:26 +01:00
JJ Kasper
ad7bb4e352 Add headers support to custom-routes (#9879)
* Add headers support to custom-routes

* Update manifest version test

* Add headers field for dynamic routes test

* Update test
2020-01-01 13:47:58 +01:00
JJ Kasper
8132524d24
Revert version bump for routes-manifest (#9896) 2019-12-31 16:06:09 -06:00
Joe Haddad
8247f19f10 Defer Loading CSS Configuration (#9889) 2019-12-30 17:53:35 -06:00
JJ Kasper
148084006a Add basePath to routes-manifest (#9875)
* Add basePath to routes-manifest

* Bump routes-manifest version

* Update tests for version bump
2019-12-30 11:23:26 +01:00
Tim Neutkens
86808bbce2
Add basePath support (#9872)
* Add basePath support

* Add tests including copy of HMR tests

* Add production tests

* Add tests for serverless target

* Add missing quotes
2019-12-29 20:03:12 +01:00
Joe Haddad
be3b5b7c5f Register Created Bindings (#9864) 2019-12-28 16:01:01 -06:00
Joe Haddad
edf63e597d Expose CSS Issuer When Error (#9850)
* Expose CSS Issuer When Error
This introduces a friendlier error for invalid CSS imports by telling you the offending file.

---

Fixes #9847

* fix test matches
2019-12-27 13:56:33 -06:00
Joe Haddad
14b18da055
Special Global CSS Error within node_modules (#9849) 2019-12-27 13:35:37 -05:00
Joe Haddad
a56d9a918c Do Not Run File Loader on Server (#9843) 2019-12-26 16:17:37 -06:00
Jason Miller
93c745c2b7 [Experimental] Move Babel transpile into a cached thread pool (#9331)
* Add cached off-thread babel transpile

* Update webpack-config.ts

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2019-12-24 16:58:50 +01:00
Joe Haddad
632e40f266
Optimize Prefetching (#9818)
* Optimize Prefetching

* fix css client nav test

* fix preload viewport test

* fix production test

* patch tests more

* Make page loader wait on prefetch

* no unhandled rejection

* Save some bytes
2019-12-24 10:07:44 -05:00
JJ Kasper
b9865ba32e Add checking filesystem after each rewrite (#9568)
* Add check: true behavior to custom routes

* Update adding dev routes

* Add checking of pages and dynamic routes for check: true

* Fix hasPage binding

* Add tests for check: true behavior

* Update regex checking

* Make changes based on review

* Update to handle rewrites in serverless loader

* Update to not change req.url

* Make sure to always parse dynamic route params

* Export all of pathToRegexp from path-match

Co-authored-by: Joe Haddad <timer150@gmail.com>
2019-12-23 16:20:17 -05:00
Joe Haddad
5c3f9ba745 Add Specific Error for Function in PostCSS Config (#9815) 2019-12-23 14:43:38 -06:00
Lachlan Campbell
8e1046d94a Fix error message typo: "Keys that need moved" (#9772) 2019-12-17 14:25:02 -10:00
JJ Kasper
fd95d6c8bc
Fix AMP HMR for child components (#9736) 2019-12-16 11:45:48 -06:00
JJ Kasper
a32af59e93 Fix Shared Sizes Missing Commons (#9752)
* Fix shared sizes missing commons

* Add tests
2019-12-14 12:23:04 -07:00
Tim Neutkens
950d67b721
Add experiment for prefetching (#9747) 2019-12-14 11:21:48 +01:00
Joe Haddad
845dc0827d Compute Gzip Sizes of Files (#9745) 2019-12-14 00:39:59 -06:00
JJ Kasper
6fcb6230d2 Add support for exporting from serverless build (#9744)
* Add support for exporting from serverless build

* Add more tests

* Update syntax

* Dont add dynamic params in worker

* Update amphtml rel for serverless tests

* Update tests again

* Update dynamic params populating

* Fix params parsing

* Pass params separately
2019-12-14 01:31:48 -05:00
Joe Haddad
32cb5e105a Disable CSS Support When Manually Configured (#9735)
* Disable CSS Support When Manually Configured

* upgrade TS

* adjust yarn lock

* Remove another version of TypeScript

* Remove possibly leftover loader

* Revert "Remove possibly leftover loader"

This reverts commit 7ce2d1a8854f3d7a833867f8ac3be7923a6cb1d8.

* Update to use no-op loader
2019-12-13 14:23:28 -06:00
Joe Haddad
62a6ece4b9 Emit Static Export Intent (#9737)
* Emit Static Export Intent

* Remove the old export detail on rebuild

* Add test cases

* fix export

* Add a resolve return
2019-12-13 13:30:22 -06:00
Joe Haddad
88de2328e5 Enable Page Symbol For /_error (#9730) 2019-12-13 14:45:15 +01:00
Joe Haddad
1a0a76c011 New File Size Output (#9726)
* New File Size Output

* fix test
2019-12-12 20:44:34 +01:00
Joe Haddad
a133f850fa Refine Pages Output (#9725) 2019-12-12 17:20:24 +01:00
Joe Haddad
5b57a7527d Improve Build Output for SSG (#9719)
* Improve Build Output for SSG

* Swap out symbols and reasons

* adjust text more

* Add test

* Expect more output lines

* fix test case
2019-12-12 10:45:45 +01:00
Joe Haddad
c4c3173297
Fix CSS Modules Relative Path on Windows (#9709) 2019-12-11 14:21:40 -05:00
Joe Haddad
179e627a36
Redesign PostCSS Configuration Loading (#9704)
* Redesign PostCSS Configuration Loading

* Test array configuration

* Test new configuration handling

* Remove unnecessary async
2019-12-11 11:51:10 -05:00
Joe Haddad
a6dc0e1603 Adjust postcss-modules Message (#9703) 2019-12-11 09:23:06 -06:00
Joe Haddad
734989d836 [Experimental] CSS Module Support (#9686)
* CSS Module Support

* Fix Server-Side Render of CSS Modules

* Fix Jest Snapshots
https://github.com/facebook/jest/pull/8492

* Fix snapshots

* Add test for CSS module edit without remounting

* Add tests for dev and production style being applied

* Add missing TODOs

* Include/exclude should only be applied to issuer, not the CSS file itself

* Add CSS modules + node_modules tests

* Test that content is correct

* Create Multi Module Suite

* Add client-side navigation support for CSS

* Add tests for client-side nav

* Add some delays

* Try another fix

* Increase timeout to 3 minutes

* Fix test

* Give all unique directories
2019-12-11 11:46:12 +01:00
JJ Kasper
83eeda085b Fix not detecting legacy getStaticParams in serverless mode (#9685)
* Fix not detecting legacy getStaticParams in serverless mode

* Update test/integration/prerender-legacy/test/index.test.js
2019-12-10 14:30:22 -05:00
JJ Kasper
6c103ef5a6 Add checking of custom routes for invalid fields (#9434)
* Add checking of custom routes for invalid fields

* Remove un-used test imports

* Mentioned statusCode can be undefined in error message

* Update test

* Update invalid routes output

* Add checking to make sure source/destination start with slash

* Update import
2019-12-10 09:54:56 -05:00
Joe Haddad
9b6ea9d466 Refactor Webpack Configuration (#9651)
* WIP

* Move data experiment

* Do not throw away rules

* Remove test code

* Correct next data behavior

* Add support for async composing

* Remove unnecessary workaround

* Rename Field
2019-12-09 14:08:15 -06:00
JJ Kasper
963d598dc1
Add tests for optional chaining and nullish coalescing (#9665)
* Add tests for optional chaining and nullish coalescing

* Add integration tests
2019-12-08 12:38:22 -06:00
Sayuti Daniel
26a6a37316 feat: optional chaining and nullish coalescing (#9615) 2019-12-08 12:46:44 +01:00
Joe Haddad
ed1a9450f0 Disable SSG Transform on Non-SSG Pages (#9657)
* Disable SSG Transform on Non-SSG Pages

* correct test
2019-12-07 00:03:29 -06:00
Joe Haddad
04b2f0ebe1
Use Real Identifier for SSG Transform (#9656) 2019-12-07 00:52:24 -05:00
Joe Haddad
cbf8e0b2c4
Bump Babel Cache Key (#9655) 2019-12-06 23:30:58 -05:00
Joe Haddad
bbc62a07be
Only Remove Server-Side Imports (#9653)
* Only Remove Server-Side Imports

* Cleanup imports
2019-12-06 22:57:14 -05:00
Joe Haddad
b4db0421ff
Rewrite SSG Transform for Recursive Cleanup (#9652) 2019-12-06 22:03:55 -05:00
Joe Haddad
cb4c08c02b
Fix SSG Named Export Transform (#9649) 2019-12-06 11:50:50 -05:00
Joe Haddad
10b2eb5b31
Fix Import Shaking for Namespaces (#9650) 2019-12-06 11:46:00 -05:00
Joe Haddad
e76fc18675
Remove Scope Bindings for SSG (#9642) 2019-12-05 18:05:50 -05:00
Joe Haddad
7a51b888c5 Add SSG Support for VariableDeclarations (#9641) 2019-12-05 16:43:18 -06:00
Joe Haddad
a718df5f56
Rewrite SSG Transform (#9640)
* Rewrite SSG Transform

* Add Named Declaration Support

* more adjustments

* Re-crawl scope
2019-12-05 17:22:41 -05:00
Joe Haddad
b4d0740c62
Separate SSG Transform from Config (#9639)
* Separate SSG Transform from Config

* update fn name

* fix
2019-12-05 16:43:11 -05:00
Joe Haddad
30ff9a339f Remove Extraneous Imports in Pages (#9627)
* Remove Extraneous Imports in Pages

* Add test

* bump cache key
2019-12-05 11:04:00 -06:00
Joe Haddad
21e1db7bc1
Aggressively Replace Constants (#9610)
* Aggressively Replace Constants

* Test both windows

* add other switch
2019-12-03 16:08:49 -05:00
Joe Haddad
063e174076
Add Support for Event Flushing (#9606)
* Add Support for Event Flushing

* Update packages/next/export/index.ts

Co-Authored-By: JJ Kasper <jj@jjsweb.site>
2019-12-03 11:18:58 -05:00
JJ Kasper
bf1d872f89 Fix extra prerender error for invalid getStaticProps usage (#9593)
* Fix extra prerender error for invalid getStaticProps usage

* Add error for getStaticProps usage in _error

* Revert erroring for SSG in _error
2019-12-02 17:12:10 -05:00
Joe Haddad
69b7538dce
Simplify getRouteRegex Callsites (#9597) 2019-12-02 16:43:30 -05:00
Joe Haddad
dd1f610f8d
Add SSG Tests with Catch All Routing (#9594)
* Add SSG Tests with Catch All Routing

* fix node version compat

* Remove unneeded query
2019-12-02 16:04:25 -05:00
JJ Kasper
89b22d2994 Fix missing getStaticProps error in serverless mode (#9532)
* Make sure to show missing getStaticProps error in serverless mode

* Update test
2019-11-27 23:23:32 -05:00
Joe Haddad
ca3f881a42 s/getStaticParams/getStaticPaths/ (#9565)
* WIP: rename get static paths

* Adjust logic

* Add warning

* rename constant

* Check for error when using old method

* Add friendly error message

* Test for message of invalid keys

* replace index with dots
2019-11-27 21:46:16 -06:00
Joe Haddad
a6656a0b84
Upgrade path-to-regexp (#9553)
* Upgrade `path-to-regexp`

* Correct import

* Update delimiter

* Fix path match

* Fix hot loader

* Fix params.path usage and pathToRegexp import

* Revert changes for params.path

* Fix lint

* Simplify path match function

* Delimiter should always be `/`

* Fix passed in params

* Add new regex wrapping

* Wrap another route

* Fix error message match
2019-11-27 16:48:28 -05:00
Kristoffer K
63886b36a2 fix: resolve preset-modules (#9538)
* fix: require preset-modules

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

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

* fix formatting
2019-11-26 14:56:08 -05:00
Jason Miller
1f15746176 [modern] preset-modules & fix custom babelrc (#9489)
* Modernize additional common Babel configurations.

* Add @babel/preset-modules dependency

* code quality

* Use modern terser ecma mode for .module.js bundles.
2019-11-26 11:27:26 +01:00
JJ Kasper
cd8e72d5e3 Add custom routes to build output (#9517)
* Add custom routes to build output

* De-dupe code a bit
2019-11-26 10:33:47 +01:00
Janicklas Ralph
04a7f1e85d Replace url polyfill with self.URL (#9200)
* Adding native-url package

* Bumping native-url version

* Upgrading native-url

* Logging stats object for debugging

* Logging stats object for debugging

* Adding try catch to the error lines

* Experimenting with regex

* Experimenting with regex

* Experimenting with regex

* Testing regex changes

* Fixing defer-script test case to not include polyfill.js

* Meging changes with existing polyfill work

* Bumping version

* adjust webpack config

* Reduce size in size test

* Remove 1kb from legacy
2019-11-25 23:10:02 -05:00
Joe Haddad
4656f52d15
CSS Support Customization (#9502)
* CSS Support Customization

* Sort imports

* Correct PostCSS plugin loading

* Add css customization test

* Test "bad" css configuration

* Add load config test

* adjust spacing

* adjust spacing 2x

* Only allow config through JSON

* Support excluding false plugins

* Test tailwind css behavior

* Test plugin exclusion

* Fix unit test

* Fix config file

* Remove more variants

* Update test cases
2019-11-25 16:52:29 -05:00
Joe Haddad
caa5347873
Remove Legacy Code (#9515)
The `sprStatus` module state is no longer used (and shouldn't be!). We can safely remove this code.

I also renamed the drop bundle identifier while I was here.
2019-11-25 14:32:25 -05:00