Commit graph

221 commits

Author SHA1 Message Date
Tim Neutkens
f4a2cbb403 v7.0.2-canary.44 2018-12-15 23:45:34 +01:00
DevSide
ebf217cb16 add --node-args option (#5858)
This message is from @timneutkens after making changes:
- Convert executables to Typescript
- Remove `minimist` in favor of `arg` 
- Implement `--node-args` usage: `--node-args="--throw-deprecation"`
- Adds tests for usage of the `next` cli
2018-12-15 22:55:59 +01:00
JJ Kasper
af07611a63 Implement websockets based on-demand-entries ping (#4508)
Fixes #4495

Here's my approach for replacing the XHR on-demand-entries pinger #1364 #4495. I'm not sure if this is the way everyone wants to accomplish this since I saw mention of using a separate server and port for the dynamic entries websocket, but thought this would be a fairly clean solution since it doesn't need that.

With this method the only change when using a custom server is you have to listen for the upgrade event and pass it to next.getRequestHandler(). Example: 
```
const server = app.listen(port)
const handleRequest = next.getRequestHandler()

if(dev) {
  server.on('upgrade', handleRequest)
}
```
2018-12-14 12:25:59 +01:00
Tim Neutkens
1464d932eb
Disable webpack cache option in prod (#5877)
* Disable webpack cache option in prod

* Remove cache option as it’s added by mode === ‘development’
2018-12-14 11:34:05 +01:00
Tim Neutkens
00a14d696d v7.0.2-canary.43 2018-12-13 19:47:10 +01:00
Tim Neutkens
4426fdb98e
Make sure 404 is rendered (#5880) 2018-12-13 19:46:16 +01:00
Tim Neutkens
1016b71011
Don’t prefetch on slow network / when datasaver is enabled (#5876)
Inspired by https://twitter.com/addyosmani/status/1073118564423356416

I've made the checking function slightly smaller (including both conditions on one line makes Terser optimize the condition).

cc @addyosmani
2018-12-13 19:08:23 +01:00
Tim Neutkens
620b426903
Remove baseurl/paths option (#5878)
For some reason the canary branch is failing on Typescript while the PR was not.
2018-12-13 16:56:48 +01:00
Connor Davis
419bec0b9b Fix #5674 Append crossOrigin on the client side too, add config option for crossOrigin (#5873)
# Fixes https://github.com/zeit/next.js/issues/5674

This adds config option
```js
// next.config.js
module.exports = {
  crossOrigin: 'anonymous'
}
```
This config option is defined in the webpack Define Plugin at build.
`Head` and `NextScript` now use the config option, if it's not explicitly set on the element.
This value is now passed to Webpack so it can add it to scripts that it loads.
The value is now used in `PageLoader` (on the client) so it can add it to the scripts and links that it loads.
Using `<Head crossOrigin>` or `<NextScript crossOrigin>` is now deprecated.
2018-12-13 01:05:21 +01:00
Tim Neutkens
5e3bf6e537
Convert render.js to typescript (#5869)
* Convert render.js to typescript

* Compile tsx files too

* Remove internal renderErrorToHTML function

* Interopt component result

* requirePage doesn’t need async

* Move out enhancing logic into it’s own function

* Remove buildManifest from renderPage

* Move render into it’s own function

* Change let to const

* Move renderDocument into it’s own function
2018-12-13 01:00:46 +01:00
Benjamin Kniffler
e6c3686629 multi-threaded export with nice progress indication (#5870)
This PR will

- allow nextjs export to use all available CPU cores for rendering & writing pages by using child_process
- make use of async-sema to allow each thread to concurrently write multiple paths
- show a fancy progress bar while processing pages (with non-TTY fallback for CI web consoles)

The performance gain for my MacBook with 4 CPU cores went from ~25 pages per second to ~75 pages per second. Beefy CI machines with lots of cores should profit even more.
2018-12-12 13:59:11 +01:00
Tim Neutkens
2dec1fcd63 v7.0.2-canary.42 2018-12-11 21:59:30 +01:00
Tim Neutkens
5708e99eca
Run compilers sequentially when in lambdas mode (#5862) 2018-12-11 21:46:23 +01:00
Tim Neutkens
1c8b09d7ea
Make <Head> children render first, then next/head children, then script preloads/styles (#5852) 2018-12-10 23:40:42 +01:00
Tim Neutkens
93424b64a9
Use correct default for query (#5851) 2018-12-10 23:40:26 +01:00
Kenneth Luján Rosas
616c3d7ac8 docs(readme): add documentation for renderPage customization on _document.js (#5723)
Per @timneutkens suggestion [here](https://github.com/zeit/next.js/pull/5631#issuecomment-440588455) I went ahead and gave a shot at trying to document `renderPage` usage.

This PR:
- Documents `renderPage` legacy and current usage.
2018-12-10 17:01:59 +01:00
Oscar Busk
27c0b199d0 Fix paths when built on windows (#5795)
This PR Fixes #4920

So the problem is that when a next.js application is built on windows, the `pages-manifest.json` file is created with backslashes. If this built application is deployed to a linux hosting enviroment, the server will fail when trying to load the modules.

```
Error: Cannot find module '/user_code/next/server/bundles\pages\index.js
```

My simple solution is to modify the `pages-manifest.json` to always use linux separator (`/`), then also
modify `server/require.js` to, when requiring page, replace any separator (`\` or `/`) with current platform-specific file separator (`require('path').sep`).

The fix in `server/require.js` would be sufficient, but my opinion is that having some cross-platform consistency is nice.

This change was tested by bulding an application in windows and running it in linux and windows, aswell as building an application in linux and running it in linux and windows. The related tests was also run.
# Conflicts:
#	test/integration/production/test/index.test.js
2018-12-10 14:48:06 +01:00
Tim Neutkens
8b6173917a
Convert next-server.js to typescript (#5844) 2018-12-09 22:46:45 +01:00
Tim Neutkens
61894816ba
Remove app variable as it’s only used once (#5842)
* Remove app variable as it’s only used once

* Remove double spread
2018-12-08 13:14:44 +01:00
Tim Neutkens
0e6d190706
Move sendHTML and rewrite in ts (#5839)
* Move send-html function and rewrite in typescript

* Move getPageFiles and convert to ts

* Move getPageFiles and convert to ts (#5841)

* Move getPageFiles and convert to ts

# Conflicts:
#	packages/next-server/server/render.js

* Fix unit tests
2018-12-07 15:52:29 +01:00
Tim Neutkens
8873242b0b
Move getPageFiles and convert to ts (#5841)
* Move getPageFiles and convert to ts

# Conflicts:
#	packages/next-server/server/render.js

* Fix unit tests
2018-12-07 13:35:01 +01:00
Tim Neutkens
8ca5749ff9
Remove unused properties (#5837) 2018-12-07 00:57:39 +01:00
Tim Neutkens
ffe1a12f2e
Move getDynamicImportBundles into own ts file (#5836) 2018-12-06 22:34:53 +01:00
Tim Neutkens
3c62b07593
Move serve-static to typescript (#5833) 2018-12-06 16:54:33 +01:00
Tim Neutkens
5d2250ac27
Remove unused functions (#5832)
Couldn't find a reference to these functions as next-server uses the renderToHTML directly.
2018-12-06 16:47:10 +01:00
Tim Neutkens
261eb16308
Only check if BUILD_ID exists when reading throws error (#5834)
We don't have to check if the file already exists here, since it's always in production mode (dev overrides the readBuildId method to always be `development`) If the file is not found (error is thrown) we check if the file exists. If not we throw a helpful error. In other cases we throw the original error.
2018-12-06 16:46:53 +01:00
Tim Neutkens
902c5244f3 v7.0.2-canary.41 2018-12-05 22:41:26 +01:00
Tim Neutkens
6729fa4580 Mark react/react-dom as external when in lambdas mode (#5828) 2018-12-05 13:40:17 -08:00
Tim Neutkens
dd556bf90b
Add tsc type checking (#5826)
* Add tsc type checking

* Add linting on circle

* Add node-fetch types

* Use strict mode
2018-12-05 21:45:50 +01:00
Tim Neutkens
7098501547 v7.0.2-canary.40 2018-12-05 15:05:59 +01:00
Tim Neutkens
1a5fc941ce Remove console.log after verifying the correct files are ignored 2018-12-05 15:05:14 +01:00
Tim Neutkens
a62a6276c7 v7.0.2-canary.39 2018-12-05 14:45:14 +01:00
Tim Neutkens
6542750e12
Fix edge case where file had module.export in the content (#5823)
We ran into this eg on hyper-site, which has `module.exports` in the content.
2018-12-05 14:37:26 +01:00
Tim Neutkens
84223d39e7 v7.0.2-canary.38 2018-12-04 20:10:53 +01:00
Tim Neutkens
2d5b56a181 Disable usage of esmodules when commonjs is enabled on the preset 2018-12-04 20:10:22 +01:00
Tim Neutkens
29ed67b020
Add test for generateBuildId (#5816)
* Add docs for returning `null` from generateBuildId

* Add test for setting custom buildid

* Fix linting
2018-12-04 16:42:25 +01:00
Tim Neutkens
dada692bd6 v7.0.2-canary.37 2018-12-04 15:28:36 +01:00
Tim Neutkens
bd2ad412d3
Bring back module.exports because of backwards compat (#5815) 2018-12-04 15:26:20 +01:00
Tim Neutkens
dd3b5bf81d v7.0.2-canary.36 2018-12-04 11:04:21 +01:00
Tim Neutkens
d11a3aa34e
Add tests for isomorphic-unfetch bundling issue (#5805)
* Add tests for isomorphic-unfetch bundling issue

* Remove unneeded extra option

* Remove isomorphic-fetch
2018-12-04 10:59:12 +01:00
Matheus Fernandes
977bf8d9eb Zeit -> ZEIT (#5804) 2018-12-03 23:01:23 +01:00
Tim Neutkens
082db2877d v7.0.2-canary.35 2018-12-03 19:50:59 +01:00
Tim Neutkens
f79230db33
Change module resolution extensions (#5801)
Same as https://github.com/zeit/ncc/pull/80
2018-12-03 19:36:24 +01:00
Tim Neutkens
9890e06907
Dedupe only items with unique key (#5800)
Fixes #3705
Fixes #4656

- No longer automatically dedupe certain tags. Only the ones we know are *never* going to be duplicate like charSet, title etc.
- Fix `key=""` behavior, making sure that if a unique key is provided tags are deduped based on that.

For example:

```jsx
<meta property='fb:pages' content='one'>
<meta property='fb:pages' content='two'>
```

Would currently cause

```jsx
<meta property='fb:pages' content='two'>
```

### After this change:

```jsx
<meta property='fb:pages' content='one'>
<meta property='fb:pages' content='two'>
```

Then if you use next/head multiple times / want to be able to override:

```jsx
<meta property='fb:pages' content='one' key="not-unique-key">
<meta property='fb:pages' content='two' key="not-unique-key">
```

Would cause:

```jsx
<meta property='fb:pages' content='two'>
```

As `key` gets deduped correctly after this PR, similar to how React itself works.
2018-12-03 17:28:42 +01:00
Tim Neutkens
58f5dd297a
Add Typescript types for builds functions (#5791) 2018-12-03 14:18:52 +01:00
Tim Neutkens
a9cf735f50
Convert babel plugins to typescript (#5789)
Slowly moving files over 💯
2018-12-02 18:30:00 +01:00
Luc
e43d21fdf0 remove occurence of deprecated url prop in readme (#5786) 2018-12-01 21:11:06 +01:00
Tim Neutkens
a66e1c0d7c v7.0.2-canary.34 2018-11-30 19:51:54 +01:00
Tim Neutkens
e5002234d0
Transpile imports if module has module.exports (#5780)
Fixes #5778
Fixes #3650
2018-11-30 17:56:07 +01:00
Tim Neutkens
633dd87b18
Handle 404 thrown from send (#5779) 2018-11-30 17:09:23 +01:00
Tim Neutkens
4322bb13dd
Build / watch .ts core files (#5776) 2018-11-30 13:10:30 +01:00
Tim Neutkens
f1fe237ba8 v7.0.2-canary.33 2018-11-29 19:33:20 +01:00
Tim Neutkens
1c64e59564 v7.0.2-canary.32 2018-11-29 12:36:48 +01:00
Tim Neutkens
55e89e759a
Fix polyfill for ie11 (#5763)
* Fix polyfill for ie11

* Use esmodules only when using webpack
2018-11-29 12:36:03 +01:00
Tim Neutkens
c1037949fd v7.0.2-canary.31 2018-11-28 17:55:37 +01:00
Tim Neutkens
fb92fdef54
Make sure const/async is transpiled (#5760)
* Make sure const/async is transpiled

* Use babel common compilation instead
2018-11-28 17:53:49 +01:00
Ståle Pettersen
4594b7cb07 Remove secret from 'publicRuntimeConfig' example (#5759) 2018-11-28 15:29:41 +01:00
Tim Neutkens
af893bf740 v7.0.2-canary.30 2018-11-28 15:12:43 +01:00
Tim Neutkens
15bb1c5e79
Use Typescript to transpile Next.js core files instead of Babel (#5747)
- Replaces taskr-babel with taskr-typescript for the `next` package
- Makes sure Node 8+ is used, no unneeded transpilation
- Compile Next.js client side files through babel the same way pages are
- Compile Next.js client side files to esmodules, not commonjs, so that tree shaking works.
- Move error-debug.js out of next-server as it's only used/require in development
- Drop ansi-html as dependency from next-server
- Make next/link esmodule (for tree-shaking)
- Make next/router esmodule (for tree-shaking)
- add typescript compilation to next-server
- Remove last remains of Flow
- Move hoist-non-react-statics to next, out of next-server
- Move htmlescape to next, out of next-server
- Remove runtime-corejs2 from next-server
2018-11-28 15:03:02 +01:00
Tim Neutkens
c801a96631 v7.0.2-canary.29 2018-11-27 22:21:00 +01:00
Tim Neutkens
08e3396574
Fix graphql issue with lambdas flag (#5755)
Fixes https://spectrum.chat/?t=604f6aa6-23f2-4358-8b0b-14e5810178dc
2018-11-27 22:20:13 +01:00
Tim Neutkens
818cf8e77a v7.0.2-canary.28 2018-11-27 12:39:07 +01:00
Tim Neutkens
9d30e411b5
Fallback to <script> loading behavior when preload is not supported (#5744)
Based on https://github.com/zeit/next.js/pull/5737#discussion_r236059295

This will cause a warning in chrome/safari after 3s
2018-11-26 23:58:40 +01:00
Tim Neutkens
9f03fad5e9 v7.0.2-canary.27 2018-11-25 00:57:02 +01:00
Tim Neutkens
cad19c808c
Use <link rel=“prefetch”> for prefetching (#5737)
* Use <link rel=“prefetch”> for prefetching

Fixes #5734

* Fix unit tests for router

* Add test for prefetch

* Rename test

* Check all logs for message
2018-11-25 00:47:39 +01:00
Hozefa
401594ed36 remove glamorous example since its no longer maintained (#5738)
Since glamorous is [no longer maintained](https://github.com/paypal/glamorous#status-unmaintained) removing it from readme.
2018-11-23 21:18:13 +01:00
Richard Park
44d661af67 Upgrade to webpack@4.26 (#5729)
* Upgrade terser-webpack-plugin

* Upgrade webpack

* Extract common terserPluginConfig
2018-11-22 10:14:14 +01:00
Tim Neutkens
9b2782a6d0
Add engines to next and next-server (#5724) 2018-11-21 21:56:24 +01:00
Tim Neutkens
c2eaf26ea9
Remove flow types (#5704)
* Remove flow-typed

* Remove flow types

* Remove the last types

* Bring back taskr dependency

* Revert "Bring back taskr dependency"

This reverts commit 38cb95d7274d63fe63c6ac3c95ca358a28c17895.

* Bring back preset-flow as it’s used for tests

* Revert "Revert "Bring back taskr dependency""

This reverts commit b4c933ef133f4039f544fb10bf31d5c95d3b27a2.
2018-11-21 16:04:37 +01:00
Curran Kelleher
19db04f302 Iterate wording in documentation (#5718)
I came across **Possible spelling mistakes** #5496 and noticed that the current wording could be improved both in terms of accuracy and succinctness.
2018-11-21 01:57:51 +01:00
Anderson Leite
8af767b52d Refactor readBuildId. (#5720) 2018-11-21 01:56:11 +01:00
Tim Neutkens
76202f2fb2 v7.0.2-canary.26 2018-11-20 12:17:23 +01:00
Tim Neutkens
70cae4b2ea
Disable mjs support when in lambdas mode (#5712) 2018-11-20 12:13:31 +01:00
Anderson Leite
0d44623f74 Local variable 'out' is redundant. (#5710) 2018-11-20 12:13:06 +01:00
Tim Neutkens
9547e77820
use native http instead of micro (#5706) 2018-11-19 16:36:18 +01:00
Giuseppe
e1f6f34f86 Update styled-jsx (#5617) 2018-11-18 23:33:23 +01:00
Sean Connolly
a9092c7c7d Update README.md (#5670) 2018-11-18 23:33:07 +01:00
Anderson Leite
79095bc500 Refactor rendor verification to validate if it's a blocked page. (#5686)
Extracting the logic that defines if a page is blocked to utils.

If that refactor make sense, I will create a next PR to cover both of the functions inside utils with tests.
2018-11-18 20:44:50 +01:00
Alexander Kachkaev
233a6042d9 Bump bump-babel-plugin-react-require to 3.0.1 (#5693) 2018-11-18 20:40:18 +01:00
Tim Neutkens
cfd46acde5 v7.0.2-canary.25 2018-11-18 13:53:45 +01:00
Tim Neutkens
7d78c3b641 Add node_modules bundling under the --lambdas flag for next build (#5690)
* Add node_modules bundling under the —lambdas flag for next build

* Run minifier when lambdas mode is enabled

* Add lambdas option to next.config.js

* Add test for lambdas option
2018-11-17 11:15:33 -08:00
Luc
b63dda7cf7 Unnecessary else if in next-server/server/render.js (#5609) 2018-11-15 22:48:19 +01:00
Anderson Leite
0d77dda28c Fix typos on next-server.js comments. (#5672) 2018-11-14 09:55:25 +01:00
Tim Neutkens
e930d1e821 v7.0.2-canary.24 2018-11-13 22:58:21 +01:00
Tim Neutkens
79470c76b8 Add license to next-server
Fixes #5671
2018-11-13 22:57:31 +01:00
Tim Neutkens
a7c440d88e v7.0.2-canary.23 2018-11-13 21:58:33 +01:00
Adam Lane
4ce095df89 Add crossOrigin via props to _document Head and NextScript (#5646)
This alternative implementation of https://github.com/zeit/next.js/pull/5150 follows @timneutkens suggestion of using props.

Fixes #5150 
Fixes #3630
2018-11-13 21:36:09 +01:00
Luc
add5879cc2 Print assets sizes after build (#5664)
It looks like this : 

![capture d ecran 2018-11-13 a 00 47 12](https://user-images.githubusercontent.com/6616955/48361936-7cc13d80-e6dd-11e8-8aa8-c5a73beae966.png)

I'm not sure about the License part, can you check @timneutkens ?
2018-11-13 10:46:26 +01:00
Tim Neutkens
d0dd1bc28d
Trim buildId returned from generateBuildId (#5634)
* Trim buildId returned from generateBuildId

* Pass dir to function
2018-11-12 15:57:48 +01:00
Callum Locke
c4cec5b7d9 Fix link to constants (for phases) in next readme (#5643) 2018-11-09 15:03:27 +01:00
Tim Neutkens
2776caacde v7.0.2-canary.22 2018-11-09 14:10:24 +01:00
Jerónimo Carrizo
3bc415d8b5 canary - just updating to the latest stable version of webpack (#5623)
In order to trying to resolve the bug [#5480](https://github.com/zeit/next.js/issues/5480), I create this PR which update the webpack version.
2018-11-09 14:09:12 +01:00
Tim Neutkens
a0137d4fd8 Rename class to NextJsRequireCacheHotReloader 2018-11-07 18:56:53 +01:00
Tim Neutkens
5ffbb34841 v7.0.2-canary.21 2018-11-07 18:46:35 +01:00
Tim Neutkens
d6284f171b
Don’t fail build on webpack warning (#5622) 2018-11-07 18:38:37 +01:00
Tim Neutkens
b46d7e8f6f v7.0.2-canary.20 2018-11-07 15:39:23 +01:00
Tim Neutkens
2e14b4491b
Bundle @babel/runtime into server bundle (#5619) 2018-11-07 15:38:35 +01:00
Tim Neutkens
a82a2d8d1b v7.0.2-canary.19 2018-11-07 14:42:00 +01:00
Tim Neutkens
88f2c1716a
Clean up dependencies between next and next-server (#5615) 2018-11-07 14:41:00 +01:00
Pieter De Decker
a09ca535c3 Fix typos (#5599) 2018-11-05 22:14:17 +01:00