Commit graph

108 commits

Author SHA1 Message Date
htbvo
211c84e1c9 allow NextScript to optionally defer javascript (#8980)
* allow NextScript to optionally defer javascript

* move defer options to experimental feature

* combine defer flags into a single option

* Update deferScripts to work with serverless target

* Add test for defer and async property

* Read the async property

* Check versions of chrome and chromedriver

* Update to chromedriver 76

* Fix test
2019-10-26 19:27:22 +02:00
Joe Haddad
f81c5d5454
Match public/static/ folder before static/ (#8986)
* Test `public/static/` folder

* Public routes should be matched before static catch-all
2019-10-07 23:12:41 -04: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
JJ Kasper
4e9e51035e Match public files priority in dev (#8641)
* Match public files priority in dev

* Remove un-needed old public file handling

* Run public file priority test for non-dev also

* Make sure to enable publicDirectory

* Add checking for conflicting pages in dev and during build

* Add error for public dir middleware conflict

* Add err.sh for _next conflict

* Move up public dir conflict checking

* Only run _next conflict check in dev when path contains it
2019-09-16 23:06:30 +02:00
JJ Kasper
ed5dc2107f Add autoExport to __NEXT_DATA__ (#8746)
* Add autoExport to __NEXT_DATA__

* Update render variable
2019-09-15 20:35:14 +02:00
Tim Neutkens
2ba352da39 Move next-server back into next package (#8613)
* Initial move

* Make emitting work

* Update paths

* Remove leftover files

* Add correct externals configuration

* Import correct path

* Update path to work with ts-server test

* Update lib directory

* Compile next-server/lib
2019-09-04 10:00:54 -04:00
JJ Kasper
56501aeb82 Fix production test failing in ie11 (#8612) 2019-09-03 12:13:50 -04:00
Houssein Djirdeh
689b1319b6 Update performance marking (#8527)
* creates perf marks object constant

* updates clearmarks to only clear core marks

* adds test + fixes object constqnt reference

* hardcodes perf marks and removes constant

* adds test to check custom marks are not cleared
2019-08-30 22:40:05 -04:00
JJ Kasper
340594398e
Make sure to 404 for /_next/static (#8564) 2019-08-29 15:00:54 -05:00
Houssein Djirdeh
010059915d Add version property to Next.js instance (#8499)
* adds global for next version

* updates to use env variable and keeps it local

* Test Next.js version presence

* Unfocus test
2019-08-24 00:49:24 -04:00
William
ec95927e14 Fix dynamic APIs with query params (#8386)
* Fix dynamic APIs with query params

If you define a dynamic API such as

```
pages/
  api/
    [id].js
```

This api becomes available at `/api/[id]`. If you send a request with
a query parameter the value of `req.query.id` will include the query
string as well as the path parameter.

E.g. the request to `/api/2?test=123` will result in `req.query`
being

```javascript
{
  id: "2?test=123",
  test: "123",
}
```

instead of

```javascript
{
  id: "2",
  test: "123",
}
```

* Fix url parse in serverless loader

* Add serverless test
2019-08-19 13:19:39 -04:00
Tim Neutkens
46c4f20cd3
Add custom profiler / tracer (#8378)
* Add custom profiler / tracer

This captures both client/production builds and everything before and after is cpu profiled, which makes sure that the whole process instead of just webpack is included in the final report.

* Update tests

* Update profiling-plugin.js

* Rename profiling-plugin.js to profiling-plugin.ts

* Update profiling-plugin.ts

* Update and rename profiling-plugin.ts to profiling-plugin.js

* Update webpack-config.ts

* Update profiling-plugin.js

* Add types

* Add missing type

* Add back TypeScript linting

* Remove tracing-js
2019-08-18 21:45:39 +02:00
Natalie Marleny
06876f1be0 fix: Warn when user specifies prefetch option as true (#8233)
* Warn when user specifies prefetch option as `true`

* Update index.test.js
2019-08-12 00:26:25 -04:00
Lukáš Huvar
869bf0f16c Remove 405 from render method (#8323)
* Revert 405 on pages

* Modify tests
2019-08-11 15:42:40 +02:00
Alex Castle
3e8b36e879 Experimental: Granular build chunking (#7696)
* Refactor SplitChunksPlugin configs and add experimental chunking strategy

* Use typeDefs for SplitChunksConfig

* Modify build manifest plugin to create runtime build manifest

* Add support for granular chunks to page-loader

* Ensure normal behavior if experimental granularChunks flag is false

* Update client build manifest to remove iife & implicit global

* Factor out '/_next/' prepending into getDependencies

* Update packages/next/build/webpack-config.ts filepath regex

Co-Authored-By: Jason Miller <developit@users.noreply.github.com>

* Simplify dependency load ordering in page-loader.js

* Use SHA1 hash to shorten filenames for dependency modules

* Add scheduler to framework cacheGroup in webpack-config

* Update page loader to not duplicate script tags with query parameters

* Ensure no slashes end up in the file hashes

* Add prop-types to framework chunk

* Fix issue with mis-attributed events

* Increase modern build size budget--possibly decrement after consulting with @janicklasralph

* Use module.rawRequest for lib chunks

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Dasherize lib chunk names

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Fix typescript errors, reorganize lib name logic

* Dasherize rawRequest, short circuit name logic when rawRequest found

* Add `scheduler` package to test regex

* Fix a nit

* Adjust build manifest plugin

* Shorten key name

* Extract createPreloadLink helper

* Extract getDependencies helper

* Move method

* Minimize diff

* Minimize diff x2

* Fix Array.from polyfill

* Simplify page loader code

* Remove async=false for script tags

* Code golf `getDependencies` implementation

* Require lib chunks be in node_modules

* Update packages/next/build/webpack-config.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Replace remaining missed windows compat regex

* Trim client manifest

* Prevent duplicate link preload tags

* Revert size test changes

* Squash manifest size even further

* Add comment for clarity

* Code golfing 🏌️‍♂️

* Correctly select modern dependencies

* Ship separate modern client manifest when module/module enabled

* Update packages/next/build/webpack/plugins/build-manifest-plugin.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove unneccessary filter from page-loader

* Add lookbehind to file extension regex in page-loader

* v9.0.3

* Update examples for Apollo with AppTree (#8180)

* Update examples for Apollo with AppTree

* Fix apolloClient being overwritten when rendering AppTree

* Golf page-loader (#8190)

* Remove lookbehind for module replacement

* Wait for build manifest promise before page load or prefetch

* Updating modern-only chunks inside the right entry point

* Fixing ts errors

* Rename variable

* Revert "Wait for build manifest promise before page load or prefetch"

This reverts commit c370528c6888ba7fa71162a0854534ed280224ef.

* Use proper typedef for webpack chunk

* Re-enable promisified client build manifest

* Fix bug in getDependencies map

* Insert check for granularChunks in page-loader

* Increase size limit temporarily for granular chunks

* Add 50ms delay to flaky test

* Set env.__NEXT_GRANULAR_CHUNKS in webpack config

* Reset size limit to 187

* Set process.env.__NEXT_GRANULAR_CHUNKS to false if selectivePageBuilding

* Update test/integration/production/test/index.test.js

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Do not create promise if not using chunking PR
2019-08-08 13:14:33 -04:00
JJ Kasper
6ddb5ee341 Update to check browserName instead of browser.log (#8234)
* Update to check browserName instead of browser.log

* Fix browserName check for some tests
2019-08-04 15:44:32 +02:00
Joe Haddad
2ab300dd81
Remove Old Prerender Implementation (#8218)
* Remove Prerender Implementation

* Fix PageConfig

* Fix next server

* Fix two more files

* Fix render

* Fix render

* Try to fix up page config

* Correct build file

* Switch back static checker

* Turn stuff back

* Add missing newline

* Revert changes

* Add missing newline

* Fix types
2019-08-02 10:28:03 -04:00
Janicklas Ralph
f4e6149d1c Experimental module/nomodule support (#7704)
* Module/nomodule implementation based on RFC 7563

* Remove comment

* Fixing issue with building amp pages

* Fixing test cases for serverless mode

* Adding safari 10 nomodule fix. Preloading modern js by default

* Fixing size-limit integration test

* Bug fix

* Adding testcase for modern build

* Trigger rebuild

* Setting default crossOrigin value

* Moving modern config option inside experimental flag

* Adding nomodule attribute to safari-fix script

* Changing safari10NomoduleFix default value to true

* Removing safari-fix flag

* Changing .es6 to .module

* Disable modern default

* Removing default crossOrigin value. Setting modern flag to false by default. Fixed test cases

* Remove confusing defaults and mark required instead

* Adjust blacklist

* Move behavior of page marking

* Fixing childCompiler errors not being captured

* Tweak names

* Revert

* whoops

* Fixing bug with page-loader.js

* Changing modern babel cache name

* Rename helper

* Iterate over both bundles

* Correctly clamp bundle sizes

* Revert test

* Add modern mode tests

* Fix test

* test

* test2
2019-07-24 22:16:32 -04:00
JJ Kasper
1cbb5958ec Fix syntax error in ie11 from next-server/amp (#8032) 2019-07-18 22:09:41 -04:00
Joe Haddad
f43ae7363e
Adjust test names for send (#7996)
* Adjust test names for `serve`

* Clarify names more
2019-07-16 07:40:02 -07:00
Adam Misiorny
90280c864b Add support for 412 Precondition Failed status for static files (#7944)
* Add support for Precondition Failed status for static files

* Add test

* Trigger tests

* Update next-server.ts
2019-07-16 13:30:29 +02:00
JJ Kasper
bf7af1d16b Add default values for runtime config (#7847)
* Add default values for runtime config

* Add test to ensure default values are set
for runtime config

* Only add runtimeConfig if it's not empty

* Only add runtimeConfig if it's not empty

* Simplify default value adding

* Reduce bundle size

* remove comment changes

* Fix typos

* Add test for runtimeConfig in __NEXT_DATA__
2019-07-10 10:43:04 -04:00
Joe Haddad
b0b1c320a8 Experimentalize public/ (#7771)
* Experimentalize `public/`

* Update tests for publicDirectory config
2019-07-08 07:45:41 +02:00
Joe Haddad
b60985b2be
Revert "fix(Link): Set focus back to the body element (#7693)" (#7753)
This reverts commit defde85e81.
2019-07-04 23:24:14 -04:00
Connor Bär
defde85e81 fix(Link): Set focus back to the body element (#7693)
* fix(Link): Set focus back to the body element

* refactor(Link): Fix typings

* Update blurring logic and add tests
2019-07-04 11:30:22 -04:00
Lukáš Huvar
87acbdb594
Http methods update for static files and pages (#7721)
* Change static method handling and pages revert

* Allow and reflect old behaviour

* Post should return 501

* Add back old test

* Invert logic

* Handle 501 for pages in separate location

* Remove usage of 501 HTTP status code

* Prevent information leak

* Add test

* Only 405 if the page exists -- 404 if it doesn't

* Handle sent responses

* Revert "Handle sent responses"

This reverts commit 5e9012ae29b611c25ed1e090756a25dbe3437182.

* Fix bad test

* Switch back to quiet

* Update test/integration/production/test/index.test.js

Co-Authored-By: JJ Kasper <jj@jjsweb.site>
2019-07-04 10:22:25 +02:00
Joe Haddad
7439a773b0 Nit: Change Pre-render to Prerender (#7733) 2019-07-02 22:51:12 +02:00
JJ Kasper
0ca8087565
Add prerender PageConfig option (#7699)
* Add prerender PageConfig option

* Update PageConfig type

* Add inlining of data when pre-render is set and add tests

* Update types import

* Add check for props

* Rename prerender to experimentalPrerender for now
2019-07-01 14:13:52 -07:00
Joe Haddad
3aed76fad8
Unflag Automatic Prerendering (#7666)
* Unflag Dynamic Routing

* Unflag Automatic Prerendering

* Ensure pages are lambdas for test

* Fix file check

* Fix tests

* oof

* Use lambda for document middleware test
2019-06-28 16:01:11 -04:00
JJ Kasper
291eb83923 Revert "Remove modules option from dynamic (#7688)" (#7701)
This reverts commit 0fd7e68556.
2019-06-28 13:39:23 -04:00
JJ Kasper
0fd7e68556 Remove modules option from dynamic (#7688)
* Remove modules option from dynamic

* Remove old test
2019-06-28 09:02:33 -04: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
Lukáš Huvar
b5e3aac1ec Fix POST and PUT on api routes (#7319)
* Fix POST and PUT

* Fix condition for request and test
2019-05-13 15:40:23 +02:00
Tim Neutkens
75ba3db256
Make sure API routes are built in production (#7306)
* Make sure API routes is built correctly

* Don’t create client-side bundle for API routes

* Add tests for production
2019-05-11 15:32:38 +02:00
Luis Fernando Alvarez D
74771bc5e4
Add support for /public (#7213) 2019-05-03 11:57:47 -05:00
JJ Kasper
84afda6bd1
Update cache-control header when no getInitialProps (#7185) 2019-04-28 13:28:59 -05:00
Tim Neutkens
1a53ca7474
Add x-powered-by (#7029)
* Add x-powered-by

* Remove ampEnabled type
2019-04-15 16:48:14 +09:00
JJ Kasper
5421274c87
Fix re-rendering on client after navigating back from external (#6652)
* Fix re-rendering on client after navigating
back from external site

* Clean up tagging before unload

* Add check for history.state 1/2

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Add check for history.state 2/2

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Add check for options

Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>

* Add test for navigating to external site and back
also added testing in safari and firefox

* Add test for query in url
2019-04-09 16:58:44 -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
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
dbd41725ce Removed the X-Powered-By header (#6789)
Related to #6776
2019-03-26 12:32:01 +01:00
Joe Haddad
31f6f4c606
Ensure browser gets closed during testing (#6724)
* Ensure browser gets closed during testing

* Remove fit
2019-03-19 18:03:50 -04:00
Joe Haddad
8dd7185112
Check for the user's home directory in the build output (#6661)
* Check for the user's home directory in the build output

* Output files on windows for debugging

* add process cwd

* try more paths

* Add branch for winblows

* Print info on error

* set proper env

* try fix
2019-03-15 00:07:59 -04:00
JJ Kasper
e2944c0aca
Fix loading showing before pastDelay (#6628) 2019-03-12 14:12:49 -05:00
JJ Kasper
41278a62f2
Remove _error page from blocked pages (#6579) 2019-03-08 13:00:09 -06:00
k-kawakami
d9060f5abd Remove trailing spaces (#6547)
### changes
#### remove trailing spaces

When I was using example I noticed trailing spaces.
So, this PR removes the trailing spaces of json file, README, and others.

`examples/with-jest-typescript/src/modules/cars/Overview.tsx` also has it, but this time it did not change as tslint error occurs at commit.
2019-03-07 17:40:08 +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