Commit graph

164 commits

Author SHA1 Message Date
Tobias Koppers
d07107f2c6
add experimental.urlImports option (#30079)
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Rich Haines <hello@richardhaines.dev>
2021-10-21 13:14:57 +02:00
Tobias Koppers
7cb5577e48
make test directories more unique (#29864)
I wouldn't believe it, but it actually happens that the first two test cases try to create their test directory at the same millisecond, resulting in a shared directory, which leads to conflicts.
2021-10-13 08:13:15 +00:00
JJ Kasper
ebc1b0e559
Fix missing trace items and migrate required files test (#29649) 2021-10-05 13:52:19 -05:00
JJ Kasper
38ac55dd20
Update output tracing resolving (#29473) 2021-09-29 12:38:21 -05:00
Tobias Koppers
4f212ee91d
the way towards webpack 5 typings (#29105)
Co-authored-by: sokra <sokra@users.noreply.github.com>
2021-09-21 19:17:16 +02:00
JJ Kasper
8e52126ea6
Migrate prerender tests to new set-up (#29245) 2021-09-21 16:21:05 +02:00
JJ Kasper
371ca582d1
Ensure trailingSlash is correct for index with query (#29217) 2021-09-21 16:18:42 +02:00
JJ Kasper
cefd9cf283
Add crawler blocking for fallback: true (#29121)
* Add crawler blocking for fallback: true

* update test

* Update check

* Add note to docs

* use browser agent for non-crawler test
2021-09-16 11:01:28 -05:00
JJ Kasper
6a9cda5726
Ensure browser instances are not re-created un-necessarily (#29091) 2021-09-15 10:03:33 -05:00
JJ Kasper
a92a5caec2
Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00
JJ Kasper
24b09ad4f8
Add entrypoint tracing (#25538)
This adds tracing entrypoints directly after they have have been transpiled to allow us to trace before the webpack runtime has been added to the modules. This should allow for more accurate tracing of entrypoints and allow the trace step to be cached. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added


x-ref: https://github.com/vercel/next.js/issues/24700
x-ref: https://github.com/vercel/next.js/issues/26200
x-ref: https://github.com/vercel/next.js/issues/23894
x-ref: https://github.com/vercel/next.js/issues/25431
2021-08-16 19:29:11 +00:00
JJ Kasper
4ab41efdbf
Add handling for repeated slashes (#27738)
This adds handling for repeated forward/back slashes in Next.js, when these slashes are detected in a request to Next.js we will automatically remove the additional slashes redirecting with a 308 status code which prevents duplicate content when being crawled by search engines. 

Fixes: https://github.com/vercel/next.js/issues/13011
Fixes: https://github.com/vercel/next.js/issues/23772
Closes: https://github.com/vercel/next.js/pull/15171
Closes: https://github.com/vercel/next.js/pull/25745
2021-08-03 15:06:26 +00:00
Jiachi Liu
a6e478f9ed
Use require alias to resolve react 18 for testing (#27601)
For test only, previously the react-dom is still been resolved as react 17

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-29 20:06:13 +00:00
JJ Kasper
ef379f1500
Ensure has query encoding is normalized (#25732)
* Ensure has query encoding is normalized

* fix type error
2021-06-17 10:52:11 -05:00
Houssein Djirdeh
bbc28ccae0
next lint + ESLint in Create Next App (#25064)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-06-03 14:01:24 +02:00
JJ Kasper
e6a05ee940
Fix export worker threads options (#25063)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-14 12:50:29 +02:00
JJ Kasper
85d87a3795
Ensure dev overlay is triggered for more _app/_document errors (#24328)
This expands on https://github.com/vercel/next.js/issues/24070 and ensures we show the dev overlay for additional cases like where `_app` or `_document` have syntax errors causing compilation to not be able to complete. This achieves showing the dev overlay even when compilation fails from a syntax error by doing a third minimal compilation in development with the needed client-side assets to render the dev overlay. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

x-ref: https://github.com/vercel/next.js/issues/24070
2021-04-22 11:08:47 +00:00
Brandon Bayer
8ccfff10ae
fix types of next-webdriver (#23995)
This does not touch any next.js code. This improves the integration test setup by properly typing next-webdriver.
2021-04-20 18:40:51 +00:00
JJ Kasper
348115036c
Ensure no-op export returns without error (#23752)
This ensures we don't reach the invariant from trying to create the export progress with no items during `next build` or `next export` by returning immediately when we notice there are no paths being exported. Additional tests have been added to ensure these cases don't error. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

Fixes: https://github.com/vercel/next.js/issues/23724
2021-04-06 17:12:23 +00:00
JJ Kasper
5cf16ece71
Ensure static 500 hydrates correctly with query (#22468)
Follow-up to https://github.com/vercel/next.js/pull/22139 this ensures the default 500 error page hydrates with the correct `statusCode` prop when updating query values on the client since currently it will switch the 404 `statusCode` when one isn't present. An additional test case has been added to ensure this is handled correctly.
2021-02-23 22:15:46 +00:00
JJ Kasper
8bdff57b15
Update redbox tests (#20866)
This adds retrying for getting redbox content and ensures the `next.config.js` file is cleaned up for the dynamic-routing test suite.

x-ref: https://github.com/vercel/next.js/pull/20786#issuecomment-755929891
2021-01-07 18:06:40 +00:00
Jamie
397a375b37
Ensure next commands respect termination signals (#19433)
Fixes #16173

## What

Restores handling of termination signals, `SIGTERM` and `SIGINT`, to allow graceful termination of next commands. Seems to have been removed during a child process refactor #6450, was this intentional?

## Why 

Currently the command processes have to be forcefully killed. This would help those using Next.js with custom servers and tools like Docker and Kubernetes that rely on termination signals to shutdown instances.

---

Where would be a good location to add some tests? [test/integration/cli/test/index.test.js](fc98c13a2e/test/integration/cli/test/index.test.js)?
2020-11-25 13:30:06 +00:00
JJ Kasper
db0587c4ac
Fix relay-analytics test on Azure (#18875) 2020-11-05 23:19:02 -05:00
JJ Kasper
a5cb28d907
Ensure redirects are handled properly from cache (#18806)
This updates the GS(S)P redirect handling to make sure to handle redirects correctly when coming from the incremental-cache. Additional tests have been added to ensure the redirects work correctly after the cache is populated. 

Fixes: https://github.com/vercel/next.js/issues/18735
Fixes: https://github.com/vercel/next.js/issues/18783
2020-11-04 22:18:44 +00:00
Steven
afa04d22db
Add layout prop to Image component (#18491)
This PR introduces a new `layout` property.

This allows 3 possible values (`fixed`, `intrinsic`, or `responsive`) which solve many use cases we have seen since 10.0.0 and will hopefully avoid usage of `unsized`.

Fixes #18351 

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-10-30 10:33:34 -04:00
JJ Kasper
f01deeedb9
Stabilize i18n fallback test (#17957)
* Stabilize i18n fallback test

* Handle reload during hydration check
2020-10-16 16:17:12 -05:00
JJ Kasper
bbc1a21c74
Update to have default locale matched on root (#17669)
Follow-up PR to https://github.com/vercel/next.js/pull/17370 when the path is not prefixed with a locale and the default locale is the detected locale it doesn't redirect to locale prefixed variant. If the default locale path is visited and the default locale is visited this also redirects to the root removing the un-necessary locale in the URL. 

This also exposes the `defaultLocale` on the router since the RFC mentions `Setting a defaultLocale is required in every i18n library so it'd be useful for Next.js to provide it to the application.` although doesn't explicitly spec where we want to expose it. If we want to expose it differently this can be updated.
2020-10-08 11:12:17 +00:00
JJ Kasper
b2d1d87e7f
Add initial changes for i18n support (#17370)
This adds the initial changes outlined in the [i18n routing RFC](https://github.com/vercel/next.js/discussions/17078). This currently treats the locale prefix on routes similar to how the basePath is treated in that the config doesn't require any changes to your pages directory and is automatically stripped/added based on the detected locale that should be used. 

Currently redirecting occurs on the `/` route if a locale is detected regardless of if an optional catch-all route would match the `/` route or not we may want to investigate whether we want to disable this redirection automatically if an `/index.js` file isn't present at root of the pages directory. 

TODO: 

- [x] ensure locale detection/populating works in serverless mode correctly
- [x] add tests for locale handling in different modes, fallback/getStaticProps/getServerSideProps

To be continued in fall-up PRs

- [ ] add tests for revalidate, auto-export, basePath + i18n
- [ ] add mapping of domains with locales
- [ ] investigate detecting locale against non-index routes and populating the locale in a cookie

x-ref: https://github.com/vercel/next.js/issues/17110
2020-10-07 21:11:01 +00:00
Jan Potoms
3ffef60280
Fix webdriver error handling (#15491)
errors in script execution will result in timeout instead of failure. This PR makes sure to pass all arguments to `.then` so error handling is correctly set up. (`.then` needs to be able to take a second argument). I also removed `.finally`.

I don't know why, but it looks like the following test does something that prevents the tests after it from opening a new browser window on azure. I'm giving up, I shuffled the tests to put this one last.
```js
    it('shows warning when dynamic route mismatch is used on Link', async () => {
      await showsError(
        '/dynamic-route-mismatch',
        /Mismatching `as` and `href` failed to manually provide the params: post in the `href`'s `query`/,
        true,
        true
      )
    })
```
2020-07-29 10:30:06 +00:00
Jan Potoms
2f50f1f8c9
Stabilize more tests (#15470)
jest retries seem to be masking test failures, like the `auto-export` one (and maybe others). I turned it off for now. The `auto-export` test fails when retries are turned off.
the output of this test failure was a bit unhelpful so I also improved it.
Many tests have anonymous page functions.
2020-07-26 04:57:06 +00:00
Tim Neutkens
e57b2091aa
Bring over fixes from #15185 (#15326)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-20 11:14:02 -04:00
Jan Potoms
54d991e642
fix basepath trailing slash (#15200)
Fixes the link rewriting part of https://github.com/vercel/next.js/issues/15194
2020-07-15 23:53:31 +00:00
Tim Neutkens
c5cc6072d0
Use single webpack runtimeChunk for Node.js compilation (#14722)
Webpack 5 supports a single runtimechunk for the Node.js compilation, this solves sharing modules between entrypoints.
2020-07-01 15:34:00 +00:00
Tim Neutkens
6c2ce70608
Remove buildId from server-side files (#14413)
Gets rid of the custom function for naming files by removing buildId from the file paths.
2020-06-22 21:12:36 +00:00
Tim Neutkens
bef9b56109
Update filename generation for client-side compilation (#14279)
Updates the way filenames are generated for browser compilation.
Notably:
- All entry bundles now have hashes in production, this includes pages (previously pages used a buildId in the path)
- The AmpFiles no longer depends on hardcoded bundle names, it uses the buildManifest instead (internals)
- All cases where we match the page name from the chunk/entrypoint name now use the same function `getRouteFromEntrypoint` (internals)
- In development we no longer include the "faked" `buildId` set to `development` for page files, instead we just use the `/_next/static/pages` path (was `/_next/static/development/pages`). This was changed as it caused unneeded complexity and makes generating the bundles easier (internals)
- Updated tons of tests to be more resilient to these changes by relying on the buildManifest instead of hardcoded paths (internals)

Follow up of these PRs:
https://github.com/vercel/next.js/pull/13759
https://github.com/vercel/next.js/pull/13870
https://github.com/vercel/next.js/pull/13937
https://github.com/vercel/next.js/pull/14130
https://github.com/vercel/next.js/pull/14176
https://github.com/vercel/next.js/pull/14268


Fixes #6303
Fixes #12087 
Fixes #1948
Fixes #4368
Fixes #4255
Fixes #2548
2020-06-20 19:59:47 +00:00
Joe Haddad
ec7c3252c3
tests: fail when cannot replace content (#14087)
Fixes #14085
2020-06-11 18:29:38 +00:00
Tim Neutkens
76fddcd7ef
Use chunkhash instead of buildId for pages (#13937)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-06-11 10:57:24 +02:00
JJ Kasper
b1025995b2
Update to reject when test command fails (#13722)
As noticed in https://github.com/vercel/next.js/pull/13506 when a build or export command fails the tests can just stall. This attempts to address that by rejecting when the command doesn't exit correctly and `stdout` and `stderr` aren't being looked at
2020-06-09 18:28:15 +00:00
Joe Haddad
9386ba29f8
Stabilize config tests (#13116) 2020-05-19 18:42:41 -04:00
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
Joe Haddad
450d4bd0f3
Experimental: React Refresh Support (#12008)
* Add Fast Refresh Support

* Add Basic Acceptance Test

* Increase delay

* fix version

* Ignore test files

* Update packages/next/build/webpack/loaders/next-babel-loader.js

* Copy tests

* Redo test style

* drop directory

* fix compile

* fix remove function

* Update helpers
2020-04-19 13:58:31 -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
a8b39889f3
Update legacy safari test for GitHub actions (#10618) 2020-02-20 15:39:57 -06:00
JJ Kasper
00855de60a
Add navigation test specific for Safari 10 (#10616)
* Add testing in Safari 10.1 on merge

* Add nav test specific for Safari 10
2020-02-20 13:35:28 -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
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