Commit graph

59 commits

Author SHA1 Message Date
Joe Haddad
86160a5190
Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
Jan Potoms
714747957a
Add eslint-plugin-jest (#13003) 2020-05-18 13:16:07 -04:00
Joe Haddad
ae1daea355
Enable Fast Refresh by Default (#12640) 2020-05-10 19:25:57 -04:00
Joe Haddad
3a41ddb56e
Fix check utility in tests (#12678) 2020-05-10 11:36:07 +02:00
JJ Kasper
b72d9fa41d
Update tests to poll for output instead of wait for it (#12534) 2020-05-05 15:19:07 -05:00
JJ Kasper
00d930aae8
Add additional file serving tests (#12479)
* Test `static/` file name encoding

* Fix `static/` file name encoding

* Add additional file-serving tests

* bump

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-05-04 11:58:19 -05:00
Tim Neutkens
e907e4791c
New logging output (#12169)
* Add new logger output

* Fix tests

* Fix tests

* Update next start log for consistency

* Fix cli tests

* Fix tsconfig tests

* Update plugins test

* Fix invalid-custom-routes tests

* Revert "Fix invalid-custom-routes tests"

This reverts commit 8e8eec11dd21feb2186163856207bb974110c13e.

* Revert "Update plugins test"

This reverts commit 3f09270509ea52a1b4f0515cee8e4e711f7e1b16.

* Revert "Fix tsconfig tests"

This reverts commit a4c23bb120e81a15ea50dc6ad1ad097368ef3be6.

* Revert "Fix cli tests"

This reverts commit ff3a321d29bd9afb09f7cf550823010a08a54ae1.

* Revert "Update next start log for consistency"

This reverts commit 481509d8f713a918b7a125e4b7f7bc5c5990c2e1.

* Revert "Fix tests"

This reverts commit 6fb2cb59f79fdf8495fc7288c1c18ece75279ed7.

* Revert "Fix tests"

This reverts commit 9d37298dbc20392a33338cf45166ad86c556de4b.

* Fix tests

* Update next start message

* Update packages/next/build/output/log.ts

Co-Authored-By: Joe Haddad <timer@zeit.co>

* Fix tests

Co-authored-by: Joe Haddad <timer@zeit.co>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-29 04:49:28 -04:00
Joey Tepperman
cdc7f01954
Add warning when a page is rendered without a starting / (#11418)
* Add error/warning when a page is rendered without a /

Throws an error for development and gives a warning in production

* Add tests for error when rendering without starting slash

* Update to always warn and add err.sh

* Update errors/render-no-starting-slash.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-04-06 11:54:42 -05:00
JJ Kasper
53e9983d83 Add hydration callback for testing (#10195)
* Add hydration callback for testing

* Update size-limit test
2020-01-21 15:33:58 -05:00
JJ Kasper
ee0761255a Error on query values in exportPathMap for auto export page (#9908)
* Add warning when providing query values in exportPathMap for auto-export page

* Update test for SSG page also

* Update to error instead of warn

* Update warn -> Error and check exit code
2020-01-16 21:39:00 -05:00
Brian Mathews
5a2182e62e Add assetPrefix when fetching script and style dependencies (#9933)
* Add assetPrefix when fetching script and style dependencies for granularChunks

* Lint

* Fix assetPrefix usage with granularChunks

* Add tests for granularChunks with assetPrefix

* Cleanup
2020-01-06 10:55:39 -05:00
JJ Kasper
fd1636ae4d
Update prerender test for Windows (#9800) 2019-12-20 14:15:55 -06:00
JJ Kasper
8267c8a6eb
Normalize RegEx source between node versions (#9749) 2019-12-14 11:25:55 -06:00
Joe Haddad
62a6ece4b9 Emit Static Export Intent (#9737)
* Emit Static Export Intent

* Remove the old export detail on rebuild

* Add test cases

* fix export

* Add a resolve return
2019-12-13 13:30:22 -06:00
JJ Kasper
6c103ef5a6 Add checking of custom routes for invalid fields (#9434)
* Add checking of custom routes for invalid fields

* Remove un-used test imports

* Mentioned statusCode can be undefined in error message

* Update test

* Update invalid routes output

* Add checking to make sure source/destination start with slash

* Update import
2019-12-10 09:54:56 -05:00
Joe Haddad
6387d9b5bc
Fix Dynamic next export Page Hydration Mismatch (#9388)
* Fix `next export` Hydration Mismatch

* Lower timeout to 1 minute
2019-11-12 18:34:12 -08:00
Joe Haddad
18a9c7e371
Improve linting rules to catch more errors (#9374)
* Update `packages/`

* Update examples

* Update tests

* Update bench

* Update top level files

* Fix build

* trigger
2019-11-10 19:24:53 -08:00
JJ Kasper
e2d713f93e De-experimentalize the public/ folder (#8661)
* Remove experimental.publicDirectory config

* Error when public is set as an output dir

* Remove experimental.publicDirectory checks

* Update publicFiles checking in next build
2019-10-06 13:44:03 +02:00
Joe Haddad
f890482871
Check for TypeScript files for auto setup (#8479)
* Check for TypeScript files for auto setup
This re-adds the behavior and only checks the `pages` directory for speed reasons.

* Adjust logic

* Handle not found too
2019-08-22 22:01:12 -04:00
JJ Kasper
56a134409c Debug TypeScript test suite (#8476)
* Tweak typescript test suite

* Revert "Tweak typescript test suite"

This reverts commit 9e0108da7c70e7ae45b412b60c07162383de65f3.

* Make sure HMR connection isn't being closed
while testing

* Update to not re-use NODE_ENV

* Break up/rework TypeScript test suite

* bump
2019-08-22 16:34:24 -04:00
Joe Haddad
a3d64abe5d
Swallow test process kill errors on win32 (#8260)
* Swallow process kill errors

* Strictly look for messsage
2019-08-06 12:51:05 -04:00
JJ Kasper
13fa2828c2 Add missing key prop for array elements in _document (#8132)
* Add missing keys for array elements

* Add test for missing key prop in app-document
2019-07-27 10:34:29 +02:00
Lukáš Huvar
2450c85e81 exportPathMap dynamic routes params fix (#7846)
* Fix dynamic page export fixes #7829

* Adding handling of unmatched path

* Remove logs

* Fix newline

* Tests

* Fix promise

* Fix amp tests

* Revert test

* Adjust error document

* Remove old argument

* Simplify export test

* Ensure page !== path for this check
2019-07-10 17:13:44 -04:00
Junyoung Choi
12f1a63442 Expose next function type (#7726)
* Expose next function type

* Add type testing for typescript custom server

* Move types test to integration folder
2019-07-03 19:38:58 -07:00
Joe Haddad
a372edae48 Default target in loadConfig instead of next build (#7521)
* Default `target` in `loadConfig` instead of `next build`
We should set the target from the environment variable during `loadConfig` instead of in `next build`. This ensures all other locations in Next.js that rely on `config` can read the correct value to toggle behaviors.

* Use object destructuring

* Add tests for builder target

* Run start with serverless
2019-06-06 15:57:42 +02:00
Joe Haddad
b3170d2648
Format missed files (#7464)
* Format missed files

* Remove unnecessary rule

* Fix type error
2019-05-29 18:19:32 -07:00
JJ Kasper
cdd54afb0d Add auto static/dynamic (#7293)
* Add automatic exporting of pages with no getInitialProps

* Add support for exporting serverless to static
and serving the html files during next start

* Fix missing runtimeEnv when requiring page, re-add warning
when trying to export with serverless, and update tests

* Update flying-shuttle test

* revert un-used pagesManifest change

* remove query.amp RegExp test

* Fix windows backslashes not being replaced

* Re-enable serverless support for next start

* bump

* Fix getInitialProps check

* Fix incorrect error check

* Re-add check for reserved pages

* Fix static check

* Update to ignore /api pages and clean up some tests

* Re-add needed next.config for test and correct behavior

* Update RegExp for ignored pages for auto-static

* Add checking for custom getInitialProps in pages/_app

* Update isPageStatic logic to only use default export

* Re-add retrying to CircleCi

* Update query during dev to only have values
available during export for static pages

* Fix test

* Add warning when page without default export is
found and make sure to update pages-manifest
correctly in flying-shuttle mode

* Fix backslashes not being replaced

* Integrate auto-static with flying-shuttle
and make sure AMP is handled in flying-shuttle

* Add autoExport for opting in
2019-05-22 09:36:53 -07:00
JJ Kasper
0eab07b7e8
Add automatic TypeScript setup (#7125)
* replace fkill with tree-kill
2019-05-08 21:51:23 -05:00
JJ Kasper
f861e0da75
Make sure not to require react before NODE_ENV has been set (#7200)
* Make sure not to require react before
NODE_ENV has been set

* Update to use force kill to make windows happy
2019-04-30 13:11:19 -05:00
Justin Chase
52dd42a6bb Do not clear the console (#6758)
* Do not clear the console

Its rude to clear the console, you may be sharing output with other processes even in tty mode.

* Remove unused dependency

* Dedupe and cleanup dev output without clearing

* use logError

* Remove exit handler

* Add next helper

* Add log helpers

* Switch store to log helpers and a shallow object compare

* Update other files to use new logging utility

* request => build

* Update ready on messages

* Use case insensitive matching
2019-04-09 11:52:03 -04:00
Luis Fernando Alvarez D
f81e5f4cad Added babel-plugin-dynamic-import-node (#6811)
Replaces `import()` with `require` only for the testing environment.
2019-03-30 01:50:24 +01:00
Luis Fernando Alvarez D
a750d1cc42
NODE_ENV is set to undefined before running a test command (#6823) 2019-03-28 17:05:18 -05:00
Luis Fernando Alvarez D
51b15417f8 The custom build test now runs in production mode (#6818)
I also removed the copy it had of `runNextCommand`
2019-03-28 20:13:27 +01:00
JJ Kasper
e95030b582
Update to have default value for renderToHTML (#6755)
* Update to have default value for renderToHTML
options in dev mode

* Update test
2019-03-23 11:20:54 -05:00
JJ Kasper
c3b1f31ed5 Fix /index/index.js route not emitting the right route in production (#6516)
Also added integration test in production for this

Fixes: #6285
2019-03-03 19:36:32 +01:00
Connor Davis
fcf1167cd4 Upgrade standard and fix files (#6358)
Upgrades `standard` to major version 12
2019-02-19 22:45:07 +01:00
JJ Kasper
bf69357f27 Remove onDemandEntries WebSocket server in favor of EventSource connection (#6354)
After talking with @timneutkens it was decided it'd be more streamlined to replace the onDemandEntries WebSocket with an alternative. Using the EventSource connection gives us these benefits over the WebSocket one:

- less code needed
- no extra server running
- no extra config for onDemandEntries
2019-02-19 21:58:47 +01:00
Connor Davis
1e5d0908d0 Block Certain Env Keys That Are Used Internally (#6260)
Closes: #6244 

This will block the following keys:
```
NODE_.+
__.+
```

There doesn't seem to be a way to simulate a failed build or else I'd add tests for it.
2019-02-15 17:49:40 +01:00
Tim Neutkens
0f23faf81f
Serverless Next.js (#5927)
**This does not change existing behavior.**

building to serverless is completely opt-in.

- Implements `target: 'serverless'` in `next.config.js`
- Removes `next build --lambdas` (was only available on next@canary so far)

This implements the concept of build targets. Currently there will be 2 build targets:

- server (This is the target that already existed / the default, no changes here)
- serverless (New target aimed at compiling pages to serverless handlers)

The serverless target will output a single file per `page` in the `pages` directory:

- `pages/index.js` => `.next/serverless/index.js`
- `pages/about.js` => `.next/serverless/about.js`

So what is inside `.next/serverless/about.js`? All the code needed to render that specific page. It has the Node.js `http.Server` request handler function signature:

```ts
(req: http.IncomingMessage, res: http.ServerResponse) => void
```

So how do you use it? Generally you **don't** want to use the below example, but for illustration purposes it's shown how the handler is called using a plain `http.Server`:

```js
const http = require('http')
// Note that `.default` is needed because the exported module is an esmodule
const handler = require('./.next/serverless/about.js').default
const server = new http.Server((req, res) => handler(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```

Generally you'll upload this handler function to an external service like [Now v2](https://zeit.co/now-2), the `@now/next` builder will be updated to reflect these changes. This means that it'll be no longer neccesary for `@now/next` to do some of the guesswork in creating smaller handler functions. As Next.js will output the smallest possible serverless handler function automatically.

The function has 0 dependencies so no node_modules are required to run it, and is generally very small. 45Kb zipped is the baseline, but I'm sure we can make it even smaller in the future.

One important thing to note is that the function won't try to load `next.config.js`, so `publicRuntimeConfig` / `serverRuntimeConfig` are not supported. Reasons are outlined here: #5846

So to summarize:

- every page becomes a serverless function
- the serverless function has 0 dependencies (they're all inlined)
- "just" uses the `req` and `res` coming from Node.js
- opt-in using `target: 'serverless'` in `next.config.js`
- Does not load next.config.js when executing the function

TODO:

- [x] Compile next/dynamic / `import()` into the function file, so that no extra files have to be uploaded.
- [x] Setting `assetPrefix` at build time for serverless target
- [x] Support custom /_app
- [x] Support custom /_document
- [x] Support custom /_error
- [x] Add `next.config.js` property for `target`

Need discussion:
- [ ] Since the serverless target won't support `publicRuntimeConfig` / `serverRuntimeConfig` as they're runtime values. I think we should support build-time env var replacement with webpack.DefinePlugin or similar.
- [ ] Serving static files with the correct cache-control, as there is no static file serving in the serverless target
2018-12-28 11:39:12 +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
Tim Neutkens
b1c4f3aec4
Monorepo (#5341)
- Implements Lerna
- Moves all source code into `packages/next`
- Keeps integration tests in the root directory
2018-10-01 01:02:10 +02:00
Tim Neutkens
db216e0086
Even more reliable error-recovery tests (#5284) 2018-09-26 01:04:15 +02:00
Tim Neutkens
139bc40fb5
More reliable error-recovery tests (#5281)
As they were failing intermittently, this PR tries to solve that.
2018-09-25 16:54:03 +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
Tim Neutkens
33067a5862
Fix inconsistency in dynamic tests (#5071) 2018-09-02 17:22:29 +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
Tim Neutkens
17e410a1d0
Fix Typescript HMR (#4689)
Fixes #4686

Adds tests for @zeit/next-typescript so that we don't regress on this again.

I've fixed an issue in the `next` CLI too which caused lingering processes when the process gets force killed, which is what we do in the test suite, so it kept running if there was no manual quit.
2018-06-28 20:07:41 +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
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
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