-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MSW usage example #13731
Add MSW usage example #13731
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 10.8s | 10.9s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.004 | 1.915 | -0.09 |
/ avg req/sec | 1247.78 | 1305.38 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.27 | 1.24 | -0.03 |
/error-in-render avg req/sec | 1968.97 | 2016.64 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 924 B | 924 B | ✓ |
link.html gzip | 934 B | 934 B | ✓ |
withRouter.html gzip | 922 B | 922 B | ✓ |
Overall change | 2.78 kB | 2.78 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 11.8s | 11.9s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 879 kB | 879 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
Updated It appears that MSW should implement an alternative await mechanism.
|
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 12.3s | 12s | -331ms |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.009 | 2.018 | |
/ avg req/sec | 1244.32 | 1239.02 | -5.3 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.179 | 1.105 | -0.07 |
/error-in-render avg req/sec | 2119.94 | 2261.99 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 924 B | 924 B | ✓ |
link.html gzip | 934 B | 934 B | ✓ |
withRouter.html gzip | 922 B | 922 B | ✓ |
Overall change | 2.78 kB | 2.78 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 12.8s | 12.8s | -47ms |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 879 kB | 879 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.788 | 1.822 | |
/ avg req/sec | 1398.02 | 1371.95 | -26.07 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.015 | 1.017 | 0 |
/error-in-render avg req/sec | 2463.3 | 2458.35 | -4.95 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 924 B | 924 B | ✓ |
link.html gzip | 934 B | 934 B | ✓ |
withRouter.html gzip | 922 B | 922 B | ✓ |
Overall change | 2.78 kB | 2.78 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 11.6s | 11.9s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 879 kB | 879 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.793 | 1.958 | |
/ avg req/sec | 1394.54 | 1276.89 | -117.65 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.106 | 1.207 | |
/error-in-render avg req/sec | 2260.64 | 2070.57 | -190.07 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 924 B | 924 B | ✓ |
link.html gzip | 934 B | 934 B | ✓ |
withRouter.html gzip | 922 B | 922 B | ✓ |
Overall change | 2.78 kB | 2.78 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 11.8s | 12s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.67 kB | 5.67 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 879 kB | 879 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
Having a linting (Prettier) errors. Edit: The Prettier check was fixed, I've formatted the worker file with Prettier, shouldn't be an issue. |
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 12.1s | 12.4s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.092 | 2.05 | -0.04 |
/ avg req/sec | 1195.04 | 1219.24 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.296 | 1.223 | -0.07 |
/error-in-render avg req/sec | 1928.91 | 2043.66 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.61 kB | 6.61 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.69 kB | 5.69 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 925 B | 925 B | ✓ |
link.html gzip | 935 B | 935 B | ✓ |
withRouter.html gzip | 923 B | 923 B | ✓ |
Overall change | 2.78 kB | 2.78 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 13.2s | 13.2s | |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.61 kB | 6.61 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..6c2a.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.69 kB | 5.69 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.93 kB | 6.93 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 878 kB | 878 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
I'm not including a deployment link, because MSW is not meant for production usage, making this example oriented at development experience. Developers should use actual servers in production. |
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 11.8s | 11.6s | -234ms |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.085 | 2.13 | |
/ avg req/sec | 1198.88 | 1173.89 | -24.99 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.36 | 1.295 | -0.07 |
/error-in-render avg req/sec | 1838.46 | 1930.02 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.61 kB | 6.61 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..9545.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.69 kB | 5.69 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.92 kB | 6.92 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 927 B | 927 B | ✓ |
link.html gzip | 936 B | 936 B | ✓ |
withRouter.html gzip | 924 B | 924 B | ✓ |
Overall change | 2.79 kB | 2.79 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 13.2s | 12.8s | -331ms |
nodeModulesSize | 66 MB | 66 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.js gzip | 6.61 kB | 6.61 kB | ✓ |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..9545.js gzip | 10.5 kB | 10.5 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57 kB | 57 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.69 kB | 5.69 kB | ✓ |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 6.92 kB | 6.92 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 52.5 kB | 52.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.3 kB | 26.3 kB | ✓ |
Overall change | 26.3 kB | 26.3 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error.js gzip | 3.25 kB | 3.25 kB | ✓ |
hooks.js gzip | 881 B | 881 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 2.05 kB | 2.05 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 8.21 kB | 8.21 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app.module.js gzip | 604 B | 604 B | ✓ |
_error.module.js gzip | 2.04 kB | 2.04 kB | ✓ |
hooks.module.js gzip | 383 B | 383 B | ✓ |
index.module.js gzip | 223 B | 223 B | ✓ |
link.module.js gzip | 1.51 kB | 1.51 kB | ✓ |
routerDirect..dule.js gzip | 281 B | 281 B | ✓ |
withRouter.m..dule.js gzip | 278 B | 278 B | ✓ |
Overall change | 5.32 kB | 5.32 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 878 kB | 878 kB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.81 kB | 3.81 kB | ✓ |
index.js | 878 kB | 878 kB | ✓ |
link.js | 916 kB | 916 kB | ✓ |
routerDirect.js | 909 kB | 909 kB | ✓ |
withRouter.js | 909 kB | 909 kB | ✓ |
Overall change | 4.5 MB | 4.5 MB | ✓ |
I'd appreciate any insights in regards to how debug that fast refresh issue! It appears that |
During the Fast Refresh the hot module bubbles to the What I still don't fully understand is why the request logging logic also triggers multiple times. It is as if the previous state of the chunk is left alone, and the new chunk is applied on top of it. I wonder if this should be solved by providing a hot reload mechanism on the |
Any progress on this? When do we expect it to be merged? |
Hey, @dpyzo0o. The NextJS-related implementation shouldn't change at this point. You can use this pull request as a working reference. There is an issue on the MSW side (mswjs/msw#217) that results into multiple log entries after Fast Refresh (described above). We are working on fixing it, and bumping the |
@kettanaito Thanks, nice job! |
Hi @kettanaito thanks for making this possible I have successfully implemented this in my NextJs app but was wondering how you would go about starting / stopping the mws server for server side calls (like I'd like to be able to tell the app whether or not I want the mocking to happen on the server side) I know the mws server is started when the app is started (next dev) but was wonderig if it was possible to control this after it's started for instance from a cypress test suite maybe I'm looking at this the wrong way hope you can help |
Hey, @thomasmery. Could you please give me an example of such use case? You can always have a conditional mocking in your request handlers, which you can hit during your Cypress tests: rest.get('/user', (req, res, ctx) => {
if (ANY_CONDITION) {
// Returning nothing skips this request handler, and performs the request as-is
return
}
// Return a mocked response otherwise
return res(...)
}) We encourage embedding such conditional behavior into the mocks, so your routes are predictable and easier to reason about, as opposed to turning the entire mocking on/off in specific tests, which may get confusing when debugging, or reading. |
Hi @kettanaito thanks for you reply, the use case is that I usually have an api server running when developing and want to use MSW only when testing I can do this easily with jest and the node setup by starting the msw server in the beforeAll hook I wanted to do the same with Cypress but if I launch my nextjs app with msw started then this is not only for Cypress but for all manual interactions with the app too it feels like modifying every handler to bypass it if I'm not using Cypress could be cumbersome (and how would I tell the handler I'm running Cypress (I know i can check for window.Cypress in the client code but on the server ... ?) but maybe I'm confused and missing something obvious |
MSW is started conditionally in both client and server side of NextJS runtime. Take a look at |
This is an alternative to: vercel/next.js#13731 I prefer this solution because I can use ES6 modules everywhere so I can share constants, types, etc. between implementation and test
thanks I have come up with a solution like this: const useMocks =
process.env.USE_MOCKS === 'true' &&
[PHASE_DEVELOPMENT_SERVER].includes(phase) &&
process.env.NODE_ENV === 'development';
if (useMocks) {
// Enable API mocking when serving our application in development mode.
// This allows to any traffic issued by `getServerSideProps` and similar
// to go through the request interception, and potentially being mocked.
server.listen();
} which allows to start the server in mock mode only if I want to
|
on another matter, and maybe the nextjs team can help here it seems not possible to use code from a Typescript project inside the handlers since the whole msw setup for the server side of things takes place in the I have read this thread : #5318 which seems related to this the use case I had was trying to import some config related variables from some other part of my app to configure the handlers request urls (for dev & staging environments) I solved this by using regexp path matching but I thought I would ask here since maybe I did not understand things right and it is possible to import from a ts code base inside those js files I know you say:
but I fail to understand this (unless I turn the but I'm probably confused, feel free to ignore this it is way off base thanks anyhow |
@thomasmery Next.js will not transpile/transform any code that's in @kettanaito Ping me when the example is ready for review as I would like to review it 🙏 |
We've successfully resolved the Fast Refresh issue on browser runtime 🎉 We are experiencing another issue regarding server-side API mocking (with Server-side updatesThe server-side API interception is established in the Technical reasonIt appears that NextJS executes However, how should we deal with the server-side requests interception so it supports changes to the request handlers? It feels like there should be some @lfades, may I please ask for your domain knowledge in this? It seems like |
@kettanaito Next.js currently doesn't watch for changes made to |
Thanks for the reply, @lfades! The issue here is that That module controls what requests get mocked on the server-side of Next (i.e. Please, what would you recommend for this case? Is there another place to import |
@kettanaito I see. I think I get it now after reading this: https://mswjs.io/docs/api/setup-server.
|
@lfades, thanks for the recommendation. Indeed, when I moved the server-side handlers invocation into This example is complete from the MSW point of view. Could you please give it a look? Thank you.
|
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 11.1s | 11.4s | |
nodeModulesSize | 57.2 MB | 57.2 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.062 | 2.058 | 0 |
/ avg req/sec | 1212.43 | 1215.04 | +2.61 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.141 | 1.089 | -0.05 |
/error-in-render avg req/sec | 2191.72 | 2294.75 | +103.03 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..6aa6.js gzip | 10 kB | 10 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-9a7a5f4..661e.js gzip | 6.71 kB | 6.71 kB | ✓ |
polyfills-75..1629.js gzip | 31 kB | 31 kB | ✓ |
webpack-ccf5..276a.js gzip | 751 B | 751 B | ✓ |
Overall change | 87.7 kB | 87.7 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 5.92 kB | 5.92 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-d0ac695..dule.js gzip | 5.79 kB | 5.79 kB | ✓ |
polyfills-75..dule.js gzip | 31 kB | 31 kB | ✓ |
webpack-10c7..dule.js gzip | 751 B | 751 B | ✓ |
Overall change | 82.6 kB | 82.6 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-874bd8a..0103.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fa39c..ec40.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-585f07..95a3.js gzip | 887 B | 887 B | ✓ |
index-c7b63f..fc02.js gzip | 227 B | 227 B | ✓ |
link-4c2bd9b..eadd.js gzip | 1.29 kB | 1.29 kB | ✓ |
routerDirect..ebc7.js gzip | 284 B | 284 B | ✓ |
withRouter-2..db68.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.71 kB | 7.71 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-97e743e..dule.js gzip | 626 B | 626 B | ✓ |
_error-b4004..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-696209..dule.js gzip | 387 B | 387 B | ✓ |
index-a4dd74..dule.js gzip | 226 B | 226 B | ✓ |
link-236a801..dule.js gzip | 1.26 kB | 1.26 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-1..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.37 kB | 5.37 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 273 B | 273 B | ✓ |
_buildManife..dule.js gzip | 279 B | 279 B | ✓ |
Overall change | 552 B | 552 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 945 B | 945 B | ✓ |
link.html gzip | 954 B | 954 B | ✓ |
withRouter.html gzip | 939 B | 939 B | ✓ |
Overall change | 2.84 kB | 2.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 13s | 12.7s | -333ms |
nodeModulesSize | 57.2 MB | 57.2 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..6aa6.js gzip | 10 kB | 10 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-9a7a5f4..661e.js gzip | 6.71 kB | 6.71 kB | ✓ |
polyfills-75..1629.js gzip | 31 kB | 31 kB | ✓ |
webpack-ccf5..276a.js gzip | 751 B | 751 B | ✓ |
Overall change | 87.7 kB | 87.7 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 5.92 kB | 5.92 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-d0ac695..dule.js gzip | 5.79 kB | 5.79 kB | ✓ |
polyfills-75..dule.js gzip | 31 kB | 31 kB | ✓ |
webpack-10c7..dule.js gzip | 751 B | 751 B | ✓ |
Overall change | 82.6 kB | 82.6 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-874bd8a..0103.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fa39c..ec40.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-585f07..95a3.js gzip | 887 B | 887 B | ✓ |
index-c7b63f..fc02.js gzip | 227 B | 227 B | ✓ |
link-4c2bd9b..eadd.js gzip | 1.29 kB | 1.29 kB | ✓ |
routerDirect..ebc7.js gzip | 284 B | 284 B | ✓ |
withRouter-2..db68.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.71 kB | 7.71 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-97e743e..dule.js gzip | 626 B | 626 B | ✓ |
_error-b4004..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-696209..dule.js gzip | 387 B | 387 B | ✓ |
index-a4dd74..dule.js gzip | 226 B | 226 B | ✓ |
link-236a801..dule.js gzip | 1.26 kB | 1.26 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-1..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.37 kB | 5.37 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 273 B | 273 B | ✓ |
_buildManife..dule.js gzip | 279 B | 279 B | ✓ |
Overall change | 552 B | 552 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 1.03 MB | 1.03 MB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.82 kB | 3.82 kB | ✓ |
index.js | 1.03 MB | 1.03 MB | ✓ |
link.js | 1.07 MB | 1.07 MB | ✓ |
routerDirect.js | 1.06 MB | 1.06 MB | ✓ |
withRouter.js | 1.06 MB | 1.06 MB | ✓ |
Overall change | 5.26 MB | 5.26 MB | ✓ |
Please do YES THANK YOU! 💌 I will review the PR very soon |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.405 | 2.42 | |
/ avg req/sec | 1039.66 | 1032.87 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.453 | 1.449 | 0 |
/error-in-render avg req/sec | 1720.33 | 1725.64 | +5.31 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..c139.js gzip | 10.2 kB | 10.2 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-b57f5ce..0446.js gzip | 6.74 kB | 6.74 kB | ✓ |
polyfills-75..1629.js gzip | 31 kB | 31 kB | ✓ |
webpack-ccf5..276a.js gzip | 751 B | 751 B | ✓ |
Overall change | 87.9 kB | 87.9 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 6.12 kB | 6.12 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-65b0875..dule.js gzip | 5.82 kB | 5.82 kB | ✓ |
polyfills-75..dule.js gzip | 31 kB | 31 kB | ✓ |
webpack-10c7..dule.js gzip | 751 B | 751 B | ✓ |
Overall change | 82.9 kB | 82.9 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-874bd8a..0103.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fa39c..ec40.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-585f07..95a3.js gzip | 887 B | 887 B | ✓ |
index-c7b63f..fc02.js gzip | 227 B | 227 B | ✓ |
link-4c2bd9b..eadd.js gzip | 1.29 kB | 1.29 kB | ✓ |
routerDirect..ebc7.js gzip | 284 B | 284 B | ✓ |
withRouter-2..db68.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.71 kB | 7.71 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-97e743e..dule.js gzip | 626 B | 626 B | ✓ |
_error-b4004..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-696209..dule.js gzip | 387 B | 387 B | ✓ |
index-a4dd74..dule.js gzip | 226 B | 226 B | ✓ |
link-236a801..dule.js gzip | 1.26 kB | 1.26 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-1..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.37 kB | 5.37 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
_buildManife..dule.js gzip | 329 B | 329 B | ✓ |
Overall change | 650 B | 650 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
index.html gzip | 946 B | 946 B | ✓ |
link.html gzip | 954 B | 954 B | ✓ |
withRouter.html gzip | 940 B | 940 B | ✓ |
Overall change | 2.84 kB | 2.84 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
buildDuration | 14.8s | 14.6s | -185ms |
nodeModulesSize | 57.3 MB | 57.3 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..c139.js gzip | 10.2 kB | 10.2 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-b57f5ce..0446.js gzip | 6.74 kB | 6.74 kB | ✓ |
polyfills-75..1629.js gzip | 31 kB | 31 kB | ✓ |
webpack-ccf5..276a.js gzip | 751 B | 751 B | ✓ |
Overall change | 87.9 kB | 87.9 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 6.12 kB | 6.12 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-65b0875..dule.js gzip | 5.82 kB | 5.82 kB | ✓ |
polyfills-75..dule.js gzip | 31 kB | 31 kB | ✓ |
webpack-10c7..dule.js gzip | 751 B | 751 B | ✓ |
Overall change | 82.9 kB | 82.9 kB | ✓ |
Client Pages
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-874bd8a..0103.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-fa39c..ec40.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-585f07..95a3.js gzip | 887 B | 887 B | ✓ |
index-c7b63f..fc02.js gzip | 227 B | 227 B | ✓ |
link-4c2bd9b..eadd.js gzip | 1.29 kB | 1.29 kB | ✓ |
routerDirect..ebc7.js gzip | 284 B | 284 B | ✓ |
withRouter-2..db68.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.71 kB | 7.71 kB | ✓ |
Client Pages Modern
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_app-97e743e..dule.js gzip | 626 B | 626 B | ✓ |
_error-b4004..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-696209..dule.js gzip | 387 B | 387 B | ✓ |
index-a4dd74..dule.js gzip | 226 B | 226 B | ✓ |
link-236a801..dule.js gzip | 1.26 kB | 1.26 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-1..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.37 kB | 5.37 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
_buildManife..dule.js gzip | 329 B | 329 B | ✓ |
Overall change | 650 B | 650 B | ✓ |
Serverless bundles
vercel/next.js canary | kettanaito/next.js examples/with-msw | Change | |
---|---|---|---|
_error.js | 1.03 MB | 1.03 MB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.82 kB | 3.82 kB | ✓ |
index.js | 1.03 MB | 1.03 MB | ✓ |
link.js | 1.07 MB | 1.07 MB | ✓ |
routerDirect.js | 1.06 MB | 1.06 MB | ✓ |
withRouter.js | 1.06 MB | 1.06 MB | ✓ |
Overall change | 5.26 MB | 5.26 MB | ✓ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kettanaito Thank you for the example I like it a lot! 💯
I have updated the readme to add a deploy button, and also the environment variable to make sure it works on production for the example (so the deploy button, yarn start and yarn build work) - because there's no API when the mocks are disabled. But of course mentioning that it's intentional only for the sake of the example.
Good work 👏
@lfades thank you looking at this and for the corrections! The changes are done from my side, with the only DX drawback is that changes in I believe there is no mechanism to tackle this on NextJS side at the moment. If you find this behavior acceptable, please feel free to merge this pull request! I'd love to finally reference it in the docs :) |
* Add MSW usage example * Updated example * Added .gitignore * Added .gitignore in the right place lol Co-authored-by: Luis Alvarez <luis@vercel.com>
Summary
This example illustrates how to use the Mock Service Worker (MSW) library with Next.
It allows users to kick off a full-scale project with any API mocking strategy they choose: augment an existing API, or design an expected API directly on the client side. MSW grants seamless requests interception at both client- and server-side, so the mock definition users write affect runtime requests and build-time requests, making the DX superb.
I believe that in combination with Next this is a great starting point for any project:
Implementation
Adds
public/mockServiceWorker.js
file, which is auto-generated bynpx msw init ./public
.Client-side
MSW intercepts request on the client side by using Service Worker API. That allows it to capture requests after they leave your app, on the network level. This is the closest experience to speaking with an actual server, without having to have one.
MSW uses the established Service Worker instance for the purpose of requests interception, but executes the mocking logic on the application's side. This allows users to integrate their app's logic into mocks, reuse functionality, and write mock definition as a part of their project (i.e. using TypeScript, or RxJS).
Server-side
Since there is no Service Worker in Node, MSW provides transparent requests interception by augmenting native request issuing modules (
http
/https
/XMLHttpRequest
). A cherry on top is that the mocking on the server can use the same mock definition as on the client.Screenshots
The usage example is a single book detail page. It fetches main book information as a part of
getServerSideProps
, and can query for book reviews on runtime.Roadmap
worker.start()
is called during fast reload rebuild.