Commit graph

64 commits

Author SHA1 Message Date
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
f89d55f10d Add selenium-webdriver and testing cross-browser in PRs (#9821)
* Migrate from wd to selenium-webdriver

* Add chaining for next-webdriver

* Re-add browserStackLocal global for teardown

* Add additional element methods

* Use freshWindow helper for chrome

* Add selenium-server

* Add cross-env for windows compat

* Fix single quote windows

* Update production preload tests

* Update preload tests count

* Update CircleCi for testing other browsers

* Update CI configs

* Update config

* Add browser.url command

* Add more methods

* Update xcode version

* Make sure to add chromedriver to path

* Add forceExit flag

* Update config

* Update config

* Disable safari

* Fix bug in test

* Add teardown logging

* Update jest teardown

* Move testing ie11 to Azure

* Update job names

* Remove force exiting on long teardown

* Update Azure config

* Re-add safari testing with BrowserStack

* Update config

* Update prefetch tests for ie11

* Update prefetch for safari and ids for ie11 testing

* trigger prefetching manually in ie
2019-12-26 15:01:22 -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
01b7c576b4 Breakup CSS test suite (#9715)
* Breakup CSS test suite

* De-dupe next.config.js for css-fixtures
2019-12-11 18:39:09 -05: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
JJ Kasper
b058427b76 Update CI/test set up (#9499)
* Disable concurrency for tests

* Add browser instance sharing

* Bump concurrency and install chromedriver smoother

* Fix config typo

* Fix local test

* Limit azure concurrency again

* Add delay for empty-object-test

* Make sure to use open port for chromedriver

* Move browser closing to jest-environment

* Re-enable concurrency for Azure

* bump

* Disable concurrency for Azure again

* Re-enable concurrency for Azure

* bump
2019-11-25 13:19:45 -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
JJ Kasper
03d589349a
Render valid optimized AMP by default (#7465)
* Upgrade to latest AMP toolbox optimizer

* Remove amphtml from AMP only and update tests

* Update tests

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>
2019-05-29 19:53:41 -07: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
JJ Kasper
6344c5f0c1
Add optimizing AMP pages (#6835)
* Added amp-toolbox-optimizer and added
optimizing AMP pages as dirty and clean

* Fix amp-optimizer breaking serverless build

* Exclude amp-toolbox-optimizer from serverless build

* Added check to make sure hybrid AMP pages
optimize cleanly during export

* Add check to make sure noDirtyAmp is applied
2019-04-02 13:01:34 -05:00
JJ Kasper
e25312b7d7
Make sure error isn't swallowed for production test on CircleCi (#6848) 2019-04-01 09:58:17 -05:00
JJ Kasper
14eef58702 Re-add chromedriver retrying from previous webdriver setup (#6846)
* Re-add previous webdriver setup with falling
back to BrowserStack setup

* Add missing webdriver imports
2019-04-01 16:09:09 +02: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
JJ Kasper
533018f7d0 Update tests for BrowserStack (#6810)
Update tests to setup webdriver stuff in `jest-environment` and re-use one browser session instead of spawning one for each webdriver call to prevent creating too many BrowserStack sessions.
2019-03-29 16:05:53 +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
a3356c5edb Try restarting chromedriver on timeout (#6566)
Also added `HEADLESS` env var for local testing
2019-03-08 10:23:57 +01: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
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
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