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

116 commits

Author SHA1 Message Date
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
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
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
Logan Smyth 2495316235 Use custom Babel loader to avoid using separate Babel copies for loader and loader options (#4417)
This resolves the

> .value is not a valid Plugin property

error showing up for people in https://github.com/zeit/next.js/issues/4227

cc @timneutkens
2018-05-23 20:26:57 +02:00
Tim Neutkens f620b8f455
Don’t use chunkhash in development (#4436)
* Don’t use chunkhash in development

* Add test for dynamic imports styling

* Remove pre-load of dynamic page

* Make sure the browser gets closed only once
2018-05-23 14:37:02 +02:00
Sampson Oliver 35d32b48cc Create with-firebase-hosting-and-typescript example (#4443)
Adds an example based off of @jthegedus work on firebase hosting, compatible with next v6 and using typescript in both the firebase functions and the next app.
2018-05-21 10:25:45 +02:00
Jon Espen Kvisler f2261050a0 Set cache-control public (again) (#4322)
* set cache-control public

* test for Cache-Control header

* set Cache-Control header for commons/main.js
2018-05-19 21:43:18 +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
Tim Neutkens 4bec4cc6f7
Test stateful component style update (#4309) 2018-05-08 17:34:24 +02:00
Tim Neutkens 22005080bc
Upgrade react-hot-loader (#4277)
Fixes zeit/styled-jsx#425
Fixes #4246
Fixes #4273
2018-05-05 05:34:28 -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
Tim Neutkens dac2f39a25 Add support for exportPathMap in development (#4094)
* Add support for exportPathMap in development

* Add comment about what it does
2018-04-05 07:18:11 +05:30
Tim Neutkens 2d8c19a450
Upgrade Babel 6 to Babel 7 (major) (#4050)
Upgrade Babel 6 to Babel 7 (major)
2018-04-03 09:34:07 +02:00
Tim Neutkens ebf0c47c25
Upgrade standard.js (#4064)
* Upgrade standard.js

# Conflicts:
#	yarn.lock

* Upgrade babel-eslint
2018-03-27 20:11:03 +02:00
Arunoda Susiripala 1844a09023 Remove the default HMR error overlay (#4020)
This is supplied by webpack-hot-middleware.
I also added a test case to prevent this from popping up again.
2018-03-17 11:59:46 +01:00
Oscar Martinez eff27bdcfb Allow etags to be disabled with config option (#3915)
* Allow etags to be disabled with config option

- CR Change: Rename option to generateEtags
- CR Change: Add tests for etag generation
- CR Change: Refactor to use next.config.js
- Update documentation

* Use renderOpts instead of passing nextConfig
2018-03-13 14:18:59 +01:00
Tomas Roos 76582b8e43 Enable source maps in webpack chunking + bundling process (#3793)
* Removed combine-assets-plugin, since its very broken

* Bundle everything into app.js on production build

* Clean up

* Removed app.js from server routes

* Renamed app.js -> main.js and removed commons from loading

* Remove commons and react CommonChunks

* Removed the commons route

* Killing the entire build-stats hack for app.js

* Removed unused md5-file package
2018-03-06 10:45:29 +01:00
Tim Neutkens 802e879d33
Implement new next/config keys (#3909) 2018-02-27 17:50:14 +01:00
Arunoda Susiripala 1c36b5b9ab Add a set of test cases for error recovery in the dev mode (#3895)
* Add specific test cases for Error Recovery.

* Update hmr/about.js

* Add a test case: should recover after a bad return from the render function

* Add test case: should recover from errors in getInitialProps in client

* Add test case: should recover after an error reported via SSR

* Add a test case: should recover from 404 after a page has been added

* Refactor code base.
2018-02-26 17:18:46 +01:00
Tim Neutkens 1aade36f13
Exposing configuration to the server / client side (minor) (#3882)
* Add next/config

* Set config on server start / client render

* Add documentation for next/config

* Add next/config support for next export

* Fix test

* Use the correct name

* Set default to empty object on the client side

* Add config tests

* Rename config to runtimeConfig
2018-02-26 12:03:27 +01:00
Arunoda Susiripala 0117e2b3fa Add a test case on error recovery in the module scope. (#3892)
This is a test case related for #3888
2018-02-26 10:15:39 +01:00
Arunoda Susiripala 77c8677e58
Fix SSR error handling in the global scope (#3877)
* Fix SSR error handling.

* Remove unwanted console.logs

* Fix a typo.

* Fix current tests.

* Add a new test case for this case.

* Error should only be logged if it is not a 404
2018-02-24 18:49:08 +05:30
Ibrahim Ansari 99fb191286 Add custom-server-typescript example (see #3694) (#3838)
* Add custom-server-typescript example (see #3694)

* Fix linting errors in custom-server-typescript

* Provide proper arguments to ts-node.

* Fix import and fix all linting errors.

* Use import in server as well.

* Update nodemon.json
2018-02-22 16:29:47 +01:00
Arunoda Susiripala a32b22bb2d
Remove special error script handling (#3849)
* Remove special error script handling.
As a result of that, we can't detect 500 errors and buildIdMismatch via client side.

* Fix failing test cases.

* Refactor the code base.

* Remove Router.onAppUpdated
2018-02-21 23:11:25 +05:30
Arunoda Susiripala 30b0be1aaf Add a test for reloading the page on page script error with prefetch (#3811)
* Add a test for reloading the page on page script error with prefetch.

* Click the correct link.
2018-02-15 11:22:11 +01:00
Jerome Fitzgerald c92bc858f7 [refactor] poweredByHeader (#3716) (#3807)
This reverts `fb7c862` per @timneutkens

- Removes the errors/*.md associated
- Puts back `poweredByHeader` for `next.config.js`
- Reincorporates test:

X-Powered-By header
    ✓ should set it by default (3ms)
    ✓ should not set it when poweredByHeader==false (5ms)

Also tested with `yarn link` and verified.
2018-02-14 18:02:48 +01:00
Arunoda Susiripala 9a4226c1ec Add test case for reloading the page on page script error (#3798)
* Add a test for reloading the page on page script error.

* Add a comment.
2018-02-14 11:13:32 +01:00
Arunoda Susiripala fc3b3a4101 Implement proper error handling (#3749)
* Render error on the client without fetching additional scripts.

* Fix test cases.

* Remove unused '_document' page in ensurePage logic

* Remove console.error when page is not found
2018-02-13 16:13:22 +01:00
Tim Neutkens 9a10461150 Don’t include script that we know is going to error (#3747)
* Don’t include script that we know is going to error

* Add check to make sure page script is not included

* Loop over script tags, cheerio fails on /
2018-02-09 21:25:45 +05:30
Tim Neutkens ed122934af Add tests for universal webpack (#3680)
* Add tests for universal webpack

* Move tests to next-plugins

* Remove obsolete files

* Remove removed page

* Remove tests

* Rename test suite
2018-02-05 21:48:31 +05:30
Arunoda Susiripala 373661aafa Handle empty assetPrefix scenario properly. (#3667)
Also make sure to init assetPrefix in next/asset in
the context of next-export.
2018-02-03 17:12:01 +01:00
Chris 7afc008aa7 Example: Passing data from server through API (#2594)
* Add example on how to pass data through js api during SSR

Requested in #1117

* Use content negotiation instead of a separate route

* Codereview feedback

* Move security related test cases into a its own file.

* Removes the unused renderScript function

* Add a nerv example. (#3573)

* Add a nerv example.

* Fix for indentation/style

* Fix for name
2018-02-03 17:11:47 +01:00
Arunoda Susiripala 60cb06c1ba Improved next/asset support (#3664)
* Allow next/asset to work properly with dynamic assetPrefix
Now we use webpack's publicPath via client side.

* Add test cases for dynamic assetPrefix and next/asset.
2018-02-02 21:09:24 +01:00
Arunoda Susiripala 4c7f6cc76a Set assetPrefix dynamically (#3661)
* Introduce the setAssetPrefix API for dynamic assetPrefix.

* Remove unwanted node_modules dir in a test dir.

* Change test main description.
2018-02-02 15:43:36 +01:00
Tim Neutkens e093441bad Universal Webpack (#3578)
* Speed up next build

* Document webpack config

* Speed up next build

* Remove comment

* Add comment

* Clean up rules

* Add comments

* Run in parallel

* Push plugins seperately

* Create a new chunk for react

* Don’t uglify react since it’s already uglified. Move react to commons in development

* Use the minified version directly

* Re-add globpattern

* Move loaders into a separate variable

* Add comment linking to Dan’s explanation

* Remove dot

* Add universal webpack

* Initial dev support

* Fix linting

* Add changes from Arunoda's work

* Made next dev works.
But super slow and no HMR support.

* Fix client side hot reload

* Server side hmr

* Only in dev

* Add on-demand-entries client + hot-middleware

* Add .babelrc support

* Speed up on demand entries by running in parallel

* Serve static generated files

* Add missing config in dev

* Add sass support

* Add support for .map

* Add cssloader config and fix .jsx support

* Rename

* use same defaults as css-loader. Fix linting

* Add NoEmitErrorsPlugin

* Add clientBootstrap

* Use webpackhotmiddleware on the multi compiler

* alpha.3

* Use babel 16.2.x

* Fix reloading after error

* Remove comment

* Release 5.0.0-univeral-alpha.1

* Remove check for React 16

* Release 5.0.0-universal-alpha.2

* React hot loader v4

* Use our static file rendering machanism to serve pages.
This should work well since the file path for a page is predictable.

* Release 5.0.0-universal-alpha.3

* Remove optional loaders

* Release 5.0.0-universal-alpha.4

* Remove clientBootstrap

* Remove renderScript

* Make sure pages bundles are served correctly

* Remove unused import

* Revert to using the same code as canary

* Fix hot loader

* Release 5.0.0-universal-alpha.5

* Check if externals dir exist before applying config

* Add typescript support

* Add support for transpiling certain packages in node_modules

Thanks to @giuseppeg’s work in https://github.com/zeit/next.js/pull/3319

* Add BABEL_DISABLE_CACHE support

* Make sourcemaps in production opt-in

* Revert "Add support for transpiling certain packages in node_modules"

This reverts commit d4b1d9babfb4b9ed4f4b12d56d52dee233e862da.

In favor of a better api around this.

* Support typescript through next.config.js

* Remove comments

* Bring back commons.js calculation

* Remove unused dependencies

* Move base.config.js to webpack.js

* Make sure to only invalidate webpackDevMiddleware one after other.

* Allow babel-loder caching by default.

* Add comment about preact support

* Bring back buildir replace

* Remove obsolete plugin

* Remove build replace, speed up build

* Resolve page entries like pages/day/index.js to pages/day.js

* Add componentDidCatch back

* Compile to bundles

* Use config.distDir everywhere

* Make sure the file is an array

* Remove console.log

* Apply optimization to uglifyjs

* Add comment pointing to source

* Create entries the same way in dev and production

* Remove unused and broken pagesGlobPattern

* day/index.js is automatically turned into day.js at build time

* Remove poweredByHeader option

* Load pages with the correct path.

* Release 5.0.0-universal-alpha.6

* Make sure react-dom/server can be overwritten by module-alias

* Only add react-hot-loader babel plugin in dev

* Release 5.0.0-universal-alpha.7

* Revert tests

* Release 5.0.0-universal-alpha.10

* Make sure next/head is working properly.

* Add wepack alias for 'next' back.

* Make sure overriding className in next/head works

* Alias react too

* Add missing r

* Fragment fallback has to wrap the children

* Use min.js

* Remove css.js

* Remove wallaby.js

* Release 5.0.0-universal-alpha.11

* Resolve relative to workdir instead of next

* Make sure we touch the right file

* Resolve next modules

* Remove dotjsx removal plugins since we use webpack on the server

* Revert "Resolve relative to workdir instead of next"

This reverts commit a13f3e4ab565df9e2c9a3dfc8eb4009c0c2e02ed.

* Externalize any locally loaded module lives outside of app dir.

* Remove server aliases

* Check node_modules reliably

* Add symlink to next for tests

* Make sure dynamic imports work locally.
This is why we need it: b545b519b2/lib/MainTemplate.js (L68)
We need to have the finally clause in the above in __webpack_require__.
webpack output option strictModuleExceptionHandling does that.

* dynmaic -> dynamic

* Remove webpack-node-externals

* Make sure dynamic imports support SSR.

* Remove css support in favor of next-css

* Make sure we load path from `/` since it’s included in the path matching

* Catch when ensurepage couldn’t be fulfilled for `.js.map`

* Register require cache flusher for both client and server

* Add comment explaining this is to facilitate hot reloading

* Only load module when needed

* Remove unused modules

* Release 5.0.0-universal-alpha.12

* Only log the `found babel` message once

* Make sure ondemand entries working correctly.
Now we are just using a single instance of OnDemandEntryHandler.

* Better sourcemaps

* Release 5.0.0-universal-alpha.13

* Lock uglify version to 1.1.6

* Release 5.0.0-universal-alpha.14

* Fix a typo.

* Introduce multi-zones support for mircofrontends

* Add section on css
2018-01-30 16:44:44 +01:00
Tim Neutkens bba744d3fa Merge branch 'master' into fix/canary 2018-01-13 06:33:19 +01:00
Arunoda Susiripala 0b6575b470 Use our static file rendering machanism to serve pages.
This should work well since the file path for a page is predictable.
2018-01-13 10:36:50 +05:30
Wiktor Tkaczyński 9d059f6007 Add support for Fragments in Head (#3502)
* Add support for Fragments in Head.

* Add test cases

* Check if Component has custom key

* Upgrade to React 16.2.0
2017-12-28 07:12:27 +05:30
Patryk 732696e840 Add a charset to the default Content-Type (#3333) 2017-12-05 16:00:58 -08:00
Tim Neutkens e2bcb039cf
Add .jsx extension support (#3376)
* Add .jsx extension

* examples: add create-next-app (#3377)

* examples: add create-next-app

* fix with-typescript readme

* Upgrading with-flow example to the latest flow-bin ver. 0.59.0 (#3337)

For upgrading I used flow-upgrade module by https://yarnpkg.com/en/package/flow-upgrade

* doc'd fs-routing option & added note on `passHref` (#3384)

2 changes:

`passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag,  and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting.


`useFileSystemPublicRoutes` - this is mentioned in https://github.com/zeit/next.js/pull/914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.

* fix typo in readme.md (#3385)

* Upgrade styled-jsx to v2.2.1 (#3358)

* Pulled encoding to top of head (#3214)

* Remove next.d.ts to use @types/next (#3297)

* Add with-mobx-state-tree example (#3179)

* Adapt with-mobx example for with-mobx-state-tree

* Remove unnecessary lastUpdate parameter to show off snapshot

* update readme

* make other.js more closely mimic index.js

* Upgrade styled-jsx to v2.2.1

Includes some bug fixes.

* Fix linting

* Make sure import that doesn’t end in .jsx works

* Move tests

* Show error when .js and .jsx both exist

* Remove .jsx when importing from ‘path.jsx’

* Fixes

* Get .jsx resolver back

* Revert "Get .jsx resolver back"

This reverts commit 6f76712caa400e6f41a6a32ff80189a95b194cce.

* Revert "Revert "Get .jsx resolver back""

This reverts commit 69e592e86e53f28d0e1f78009196b76f2f831866.

* Add remove .jsx to preset

* Remove jsx resolver

* Revert "Remove jsx resolver"

This reverts commit 5e3ef1aca134de47657d91485809cd801e13329f.

* Revert "Revert "Remove jsx resolver""

This reverts commit 8248e5066cff1c7e33dac2e5a88ffe6856e3fc4e.

* Revert "Revert "Revert "Remove jsx resolver"""

This reverts commit 2a6d418a227ea4e59874b0374628ef497e527c52.

* Make 1 component not use .jsx
2017-12-05 15:46:06 -08:00
Arunoda Susiripala f6bd1df6aa
Fix canary tests on CIs (travis, appveyor) (#3375)
* Dump address.

* Use zero as the port.

* Limit test cases.

* throw address.

* Fail a specific error.

* Set a port manually.

* Make sure jest is working properly.

* Set the jest timeout time to 5 min.

* Run the actual test

* Run all production tests on Travis.

* Set the Jest default timeout to 5 min for all integration tests.

* Remove production only testing.

* Remove unwanted console.log

* Remove the addition number from test case

* Set the static export test jest timeout to 5 min.

* Run tests again if they failed once.
2017-12-03 08:12:12 +05:30
Tim Neutkens 1424b84c98
Allow overriding Content-Type (#3242)
* Allow overriding Content-Type

* Mock getHeader
2017-11-05 20:17:03 +01:00
Li Weinan 190853b4ff Support de-deduping head tags by setting key (#3170)
* Support de-deduping head tags by setting key

* move dedupe logic to `unique` function

* fix head tag deduping logic

* remove console.log

* use `toContain` assertions

* update de-duping head tags section in README
2017-10-31 22:52:51 +01:00
Tim Neutkens 03324880a8 Add asPath on the server (#3149)
* Add asPath on the server

* Make sure we don’t include `?` when there is no query
2017-10-22 12:00:31 -07:00
Tim Neutkens 40bb56e892 Fix styled-jsx test (#3147)
* Fix styled-jsx test

* Make sure the test passes
2017-10-22 18:29:58 +02:00
Jesse Ditson a79357f2a4 Allow use of filenames in exportPathMap (#2973)
* allow use of filenames in exportPathMap

* add link test and handling for file paths when flattening links for export

* add note about exporting file paths to readme.md
2017-10-05 20:33:10 +02:00
Arunoda Susiripala 2eb8b0e983 Add styled-jsx 2.0 beta support. (#3039) 2017-10-04 23:46:06 +05:30