1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
Commit graph

279 commits

Author SHA1 Message Date
Tim Neutkens 42736c061a
Introduce dynamic(() => import()) (#5249)
* Add failing tests

* Upgrade wd module

* Pass dynamic import webpack ids to the client side

* Pass through webpack ids to initalializer and only use those

* Compile dynamic(import()) to dynamic(() => import())

* Default dynamicIds

* Use forked hard-source-plugin

* Possibly fix test

* Make tests fail less intermittently

* Temporarily disable hard-source in production

* Make sure dynamic import chunks are unique

* Disable hard-source

* Log html if error is thrown

* Fix test
2018-09-25 15:27:09 +02:00
Henrik Wenz 8e9b84bf2a Keep warnings when process.env.NODE_ENV is not production (#5196)
This way the warnings will work in test mode. (`process.env.NODE_ENV === „test“`)
2018-09-18 20:17:35 +02:00
Tim Neutkens 695f372da9
Compile away next/link proptypes in production (#5155)
This saves 7KB as prop-types-exact is not needed in production.
2018-09-14 11:34:08 +02:00
Tim Neutkens a929f8c8b7
Change server error overlay to white to be consistent with react-error-overlay (#5104)
Makes the server error overlay white so it doesn’t flicker when the error is hydrated into the client overlay
2018-09-05 17:13:44 +02:00
George Pantazis 56ad5121a1 Use as instead of url to determine URL newness (#4153)
Currently, using `as` will cause the router to think the URL is not changing in the case where you're re-rendering the same page with a different route. This would most likely be an issue for custom servers
which are using shallow routing.

This should be an invisible change for non-custom-server users, since `as` is defaulted to `url` if not set.

This should resolve #3065.
2018-09-03 15:26:34 +02:00
Tim Neutkens a0aaa933de
Apply sideEffect at DidMount on the client side (#5068)
Fixes #5038

The problem with `constructor` is that it doesn't have `context` yet when being called. It's also considered unsafe to add a side-effect on constructor except when server-rendering
2018-09-02 19:18:20 +02:00
Tim Neutkens ead5a8bc3c
Split out Loadable.Capture and make NoSSR smaller (#5060) 2018-08-30 15:09:53 +02:00
Tim Neutkens e1c544cd75
Fix loading... issue (#5058)
This fixes intermittent `loading...` on some requests which surfaced on zeit.co when upgrading
2018-08-30 14:02:18 +02:00
Michael Fix 9532cc1256 Remove old UNSAFE_ lifecycle methods (#5020)
~I am not sure if this is a valid fix yet, but I was going to let CI run the tests for me. I'll close and look into it if the build fails.~

Let me know if this will cause issues, but I don't think it should. The React docs recommends moving `componentWillMount` logic into the constructor
2018-08-25 17:26:11 +02:00
HaNdTriX 4c6ec18d89
Remove dublicate className from head (followup) (#5027)
* Add test of default head.

* Remove duplicate next-head (followup #5026)
2018-08-25 10:00:57 +02:00
HaNdTriX 267cff3b81 Remove dublicate className from head (#5026)
This PR:

* Removes dublicate `className` in: `<meta charSet="utf-8" class="next-head"/>`
* Refactores head reducer

Special thanks to @udanpe for reporting and @geoffRGWilliams for bringing me on the right tack! 🙌

Closes #4745, #4802
2018-08-25 00:19:54 +02:00
Tim Neutkens 0dd2b2aa74
Add warning for broken popstate (#5000)
* Add warning for undefined url and as coming from popstate

* Use consistent url

* Fix err.sh link in test

* Rename `inital` => `initial`
2018-08-24 12:30:27 +02:00
Tim Neutkens bd5ee26841
Scroll to name when hash is provided (#5019)
Fixes #5008 

Apparently, browser behavior is to scroll to `name="something"` too.
2018-08-23 20:20:45 +02:00
HaNdTriX 4d8e9cacdd Improve getDisplayName util (#4944)
- [x] Add unit test
- [x] Allow to get the display name of a native component (e.g.: `div`) without throwing
- [ ] Remove displayName in production mode
2018-08-13 11:03:59 -07:00
Gary Meehan 0f4e9feafa Allow Duplicate Open Graph Image Tags (#4851)
* allow og:image duplicates

* add tests

* update tests

* fix spacing
2018-08-12 12:51:17 -07:00
Olivier Tassinari b02fff63d0 Fix broken hash scroll logic (#4766)
`<Container>` does not receive any property. There is no way the *scrollToHash* logic can work right now. I believe it's a regression. It was working fine at some point. I'm sorry, I'm too lazy to add a test.

This fix was tested on Material-UI 👌.

This bug reproduction is the following:
As soon as you want to transition to a new page with a hash. The scroll doesn't change.
- start on pageA
- you scrollTop to 100
- you move to pageB#hash
- you stay at scrollTop 100, but #hash is at scrollTop 400.
2018-08-11 13:04:16 -07:00
HaNdTriX d1b67623f6 Throw error if getInitialProps is defined as as instance method (#4922)
* Throw error if getInitialProps is defined as as instance method

Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: #4782

* Document getInitialProps error

* Add unit tests for loadGetInitialProps
2018-08-09 10:13:44 -07:00
Tim Neutkens a528565c69
Make next/link async safe (#4911)
Removes componentWillMount and uses memoize instead as recommended here: https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html
2018-08-06 22:44:18 -07:00
Tim Neutkens f3f939dde4
Run method sorting codemod (#4909)
react-codemod recommended way of having methods defined
2018-08-06 20:53:06 -07:00
Tim Neutkens b20b80adf0
Run rename-unsafe-lifecycles as preparation for React 17 (#4907)
https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles
2018-08-06 20:23:28 -07:00
Tim Neutkens 4c602ff395
Run manual-bind-to-arrow codemod (#4906)
https://github.com/reactjs/react-codemod#manual-bind-to-arrow
2018-08-06 20:20:01 -07:00
Jacob Page b492e6703d Make EventEmitter more Node-like (#4865)
Add behaviors to make `EventEmitter` a bit more like its NodeJS counterpart. This should make using it a bit less surprising.
2018-08-01 14:43:25 +02:00
Tim Neutkens 9240cf7855
Make .events work even when router is not initialized (#4874)
Followup of https://github.com/zeit/next.js/issues/4863#issuecomment-408920755
2018-07-31 21:04:14 +02:00
Tim Neutkens 6a087c6a5d
Rename commons directory to runtime (#4853) 2018-07-27 19:29:25 +02:00
Tim Neutkens 475b426ed1
Compile pages to .next/static directory (#4828)
* Compile pages to .next/static/<buildid>/pages/<page>

* Fix test

* Export class instead of using exports

* Use constant for static directory

* Add comment about what the middleware does
2018-07-25 13:45:42 +02:00
Tim Neutkens 75476a9136
[WIP] Webpack 4, react-error-overlay, react-loadable (#4639)
Webpack 4, react-error-overlay, react-loadable (major)
2018-07-24 11:24:40 +02:00
James Reggio 1a3f950777 Respect target on <a/> tags under Link (#4763)
There are occasions where it is useful to have `target='_blank'` on hyperlinks within your own app. (For example, if your app is being loaded in an iframe and you'd like for the links to break out in to new windows.)

With this PR, the `onClick` logic in Link now checks for an external target on the nested <a/> tag, and will fall back to the default behavior if it's present, similar to the logic for shift-/cmd-clicking the link.
2018-07-12 00:03:25 +02:00
Jacob Page 498f37e33f Support events emitter for router (#4726)
Fixes #4679 
* Document usage of `events` router property
* Expose `events` in the `router` context object
2018-07-05 14:41:18 +02:00
Tim Neutkens 57d8af857a
Make sure hashchanges get triggered (#4676)
When clicking a next/link with a hash (#something) multiple times, it wouldn't keep the scrolling behavior browsers have. This makes sure we correctly trigger it.
2018-06-28 20:56:18 +02:00
Olivier Tassinari f4af03b9c8 Remove unneeded async (#4635)
Unless I'm missing something, we don't need this async. The transpiled JavaScript is much smaller 🚀
2018-06-23 22:15:27 +02:00
Tim Neutkens c4d0b212f5
Pass in the generated asPath instead of a full url (#4622)
Fixes #4620 

On the server and when navigating pages, the `asPath` is the pathname + query + hash visible to the users, not an url. This makes sure that we keep it consistent between hot reloads.
2018-06-18 20:54:05 +02:00
Tim Neutkens f2c2519159
Move build directory outside of server folder (#4565)
The prepares for next-server.

I also took this as an opportunity to get all build directory paths from a single location, as they were previously scattered across webpack/babel plugins and loaders.
2018-06-14 19:30:14 +02:00
Tim Neutkens e881c1b386
Catch errors thrown in _app.js (#4607) 2018-06-14 15:58:31 +02:00
Tim Neutkens 5bc3b23c23
Make router properties update when re-rendering (#4541)
* Make router properties update when re-rendering

* Remove documentation about methods that have been deprecated since v2/v3

* Update next export documentation
2018-06-05 17:10:28 +02:00
Tim Neutkens a7bb9175eb
Clean up references to this.dir and this.dist everywhere (#4535)
This was spread around the server. Now it's set in one place and passed around.
2018-06-04 15:45:39 +02:00
Tim Neutkens fbaeba49b6
Add CONFIG_FILE constant, add types for server/config.js (#4529)
This was pulled from #4518, it can already be merged so it's easier to get it in.
2018-06-04 11:38:46 +02:00
Davor Santic e153bcbb9a next/head allow duplicates if it has uniq keys (#4121)
resolves #4115

For now, I just added `'article:tag'` so it could be duplicated if we need more we have to extend:
```javascript
const ALLOWED_DUPLICATES = ['article:tag']
```
2018-06-01 13:12:33 +02:00
Tim Neutkens 098f3fd7e9
Rename dist to server to be more consistent (#4506)
Previously we called this directory holding the pages/chunks for server rendering `.next/dist` instead of `.next/server` which is confusing both when looking at it and in the codebase, since there's also `distDir` as a configuration option.

Also made this a constant in `next/constants` so functionality using this can be easily found.
2018-05-31 20:56:04 +02:00
Tim Neutkens 86d01706a6
Remove react-hot-loader (#4500)
Fixes #4494
2018-05-31 11:47:29 +02:00
Michał Miszczyszyn 669225263d Allow onClick on next/link component's child (#4474)
Allow `onClick` on `next/link` child. This should not be a breaking change, but it's a very useful feature. Real-life use cases include: analytics or closing menu on navigation, and other.

- [x] allow optional `onClick` on `next/link` component's child
- [x] call original `child.props.onClick(e)` before `this.linkClicked(e)`
- [x] add integration tests
- [x] cancel the navigation if `e.defaultPrevented === true`

Fixes #1490
2018-05-27 20:47:02 +02:00
andy-viv 2b16d8b2ac added "hashChangeStart" and "hashChangeComplete" events (#4234)
This PR adds events for when there is a hash-only change in the URL. This is needed because `window.addEventListener('hashchange', ...)` does not work with next.js because it is using pushState.
2018-05-25 14:47:58 +02:00
Shu Ding 4df7e48f94 Add title to default error page (#4383) 2018-05-25 13:35:59 +02:00
Tim Neutkens 449f38daa7
Make sure props.url is immutable (#4352)
* Make sure props.url is immutable

* Add test for immutable url

* Match object instead of string
2018-05-12 20:10:17 +02:00
Tomas Carnecky 7f621324fc Set this.mounted to false when dynamic component is unmounted (#4333)
Otherwise you may get a React warning about calling setState() on an unmounted component.
2018-05-11 17:07:06 +02:00
Tim Neutkens 30b0e36c71 Don’t use caps for node_env check 2018-04-25 09:23:39 -07:00
Tim Neutkens fe24333edc Only show deprecation message in development (#4206) 2018-04-24 15:25:45 -07:00
Tim Neutkens 1d884efe78
Fix url prop override (#4191)
* Fix url prop override

* Remove console.log
2018-04-22 13:20:24 -07:00
Tim Neutkens 68626c5147 Improved stacktraces (minor) (#4156)
* Handle production errors correctly

* Improved source map support

* Make react-hot-loader hold state again

* Remove console.log

* Load modules on demand

* Catch errors in rewriteErrorTrace

* Update comment

* Update comment

* Remove source-map-support

* Load modules in next-dev

* Make sure error logged has sourcemaps too

* Add tests for production runtime errors

* Add tests for development runtime errors. Fix issue with client side errors in development

* Move functionality back to renderError now that error handling is consistent

* Rename to applySourcemaps
2018-04-18 21:48:06 +05:30
Tim Neutkens eca8e8f64b
Expose app.js (#4129)
* Expose pages/_app.js

* Add tests for _app and _document

* Uncomment deprecation warnings

* Add documentation for _app, improve documentation of _document

* Update docs / test for _document

* Add _document to client compiler in development

* Add missing app.js to comment

* Only warn once

* Add url-deprecated error page

* Combine tests

* Yse same message for all methods of ‘props.url’

* Update docs around _app

* Update documentation

* Quotes

* Update table of contents
2018-04-12 10:33:22 +02:00
Tim Neutkens 15dde33794
Add build manifest (#4119)
* Add build manifest

* Split out css since they don’t have exact name

* Remove pages map

* Fix locations test

* Re-run tests

* Get consistent open ports

* Fix static tests

* Add comment about Cache-Control header
2018-04-12 09:47:42 +02:00