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

2384 commits

Author SHA1 Message Date
Rafał Ruciński 7333dd622c Process available chunk names properly in dev mode (#4604)
Fixes #4603.

Tests explain it the best:

```js
    describe('development mode (no chunkhash)', () => {
      it('should strip the extension from the filename', () => {
        const filename = 'foo_bar_0123456789abcdef.js'
        expect(getChunkNameFromFilename(filename, true)).toBe('foo_bar_0123456789abcdef')
      })

      it('should only strip the extension even if there\'s a hyphen in the name', () => {
        const filename = 'foo-bar-0123456789abcdef.js'
        expect(getChunkNameFromFilename(filename, true)).toBe('foo-bar-0123456789abcdef')
      })
    })

    describe('production mode (with chunkhash)', () => {
      it('should strip the hash from the filename', () => {
        const filename = 'foo_bar_0123456789abcdef-0123456789abcdef.js'
        expect(getChunkNameFromFilename(filename, false)).toBe('foo_bar_0123456789abcdef')
      })

      it('should only strip the part after the last hyphen in the filename', () => {
        const filename = 'foo-bar-0123456789abcdef-0123456789abcdef.js'
        expect(getChunkNameFromFilename(filename, false)).toBe('foo-bar-0123456789abcdef')
      })
    })
```
2018-06-14 11:04:03 +02:00
Tim Neutkens ecf61f65a8 6.0.4-canary.6 2018-06-13 22:15:37 +02:00
Tim Neutkens 2a1075c122 Check if the incoming header is set before applying to the response 2018-06-13 22:06:36 +02:00
Tim Neutkens 06136d9111 6.0.4-canary.5 2018-06-13 20:33:35 +02:00
Tim Neutkens 83b5c13810 Use this.dir to join the resolved path 2018-06-13 20:33:19 +02:00
Tim Neutkens f670412c77 6.0.4-canary.4 2018-06-13 19:45:50 +02:00
Lon Ilesanmi 81802d2e60 Clean up Redux example (#4594)
- Remove unused imports

- Edit some comments

- Rename Wrapper App Class
2018-06-13 14:40:59 +02:00
James Hegedus 4f4b7a1bce with-firebase-hosting: fix npm scripts, remove firebase.json predeploy scripts (#4593)
* remove `predeploy` scripts from `firebase.json` in favour of `npm` `pre` scripts as they are consistent across `deploy` and `serve` commands. (to revisit once Firebase add support in the `firebase.json` for `preserve`)
* update deps
* workaround some bug where Babel could not resolve the standard `next/babel` config. Explicitly defining this seems to remove the issue.
* closes #4562
2018-06-12 17:37:13 +02:00
Tim Neutkens e2beadd960
Upgrade update-check (#4585)
Fixes #4581
2018-06-11 13:23:28 +02:00
Telegin Evgeniy 567da9adbf Upgrade gh-pages example to next 6.0.3 (#4575)
Hello! I have got an error while building [gh-pages example](https://github.com/zeit/next.js/tree/canary/examples/gh-pages) with next 6.0.3. I have found solution to use CommonJS modules in `.babelrc`

This resolves #4227
2018-06-10 13:08:52 +02:00
Rafał Ruciński c74ad93e14 Fix a mistake in chunk name generation (#4573)
This fixes a missed bug introduced in #4510.

Because the regexp was `/-[^-]*/` and not `/-[^-]*$/`, a wrong part of the filename was being removed:

```
bad:
'foo-bar-0123456789abcdef-0123456789abcdef.js' -> 'foo-0123456789abcdef-0123456789abcdef.js'

good:
'foo-bar-0123456789abcdef-0123456789abcdef.js' -> 'foo-bar-0123456789abcdef'
```

By a stroke of luck this didn't affect the existing dynamically generated chunks. To prevent regression I've added unit tests for the function that generates the name.

Btw. in the original issue (#4433) I used the right regexp, I just used the wrong regexp in #4510.

cc @timneutkens
2018-06-09 13:46:27 +02:00
Brice BERNARD 7e8acf3a30 [with-apollo-auth] simplify apolloState prop (#4563)
We don't need `.data` as `apollo.cache.extract()` returns at least `{}` when cache is empty
2018-06-08 11:48:10 +02:00
Brice BERNARD e318de62c0 [with-apollo-auth] Remove useless check from constructor (#4560)
We don't pass apolloClient as props, so I removed the check as confusing and always false.

see https://github.com/zeit/next.js/blob/canary/examples/with-apollo-auth/lib/withApollo.js#L72-L75

Again please explain me if I am wrong :)
2018-06-08 10:27:31 +02:00
Brice BERNARD 1a8bdba56b [with-apollo-auth] Remove useless apolloState from App's props (#4554)
App component does not need/use apolloState prop, so let's remove it. If I'm wrong please explain me the purpose of this.
2018-06-08 08:54:19 +02:00
Pascal Birchler a411b35508 Fix Access-Control-Request-Method header (#4424)
* Fix Access-Control-Request-Method header

* Make OPTIONS request work
2018-06-07 20:18:29 +02:00
Tim Neutkens f11d3487f6
Remove react-hot-loader dependency (#4550)
React hot loader was removed already, the dependency still had to be removed.
2018-06-07 13:37:48 +02:00
Rafał Ruciński e6ff476198 Use a more appropriate regexp for removing hash from a filename (#4510)
Fixes one of the problems described in #4433.

The old regexp was removing everything after a hyphen, so with a chunk name like so:

```
chunks/path-to-a-file-[hash].js
```

the saved chunk name was

```
chunks/path
```

This caused problems, because webpack by default changes `/` to `-` in chunk names generated e.g. by ``import(`foo/${bar}`)``.

After this change the chunk name will be

```
chunks/path-to-a-file
```
2018-06-07 13:19:53 +02:00
Giau Tran Minh 631e6c7eba Added example for Ant Design with LESS (#4520)
* Added example for Ant Design with LESS

* Fix ESLINT
2018-06-07 13:14:27 +02:00
Robert van Steen 2af4ad8b17 Add dependencies of _app.js to commons (#4396)
Since `_app.js` is used on every page it makes sense to move it's dependencies to the `commons.js` so that if you require a dependency in `_app.js` and in one of your pages it is not included twice in your bundles. 

This PR modifies the `CommonsChunkPlugin` to move every module that is used in `_app.js` and at least in one other bundle.
2018-06-07 13:12:48 +02:00
Eugene Sokovikov 3684231add stop duplicating charset (#4546)
**Make amp example valid**

I'm using amp validator chrome plugin which shows that `meta charset=utf-8` is duplicated.
I assume that `Head` component adds `<meta charset="utf-8" class="next-head next-head">`
anyway.
And this line just duplicating it.

<img width="987" alt="screen shot 2018-06-06 at 15 54 45" src="https://user-images.githubusercontent.com/1488195/41036743-198ca00a-69a2-11e8-978c-5a5cb5a994d2.png">
2018-06-06 14:23:20 +02:00
Nick Gauthier bbbf7ab498 Upgrade with-jest-typescript example to next 6.0.0 (#4543)
Hello! I ran into an issue using typescript and jest with next 6.0.0. I was able to work through fixing it and I wanted to share my solution back to next.js, by upgrading the with-jest-typescript example to next 6.0.0.

The steps I followed were:

1. `npx babel-upgrade --write` which added babel-core@^7.0.0-bridge.0 to allow jest's babel 6 to play nice with next's babel 7
2. Remove `ts-jest` and replace with `babel-jest` to use babel to transform the typescript code, as is done when the dev and production builds run
3. Update the babelrc to use commonjs modules in test mode to be compatible with jest

Also, I removed the `NODE_ENV=test` on the jest task, because jest sets the env to test anyways, and I'm on windows where this code is incorrect. The other option is to use `cross-env` but I felt it was simpler to just remove the environment override.

To my knowledge, this PR would help on the following issues:

#3663 #4227 #4531 #4528 #4239
2018-06-06 10:31:21 +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 18676e0870
Remove uglify options in preparation of webpack 4 (#4536) 2018-06-04 15:05:18 +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
Tobi 905da6f92b fixes bug in with-react-intl example: messages and locale variables were undefined on CSR (#4517) 2018-06-01 23:16:11 +02:00
Tim Neutkens 8210686067
Remove deprecated and removed route (#4509) 2018-06-01 13:15:03 +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 14a7264c27 6.0.4-canary.3 2018-05-31 14:26:11 +02:00
Tim Neutkens 86d01706a6
Remove react-hot-loader (#4500)
Fixes #4494
2018-05-31 11:47:29 +02:00
Tim Neutkens 0f9ea55023 6.0.4-canary.2 2018-05-29 19:42:15 +02:00
Jorge Cuadra 8082eddaef Remove unused import (patch) (#4493) 2018-05-29 19:33:21 +02:00
Tim Neutkens cd1a2fbd91
Add check for added/deleted pages (#4497) 2018-05-29 19:32:16 +02:00
Shu Ding 8cbc0be845 Add with-next-less example (#4492) 2018-05-29 10:37:03 +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
daniel tea 832c494470 fix README typo (#4476)
`idead` to `idea`
2018-05-26 12:11:09 +02:00
Tim Neutkens 1b63a14136 6.0.4-canary.1 2018-05-25 15:35:04 +02:00
Vlad Nicula dbd6f515a0 Fix dynamic import in non webpack env regression #3345 (#4208)
Just in case #3345 was a regression and nextjs should still support non webpack node envs for testing.
2018-05-25 15:29:26 +02:00
Ari Leo Frankel 9b88eef897 fix(bin/next:inspect): Allow node inspect flag to be used (#4160)
This accepts arguments to a node --inspect flag as well as other debugging node flags.

Resolves #4151
2018-05-25 15:10:55 +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
Tim Neutkens 4e8009c107 Add section to the readme about configuring .babelrc 2018-05-25 14:39:37 +02:00
Tim Neutkens e9242705a3
Default query to {}, same behaviour as next export (#4466) 2018-05-25 14:27:18 +02:00
Robin Wieruch 2c3e8d3201 Improve route prefetch docs: add client side imperative code (#4213)
I stumbled into this Issue https://github.com/zeit/next.js/issues/2868 and thought it should be mentioned properly in the documentation.
2018-05-25 14:26:45 +02:00
João Granado 8c6a4ebb1d Fix generated page chunk when libraryTarget is umd (#4205)
This fixes the generated page chunk created by the webpack `pages-plugin` which adds a new line in the beginning of the template, when using `output.libraryTarget` set to be [`umd`](https://webpack.js.org/configuration/output/#module-definition-systems) it returns the module.

Consider the following example, which is the output with the previous implementation:

```js
(function webpackUniversalModuleDefinition(root, factory) {
  if(typeof exports === 'object' && typeof module === 'object')
    module.exports = factory();
  else if(typeof define === 'function' && define.amd)
    define([], factory);
  else if(typeof exports === 'object')
    exports["MyLibrary"] = factory();
  else
    root["MyLibrary"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
  return
    __NEXT_REGISTER_PAGE(...)
});
```

`__NEXT_REGISTER_PAGE()` won't be executed since a `return` statement followed by a new line is the same as having a semicolon inserted right after the `return`. By removing the new line in the beginning of the source concatenation (which I suppose was added for stylistic reasons) this works as expected.
2018-05-25 14:23:44 +02:00
Tim Neutkens 2e9bed098d Remove page-transitions example 2018-05-25 14:19:40 +02:00
Kelly Burke 3f6834dfec sitemap.xml and robots.txt example (#4163)
This example app shows you how to set up sitemap.xml and robots.txt files for proper indexing by search engine bots.
2018-05-25 14:01:32 +02:00
Timothy Vernon a806c16713 Clarify documentation regarding the static folder (#4340) 2018-05-25 13:42:19 +02:00
Shu Ding 4df7e48f94 Add title to default error page (#4383) 2018-05-25 13:35:59 +02:00
Luke Barton cbfdcce32d Update typescript examples to use 1.0.1 of next-typescript (#4472)
* Update typescript examples to use 1.0.1 of next-typescript

* Add .babelrc modifications to upgraded typescript examples
2018-05-25 11:28:35 +02:00