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

2383 commits

Author SHA1 Message Date
Tim Neutkens a8a97b07c7
Provide a way to copy files in exportPathMap (#5089)
Related #4659 

Adds the possibility for users to copy files inside of `exportPathMap`. This allows for adding `robots.txt` `sitemap.xml` etc. another use case is for https://github.com/hanford/next-offline, currently it's manually reading the buildId in `exportPathMap`.

To allow users to do this we'll introduce a new parameter holding an object with the following keys:

- `dev` - `true` when `exportPathMap` is being called in development. `false` when running `next export`. In development `exportPathMap` is used to define routes and behavior like copying files is not required.
- `dir` - Absolute path to the project directory
- `outDir` - Absolute path to the `out` directory (configurable with `-o` or `--outdir`). When `dev` is `true` the value of `outDir` will be `null`.
- `distDir` - Absolute path to the `.next` directory (configurable using the `distDir` config key)
- `buildId` - The buildId the export is running for

Example usage:

```js
// next.config.js
const fs = require('fs')
const {join} = require('path')
const {promisify} = require('util')
const copyFile = promisify(fs.copyFile)

module.exports = {
  exportPathMap: async function (defaultPathMap, {dev, dir, outDir, distDir, buildId}) {
    if(dev) {
      return defaultPathMap
    }
    // This will copy robots.txt from your project root into the out directory
    await copyFile(join(dir, 'robots.txt'), join(outDir, 'robots.txt'))
    return defaultPathMap
  }
}
```
2018-09-04 16:01:50 +02:00
Tim Neutkens b39b44ac23
Remove obsolete route (#5092)
This route is no longer needed
2018-09-04 15:59:48 +02:00
Tomas Roos 9abbea8571 Make sure that 404's is not cached by CDN:s (#5088) 2018-09-04 14:13:15 +02:00
Tim Neutkens a6114d4d65
Fix dependencies (#5091) 2018-09-04 13:17:22 +02:00
Tim Neutkens 625288796f
Move next export into it's own directory (#5084)
* Rename static to export in integration tests

* Move export functionality into it’s own directory

* Fix path
2018-09-04 11:21:00 +02:00
Henrik Wenz c44dab63ff Add with-yarn-workspaces example (#5034)
> Workspaces are a new way to setup your package architecture that’s available by default starting from Yarn 1.0. It allows you to setup multiple packages in such a way that you only need to run yarn install once to install all of them in a single pass.

- [x] Tested in development mode
- [x] Tested in production mode
- [x] Tested with deployment https://with-yarn-workspaces-hwzubdlkul.now.sh/
- [x] Added transpile module example

Closes #3638
2018-09-03 23:41:45 +02:00
Tim Neutkens 52a4dfc8a5 7.0.0-canary.11 2018-09-03 21:04:06 +02:00
Tim Neutkens 1cdc25ff79
Use terser for minification (#5083)
Fixes #5021
2018-09-03 20:59:11 +02:00
Don Alvarez 14c7b25fcc Add with-sitemap-and-robots-express-server-typescript example (#5076)
Pulling out a few core points from the readme...

This example builds from /src into /dist, managing the different expectations of express.js (es5, commonjs) and next.js (es6) by using a pair of tsconfig.json files, both of which are run by `npm run build-ts` or any of the other npm targets.

Hot module reloading is largely but not completely wired up (nodemon is watching /dist but tsc isn't set up to watch /src and transpile changes in /src to /dist automatically (that's mainly because I wasn't sure how to start both nodemon and a pair of tsc watchers and be confident all would get shut down when the user killed dev mode). The readme suggests running `npm run build-ts` manually in another window to push changes from /src into /dev and on into the browser. 

tslint is also wired up via `npm run tslint`
2018-09-03 16:43:19 +02:00
Tim Neutkens b97fc82aa1
Use preset-react's development option + enable modules transform in test env (#5081)
## Minor changes

When `NODE_ENV=test` is used we'll now apply the `'auto'` configuration for modules transformation. Which causes Babel to check if the current environment needs to be transformed or not. In practice this means that the following `.babelrc` is not needed anymore:

**OLD**:

```json
{
  "env": {
    "development": {
      "presets": ["next/babel"]
    },
    "production": {
      "presets": ["next/babel"]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
    }
  }
}
```

**NEW**:

```
{
  "presets": ["next/babel"]
}
```

## Patches

`@babel/preset-react` has a `development` option that automatically applies a development-time plugin we manually applied before (`@babel/plugin-transform-react-jsx-source`). It also adds another development-time plugin that is said to make debugging/errors clearer: `@babel/plugin-transform-react-jsx-self` which we didn't apply before. Overall this means we can take advantage of preset-react to provide these plugins.
2018-09-03 16:41:52 +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 400a04f487
Make warning about false positives clearer (#5079) 2018-09-03 15:13:45 +02:00
Tim Neutkens 6b9b7d44aa 7.0.0-canary.10 2018-09-03 12:10:36 +02:00
Bertrand Marron 2eeebacb4c Keep chunks filenames in production mode (#5029)
* Keep chunks filenames in production mode

* Add test for new `[name]` behavior

* Rename static/dll to static/development/dll
2018-09-03 01:40:21 +02:00
Adam Lane 3d9564215c example with-reasonml dependency updates (#5048)
The original example fails to compile on my windows machine but updating bs-platform fixes that.
Depending on bs-next causes example to fail (package compiled with old incompatible version of bs-platform) so I have included it in a bindings directory where it can serve as an example of reason bindings.
Sources have been migrated to the latest reason-react.
2018-09-03 01:38:54 +02:00
Tim Neutkens 6c1389b69e
Add mention of canary vs stable (#5074) 2018-09-03 00:13:22 +02:00
Ivan Starkov 954fcb9674 Fix react-intl example (#4840)
react-intl does not work otherwise
2018-09-02 23:53:43 +02:00
Tim Neutkens cdf44c4f91 7.0.0-canary.9 2018-09-02 19:18:46 +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 33067a5862
Fix inconsistency in dynamic tests (#5071) 2018-09-02 17:22:29 +02:00
Tim Neutkens 442ec79369 Travis no longer has to remove yarn.lock 2018-09-02 15:20:19 +02:00
Tim Neutkens f9cd204c99 Remove yarn.lock 2018-09-02 15:17:37 +02:00
Tim Neutkens 2f2eaf25e4 Add circleci 2018-09-02 15:14:29 +02:00
Tim Neutkens ff35d2e747 7.0.0-canary.8 2018-09-01 13:01:04 +02:00
Tim Neutkens 3b35e5be14
Upgrade to styled-jsx@canary (#5067)
This fixes an issue with styles jumping around when using `transition: all`
2018-08-31 21:10:20 +02:00
Henrik Wenz b30a8b2e7c WIP: Fix devtoolModuleFilenames for react-error-overlay (#5055)
## Issue

Currently react-error-overlays launch-editor functionality doesn’t work because the module paths are in the wrong format.

## Todo

- [x] Keep source-maps enabled

## Related

https://github.com/zeit/next.js/pull/4979
2018-08-31 15:45:57 +02:00
Popuguy 4ef3788613 Update dependencies in package.json (#5066)
Babel loader v8 now for babel v7
other update fix bugs and performance improvements
2018-08-31 10:42:11 +02:00
Vince Picone d76b850eac Update .babelrc (#5063)
Some really nasty Internal Server errors come as a result of not having the correct module name here.
2018-08-30 23:33:08 +02:00
Daniel Reinoso 1924e3d868 Fix with-custom-reverse-proxy example (#5064)
Fixes #5052.

Example was using babel 6.
2018-08-30 23:32:19 +02:00
Tim Neutkens 4247a13ff1 7.0.0-canary.7 2018-08-30 15:11:11 +02:00
Tim Neutkens fbd933bd22
Fix 404 export (#5061) 2018-08-30 15:10:18 +02:00
Tim Neutkens ead5a8bc3c
Split out Loadable.Capture and make NoSSR smaller (#5060) 2018-08-30 15:09:53 +02:00
Tim Neutkens 3ede818252 7.0.0-canary.6 2018-08-30 14:07:05 +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
Tim Neutkens 18a23b3e4b
Set mode for DLL bundle (#5059) 2018-08-30 12:27:22 +02:00
Nikhil Fadnis 48e4c771c2 Send credentials with on-demand-entries-ping (#5053)
In my use case, the client pings are failing since the requests do not send basic auth credentials right now.

This change was made in https://github.com/zeit/next.js/pull/2509

I am not sure why it was undone as a part of https://github.com/zeit/next.js/pull/3578

Can someone explain why? Thanks.
2018-08-29 14:52:15 +02:00
Tim Neutkens 99c509e449 7.0.0-canary.5 2018-08-28 18:02:29 +02:00
Faris Abusada 015b0a9d22 Fixes dynamic chunks preload links, use href instead of src (#5047)
😬... 

https://w3c.github.io/preload/
2018-08-28 17:56:48 +02:00
Tim Neutkens d0df0e497b 7.0.0-canary.4 2018-08-28 12:46:21 +02:00
Tim Neutkens 4c891a7e8a
Upgrade to Babel 7 stable (#5042) (major)
🎉 https://twitter.com/left_pad/status/1034204330352500736
2018-08-28 12:44:15 +02:00
Tomáš Witek 66ec2061c1 Css example upgrade (#5039)
It looks like we don't need the `_document.js` file anymore.
Is that correct?
2018-08-27 16:13:02 +02:00
Kyle Holmberg b7fe234005 404 routing for static export without exportPathMap (#5036)
Resolves #5035 

Thanks a billion to @timneutkens for holding my hand
2018-08-27 12:28:54 +02:00
Tim Neutkens e0c74948d0 7.0.0-canary.3 2018-08-25 20:41:36 +02:00
Tim Neutkens dfafad488a
Remove UNSAFE_ lifecycles from tests (#5031)
* Remove UNSAFE_componentWillMount

* Remove UNSAFE_componentWillReceiveProps from lifecycle
2018-08-25 20:09:20 +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 1babde1026 7.0.0-canary.2 2018-08-24 16:47:33 +02:00
HaNdTriX 11816537c3 Open editor from error-overlay (minor) (#4979)
This PR adds links to the [react-error-overlay](https://www.npmjs.com/package/react-error-overlay).
This allows a developer to open a stack trace in its own editor.

![codelinking](https://user-images.githubusercontent.com/1265681/44278860-a63e0a80-a24f-11e8-9c69-c5365c026c58.gif)

Closes #4813
2018-08-24 16:30:41 +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