Skip to content
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

Fix for __dirname #8334

Closed
wants to merge 18 commits into from
Closed

Fix for __dirname #8334

wants to merge 18 commits into from

Conversation

huv1k
Copy link
Contributor

@huv1k huv1k commented Aug 12, 2019

This PR fix problem with __dirname, where __dirname is / instead of the actual working directory. This changes __dirname to the relative path to the source file. This simulates actual behavior of __dirname.

Fixes #8251

packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
@ijjk
Copy link
Member

ijjk commented Aug 12, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 21.2s 21s -220ms
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Base Rendered Size 2.76 kB 2.76 kB
Build Dir Size 1.41 MB 1.41 MB ⚠️ +427 B
Click to expand serverless stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 22.2s 23s ⚠️ +859ms
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB -1 B
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 300 B -1 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Serverless pages/link Size 255 kB 255 kB ⚠️ +55 B
Serverless pages/link gzip Size 68.9 kB 68.9 kB ⚠️ +22 B
Serverless pages/index Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/index gzip Size 66.6 kB 66.7 kB ⚠️ +21 B
Serverless pages/_error Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/_error gzip Size 66.3 kB 66.3 kB ⚠️ +22 B
Serverless pages/routerDirect Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/routerDirect gzip Size 66.6 kB 66.6 kB ⚠️ +23 B
Serverless pages/withRouter Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/withRouter gzip Size 66.6 kB 66.7 kB ⚠️ +20 B
Build Dir Size 2.61 MB 2.61 MB ⚠️ +275 B

@ijjk
Copy link
Member

ijjk commented Aug 12, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 24.4s 23.5s -805ms
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Base Rendered Size 2.76 kB 2.76 kB
Build Dir Size 1.41 MB 1.41 MB ⚠️ +427 B
Click to expand serverless stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 25.6s 26.9s ⚠️ +1.3s
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Serverless pages/link Size 255 kB 255 kB ⚠️ +55 B
Serverless pages/link gzip Size 68.9 kB 68.9 kB ⚠️ +20 B
Serverless pages/index Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/index gzip Size 66.6 kB 66.7 kB ⚠️ +20 B
Serverless pages/_error Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/_error gzip Size 66.3 kB 66.3 kB ⚠️ +20 B
Serverless pages/routerDirect Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/routerDirect gzip Size 66.6 kB 66.6 kB ⚠️ +20 B
Serverless pages/withRouter Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/withRouter gzip Size 66.6 kB 66.7 kB ⚠️ +17 B
Build Dir Size 2.61 MB 2.61 MB ⚠️ +275 B

@ijjk
Copy link
Member

ijjk commented Aug 12, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 22.9s 22.3s -542ms
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Base Rendered Size 2.76 kB 2.76 kB
Build Dir Size 1.41 MB 1.41 MB ⚠️ +427 B
Click to expand serverless stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 25.1s 26.9s ⚠️ +1.8s
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Serverless pages/link Size 255 kB 255 kB ⚠️ +55 B
Serverless pages/link gzip Size 68.9 kB 68.9 kB ⚠️ +19 B
Serverless pages/index Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/index gzip Size 66.6 kB 66.7 kB ⚠️ +18 B
Serverless pages/_error Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/_error gzip Size 66.3 kB 66.3 kB ⚠️ +18 B
Serverless pages/routerDirect Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/routerDirect gzip Size 66.6 kB 66.6 kB ⚠️ +19 B
Serverless pages/withRouter Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/withRouter gzip Size 66.6 kB 66.7 kB ⚠️ +18 B
Build Dir Size 2.61 MB 2.61 MB ⚠️ +275 B

@ijjk
Copy link
Member

ijjk commented Aug 12, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 22.6s 22.9s ⚠️ +273ms
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Base Rendered Size 2.76 kB 2.76 kB
Build Dir Size 1.41 MB 1.41 MB ⚠️ +427 B
Click to expand serverless stats
zeit/next.js canary huv1k/next.js dirname-fix Change
Build Duration 24.3s 25.5s ⚠️ +1.2s
node_modules Size 41.6 MB 43 MB ⚠️ +1.38 MB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 69.3 kB 69.3 kB
Total Bundle (main, webpack, commons) Modern Size 187 kB 187 kB
Total Bundle (main, webpack, commons) Modern gzip Size 61.6 kB 61.6 kB
Client _app Size 1.9 kB 1.9 kB
Client _app gzip Size 913 B 913 B
Client _app Modern Size 1.79 kB 1.79 kB
Client _app gzip Modern Size 880 B 880 B
Client _error Size 8.02 kB 8.02 kB
Client _error gzip Size 3.13 kB 3.13 kB
Client _error Modern Size 5.82 kB 5.82 kB
Client _error gzip Modern Size 2.35 kB 2.35 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.07 kB 4.07 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.78 kB 3.78 kB
Client pages/link gzip Modern Size 1.72 kB 1.72 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 13.8 kB 13.8 kB
Client main gzip Size 4.88 kB 4.88 kB
Client main Modern Size 11.4 kB 11.4 kB
Client main Modern gzip Size 4.32 kB 4.32 kB
Client commons Size 194 kB 194 kB
Client commons gzip Size 63.3 kB 63.3 kB
Client commons Modern Size 175 kB 175 kB
Client commons Modern gzip Size 57.3 kB 57.3 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Serverless pages/link Size 255 kB 255 kB ⚠️ +55 B
Serverless pages/link gzip Size 68.9 kB 68.9 kB ⚠️ +19 B
Serverless pages/index Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/index gzip Size 66.6 kB 66.7 kB ⚠️ +18 B
Serverless pages/_error Size 247 kB 247 kB ⚠️ +55 B
Serverless pages/_error gzip Size 66.3 kB 66.3 kB ⚠️ +19 B
Serverless pages/routerDirect Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/routerDirect gzip Size 66.6 kB 66.6 kB ⚠️ +20 B
Serverless pages/withRouter Size 248 kB 248 kB ⚠️ +55 B
Serverless pages/withRouter gzip Size 66.6 kB 66.7 kB ⚠️ +19 B
Build Dir Size 2.61 MB 2.61 MB ⚠️ +275 B

@ijjk
Copy link
Member

ijjk commented Aug 16, 2019

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 25.7s 24.8s -903ms
nodeModulesSize 41.3 MB 42.6 MB ⚠️ +1.38 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.9 kB 17.9 kB
main-HASH.js gzip 6.56 kB 6.56 kB
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB
commons.HASH.js gzip 61.6 kB 61.6 kB
Overall change
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.2 kB 16.2 kB
main-HASH.module.js gzip 6.28 kB 6.27 kB -1 B
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB
commons.HASH.module.js gzip 55.4 kB 55.4 kB
Overall change
Client Pages
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.9 kB 1.9 kB
_app.js gzip 905 B 905 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 600 B 601 B ⚠️ +1 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB -1 B
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 290 B 289 B -1 B
Overall change
Client Pages Modern
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.79 kB 1.79 kB
_app.module.js gzip 865 B 865 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change
Fetched pages
zeit/next.js canary huv1k/next.js dirname-fix Change
link 2.8 kB 2.8 kB
link gzip 850 B 847 B -3 B
index 2.75 kB 2.75 kB
index gzip 840 B 838 B -2 B
withRouter 2.81 kB 2.81 kB
withRouter gzip 837 B 834 B -3 B
Overall change

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 26.5s 28.5s ⚠️ +2s
nodeModulesSize 41.3 MB 42.6 MB ⚠️ +1.38 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.9 kB 17.9 kB
main-HASH.js gzip 6.56 kB 6.56 kB
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB
commons.HASH.js gzip 61.6 kB 61.6 kB
Overall change
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.2 kB 16.2 kB
main-HASH.module.js gzip 6.28 kB 6.28 kB
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB
commons.HASH.module.js gzip 55.4 kB 55.4 kB
Overall change
Client Pages
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.9 kB 1.9 kB
_app.js gzip 905 B 905 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 600 B 600 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 290 B 290 B
Overall change
Client Pages Modern
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.79 kB 1.79 kB
_app.module.js gzip 865 B 865 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change
Serverless bundles Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_error.js 247 kB 247 kB ⚠️ +55 B
_error.js gzip 66.3 kB 66.3 kB ⚠️ +21 B
hooks.html 2.87 kB 2.87 kB
hooks.html gzip 864 B 867 B ⚠️ +3 B
index.js 248 kB 248 kB ⚠️ +55 B
index.js gzip 66.6 kB 66.6 kB ⚠️ +21 B
link.js 255 kB 255 kB ⚠️ +55 B
link.js gzip 68.8 kB 68.8 kB ⚠️ +21 B
routerDirect.js 248 kB 248 kB ⚠️ +55 B
routerDirect.js gzip 66.5 kB 66.5 kB ⚠️ +22 B
withRouter.js 248 kB 248 kB ⚠️ +55 B
withRouter.js gzip 66.6 kB 66.6 kB ⚠️ +19 B
Overall change ⚠️ +275 B

packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
@Timer Timer added this to the 9.0.5 milestone Aug 20, 2019
@Timer Timer modified the milestones: 9.0.5, 9.0.6 Aug 24, 2019
@ijjk
Copy link
Member

ijjk commented Aug 29, 2019

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 23.3s 22.6s -691ms
nodeModulesSize 41.3 MB 42.7 MB ⚠️ +1.35 MB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.8 kB 17.9 kB ⚠️ +106 B
main-HASH.js gzip 6.55 kB 6.56 kB ⚠️ +9 B
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB
commons.HASH.js gzip 61.6 kB 61.6 kB -1 B
Overall change ⚠️ +106 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.1 kB 16.2 kB ⚠️ +59 B
main-HASH.module.js gzip 6.28 kB 6.28 kB -7 B
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB
commons.HASH.module.js gzip 55.4 kB 55.4 kB
Overall change ⚠️ +59 B
Client Pages Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.83 kB 1.9 kB ⚠️ +67 B
_app.js gzip 881 B 905 B ⚠️ +24 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 600 B 600 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 290 B 290 B
Overall change ⚠️ +67 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.72 kB 1.79 kB ⚠️ +68 B
_app.module.js gzip 838 B 865 B ⚠️ +27 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change ⚠️ +68 B

Diffs

Diff for main-HASH.js
@@ -289,7 +289,7 @@ var _interopRequireDefault = __webpack_require__("KI45");
 exports.__esModule = true;
 exports.render = render;
 exports.renderError = renderError;
-exports["default"] = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = exports.version = void 0;
+exports["default"] = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = void 0;
 
 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
 
@@ -338,13 +338,12 @@ if (!window.Promise) {
 
 var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
 window.__NEXT_DATA__ = data;
-var version = "9.0.5";
-exports.version = version;
 var props = data.props,
     err = data.err,
     page = data.page,
     query = data.query,
     buildId = data.buildId,
+    dynamicBuildId = data.dynamicBuildId,
     assetPrefix = data.assetPrefix,
     runtimeConfig = data.runtimeConfig,
     dynamicIds = data.dynamicIds;
@@ -517,6 +516,8 @@ function () {
             return window.__NEXT_PRELOADREADY(dynamicIds);
 
           case 22:
+            if (false) {}
+
             exports.router = router = (0, _router.createRouter)(page, query, asPath, {
               initialProps: props,
               pageLoader: pageLoader,
@@ -547,7 +548,7 @@ function () {
             render(renderCtx);
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 27:
           case "end":
             return _context.stop();
         }
@@ -1434,6 +1435,8 @@ var PageLoader =
 /*#__PURE__*/
 function () {
   function PageLoader(buildId, assetPrefix) {
+    var _this3 = this;
+
     _classCallCheck(this, PageLoader);
 
     this.buildId = buildId;
@@ -1441,6 +1444,9 @@ function () {
     this.pageCache = {};
     this.pageRegisterEvents = (0, _mitt["default"])();
     this.loadingRoutes = {};
+    this.promisedBuildId = _promise["default"].resolve();
+
+    if (false) {}
 
     if (false) {}
   } // Returns a promise for the dependencies for a particular route
@@ -1469,7 +1475,7 @@ function () {
   }, {
     key: "loadPage",
     value: function loadPage(route) {
-      var _this3 = this;
+      var _this4 = this;
 
       route = this.normalizeRoute(route);
       return new _promise["default"](function (resolve, reject) {
@@ -1477,9 +1483,9 @@ function () {
           var error = _ref.error,
               page = _ref.page;
 
-          _this3.pageRegisterEvents.off(route, fire);
+          _this4.pageRegisterEvents.off(route, fire);
 
-          delete _this3.loadingRoutes[route];
+          delete _this4.loadingRoutes[route];
 
           if (error) {
             reject(error);
@@ -1489,7 +1495,7 @@ function () {
         }; // If there's a cached version of the page, let's use it.
 
 
-        var cachedPage = _this3.pageCache[route];
+        var cachedPage = _this4.pageCache[route];
 
         if (cachedPage) {
           var error = cachedPage.error,
@@ -1499,7 +1505,7 @@ function () {
         } // Register a listener to get the page
 
 
-        _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+        _this4.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
         // rather downloading it again.
 
 
@@ -1507,11 +1513,11 @@ function () {
           return;
         }
 
-        if (!_this3.loadingRoutes[route]) {
+        if (!_this4.loadingRoutes[route]) {
           if (false) {} else {
-            _this3.loadRoute(route);
+            _this4.loadRoute(route);
 
-            _this3.loadingRoutes[route] = true;
+            _this4.loadingRoutes[route] = true;
           }
         }
       });
@@ -1529,13 +1535,22 @@ function () {
           while (1) {
             switch (_context.prev = _context.next) {
               case 0:
+                if (true) {
+                  _context.next = 3;
+                  break;
+                }
+
+                _context.next = 3;
+                return _this.promisedBuildId;
+
+              case 3:
                 route = _this.normalizeRoute(route);
                 scriptRoute = route === '/' ? '/index.js' : route + ".js";
                 url = _this.assetPrefix + "/_next/static/" + encodeURIComponent(_this.buildId) + "/pages" + scriptRoute;
 
                 _this.loadScript(url, route, true);
 
-              case 4:
+              case 7:
               case "end":
                 return _context.stop();
             }
@@ -1546,7 +1561,7 @@ function () {
   }, {
     key: "loadScript",
     value: function loadScript(url, route, isPage) {
-      var _this4 = this;
+      var _this5 = this;
 
       var script = document.createElement('script');
 
@@ -1564,7 +1579,7 @@ function () {
         var error = new Error("Error loading script " + url);
         error.code = 'PAGE_LOAD_ERROR';
 
-        _this4.pageRegisterEvents.emit(route, {
+        _this5.pageRegisterEvents.emit(route, {
           error: error
         });
       };
@@ -1575,7 +1590,7 @@ function () {
   }, {
     key: "registerPage",
     value: function registerPage(route, regFn) {
-      var _this5 = this;
+      var _this6 = this;
 
       var register = function register() {
         try {
@@ -1583,21 +1598,21 @@ function () {
               error = _regFn.error,
               page = _regFn.page;
 
-          _this5.pageCache[route] = {
+          _this6.pageCache[route] = {
             error: error,
             page: page
           };
 
-          _this5.pageRegisterEvents.emit(route, {
+          _this6.pageRegisterEvents.emit(route, {
             error: error,
             page: page
           });
         } catch (error) {
-          _this5.pageCache[route] = {
+          _this6.pageCache[route] = {
             error: error
           };
 
-          _this5.pageRegisterEvents.emit(route, {
+          _this6.pageRegisterEvents.emit(route, {
             error: error
           });
         }
@@ -1620,6 +1635,15 @@ function () {
           while (1) {
             switch (_context2.prev = _context2.next) {
               case 0:
+                if (true) {
+                  _context2.next = 3;
+                  break;
+                }
+
+                _context2.next = 3;
+                return _this2.promisedBuildId;
+
+              case 3:
                 route = _this2.normalizeRoute(route);
                 scriptRoute = (route === '/' ? '/index' : route) + ".js";
 
@@ -1630,69 +1654,69 @@ function () {
                 url = isDependency ? route : _this2.assetPrefix + "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + scriptRoute; // n.b. If preload is not supported, we fall back to `loadPage` which has
                 // its own deduping mechanism.
 
-                if (!document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
-                  _context2.next = 6;
+                if (!(document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"]") || document.querySelector("script[data-next-page=\"" + route + "\"]"))) {
+                  _context2.next = 9;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 6:
+              case 9:
                 if (!(cn = navigator.connection)) {
-                  _context2.next = 9;
+                  _context2.next = 12;
                   break;
                 }
 
                 if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
-                  _context2.next = 9;
+                  _context2.next = 12;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 9:
+              case 12:
                 if (true) {
-                  _context2.next = 15;
+                  _context2.next = 18;
                   break;
                 }
 
                 ;
-                _context2.next = 13;
+                _context2.next = 16;
                 return _this2.getDependencies(route);
 
-              case 13:
+              case 16:
                 _context2.t0 = function (url) {
                   _this2.prefetch(url, true);
                 };
 
                 _context2.sent.forEach(_context2.t0);
 
-              case 15:
+              case 18:
                 if (!hasPreload) {
-                  _context2.next = 18;
+                  _context2.next = 21;
                   break;
                 }
 
                 preloadScript(url);
                 return _context2.abrupt("return");
 
-              case 18:
+              case 21:
                 if (!isDependency) {
-                  _context2.next = 20;
+                  _context2.next = 23;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 20:
+              case 23:
                 if (!(document.readyState === 'complete')) {
-                  _context2.next = 24;
+                  _context2.next = 27;
                   break;
                 }
 
                 return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
 
-              case 24:
+              case 27:
                 return _context2.abrupt("return", new _promise["default"](function (resolve) {
                   window.addEventListener('load', function () {
                     _this2.loadPage(route).then(function () {
@@ -1703,7 +1727,7 @@ function () {
                   });
                 }));
 
-              case 25:
+              case 28:
               case "end":
                 return _context2.stop();
             }
Diff for commons.HASH.js
@@ -1287,11 +1287,9 @@ function _loadGetInitialProps() {
             throw new Error(_message);
 
           case 15:
-            if (false) {}
-
             return _context.abrupt("return", props);
 
-          case 17:
+          case 16:
           case "end":
             return _context.stop();
         }
Diff for main-HASH.module.js
@@ -361,7 +361,7 @@ var _interopRequireDefault = __webpack_require__("KI45");
 exports.__esModule = true;
 exports.render = render;
 exports.renderError = renderError;
-exports.default = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = exports.version = void 0;
+exports.default = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = void 0;
 
 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
 
@@ -410,14 +410,13 @@ if (!window.Promise) {
 
 const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
 window.__NEXT_DATA__ = data;
-const version = "9.0.5";
-exports.version = version;
 const {
   props,
   err,
   page,
   query,
   buildId,
+  dynamicBuildId,
   assetPrefix,
   runtimeConfig,
   dynamicIds
@@ -532,6 +531,8 @@ function () {
       yield window.__NEXT_PRELOADREADY(dynamicIds);
     }
 
+    if (false) {}
+
     exports.router = router = (0, _router.createRouter)(page, query, asPath, {
       initialProps: props,
       pageLoader,
@@ -1350,6 +1351,9 @@ class PageLoader {
     this.pageCache = {};
     this.pageRegisterEvents = (0, _mitt.default)();
     this.loadingRoutes = {};
+    this.promisedBuildId = _promise.default.resolve();
+
+    if (false) {}
 
     if (false) {}
   } // Returns a promise for the dependencies for a particular route
@@ -1420,6 +1424,8 @@ class PageLoader {
     var _this = this;
 
     return (0, _asyncToGenerator2.default)(function* () {
+      if (false) {}
+
       route = _this.normalizeRoute(route);
       let scriptRoute = route === '/' ? '/index.js' : route + ".js";
       const url = _this.assetPrefix + "/_next/static/" + encodeURIComponent(_this.buildId) + "/pages" + scriptRoute;
@@ -1487,6 +1493,8 @@ class PageLoader {
     var _this2 = this;
 
     return (0, _asyncToGenerator2.default)(function* () {
+      if (false) {}
+
       route = _this2.normalizeRoute(route);
       let scriptRoute = (route === '/' ? '/index' : route) + ".js";
 
@@ -1497,7 +1505,7 @@ class PageLoader {
       const url = isDependency ? route : _this2.assetPrefix + "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + scriptRoute; // n.b. If preload is not supported, we fall back to `loadPage` which has
       // its own deduping mechanism.
 
-      if (document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+      if (document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"]") || document.querySelector("script[data-next-page=\"" + route + "\"]")) {
         return;
       } // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
Diff for commons.HASH.module.js
@@ -668,8 +668,6 @@ async function loadGetInitialProps(Component, ctx) {
     throw new Error(message);
   }
 
-  if (false) {}
-
   return props;
 }
Diff for _app.js
@@ -118,7 +118,8 @@ function (_react$default$Compon) {
   }]);
 
   return App;
-}(_react["default"].Component);
+}(_react["default"].Component); // @deprecated noop for now until removal
+
 
 exports["default"] = App;
 App.childContextTypes = {
@@ -126,17 +127,15 @@ App.childContextTypes = {
 };
 App.origGetInitialProps = appGetInitialProps;
 App.getInitialProps = appGetInitialProps;
-var warnContainer;
-var warnUrl;
-
-if (false) {} // @deprecated noop for now until removal
-
 
 function Container(p) {
-  if (false) {}
   return p.children;
 }
 
+var warnUrl = (0, _utils.execOnce)(function () {
+  if (false) {}
+});
+
 function createUrl(router) {
   // This is to make sure we don't references the router object at call time
   var pathname = router.pathname,
@@ -144,40 +143,40 @@ function createUrl(router) {
       query = router.query;
   return {
     get query() {
-      if (false) {}
+      warnUrl();
       return query;
     },
 
     get pathname() {
-      if (false) {}
+      warnUrl();
       return pathname;
     },
 
     get asPath() {
-      if (false) {}
+      warnUrl();
       return asPath;
     },
 
     back: function back() {
-      if (false) {}
+      warnUrl();
       router.back();
     },
     push: function push(url, as) {
-      if (false) {}
+      warnUrl();
       return router.push(url, as);
     },
     pushTo: function pushTo(href, as) {
-      if (false) {}
+      warnUrl();
       var pushRoute = as ? href : '';
       var pushUrl = as || href;
       return router.push(pushRoute, pushUrl);
     },
     replace: function replace(url, as) {
-      if (false) {}
+      warnUrl();
       return router.replace(url, as);
     },
     replaceTo: function replaceTo(href, as) {
-      if (false) {}
+      warnUrl();
       var replaceRoute = as ? href : '';
       var replaceUrl = as || href;
       return router.replace(replaceRoute, replaceUrl);
Diff for _app.module.js
@@ -121,7 +121,8 @@ class App extends _react.default.Component {
     }));
   }
 
-}
+} // @deprecated noop for now until removal
+
 
 exports.default = App;
 App.childContextTypes = {
@@ -129,17 +130,15 @@ App.childContextTypes = {
 };
 App.origGetInitialProps = appGetInitialProps;
 App.getInitialProps = appGetInitialProps;
-let warnContainer;
-let warnUrl;
-
-if (false) {} // @deprecated noop for now until removal
-
 
 function Container(p) {
-  if (false) {}
   return p.children;
 }
 
+const warnUrl = (0, _utils.execOnce)(() => {
+  if (false) {}
+});
+
 function createUrl(router) {
   // This is to make sure we don't references the router object at call time
   const {
@@ -149,40 +148,40 @@ function createUrl(router) {
   } = router;
   return {
     get query() {
-      if (false) {}
+      warnUrl();
       return query;
     },
 
     get pathname() {
-      if (false) {}
+      warnUrl();
       return pathname;
     },
 
     get asPath() {
-      if (false) {}
+      warnUrl();
       return asPath;
     },
 
     back: () => {
-      if (false) {}
+      warnUrl();
       router.back();
     },
     push: (url, as) => {
-      if (false) {}
+      warnUrl();
       return router.push(url, as);
     },
     pushTo: (href, as) => {
-      if (false) {}
+      warnUrl();
       const pushRoute = as ? href : '';
       const pushUrl = as || href;
       return router.push(pushRoute, pushUrl);
     },
     replace: (url, as) => {
-      if (false) {}
+      warnUrl();
       return router.replace(url, as);
     },
     replaceTo: (href, as) => {
-      if (false) {}
+      warnUrl();
       const replaceRoute = as ? href : '';
       const replaceUrl = as || href;
       return router.replace(replaceRoute, replaceUrl);

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 23.7s 24.3s ⚠️ +638ms
nodeModulesSize 41.3 MB 42.7 MB ⚠️ +1.35 MB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.8 kB 17.9 kB ⚠️ +106 B
main-HASH.js gzip 6.55 kB 6.56 kB ⚠️ +9 B
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB
commons.HASH.js gzip 61.6 kB 61.6 kB -1 B
Overall change ⚠️ +106 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.1 kB 16.2 kB ⚠️ +59 B
main-HASH.module.js gzip 6.28 kB 6.28 kB -7 B
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB
commons.HASH.module.js gzip 55.4 kB 55.4 kB
Overall change ⚠️ +59 B
Client Pages Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.83 kB 1.9 kB ⚠️ +67 B
_app.js gzip 881 B 905 B ⚠️ +24 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 600 B 600 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 290 B 290 B
Overall change ⚠️ +67 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.72 kB 1.79 kB ⚠️ +68 B
_app.module.js gzip 838 B 865 B ⚠️ +27 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change ⚠️ +68 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_error.js 246 kB 247 kB ⚠️ +1.04 kB
_error.js gzip 66.1 kB 66.3 kB ⚠️ +241 B
hooks.html 2.85 kB 2.87 kB ⚠️ +23 B
hooks.html gzip 854 B 866 B ⚠️ +12 B
index.js 247 kB 248 kB ⚠️ +984 B
index.js gzip 66.6 kB 66.6 kB ⚠️ +75 B
link.js 254 kB 255 kB ⚠️ +984 B
link.js gzip 68.7 kB 68.8 kB ⚠️ +100 B
routerDirect.js 247 kB 248 kB ⚠️ +984 B
routerDirect.js gzip 66.6 kB 66.5 kB -83 B
withRouter.js 247 kB 248 kB ⚠️ +984 B
withRouter.js gzip 66.5 kB 66.6 kB ⚠️ +92 B
Overall change ⚠️ +5 kB

@huv1k huv1k changed the title [WIP] Fix for __dirname Fix for __dirname Aug 30, 2019
@huv1k
Copy link
Contributor Author

huv1k commented Aug 30, 2019

Blocked by vercel/webpack-asset-relocator-loader#69

@ijjk
Copy link
Member

ijjk commented Aug 30, 2019

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 22.6s 22.4s -284ms
nodeModulesSize 41.8 MB 42.7 MB ⚠️ +898 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.8 kB 17.9 kB ⚠️ +84 B
main-HASH.js gzip 6.56 kB 6.56 kB ⚠️ +3 B
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB -46 B
commons.HASH.js gzip 61.6 kB 61.6 kB -20 B
Overall change ⚠️ +38 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.2 kB 16.2 kB ⚠️ +37 B
main-HASH.module.js gzip 6.28 kB 6.28 kB -9 B
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB -46 B
commons.HASH.module.js gzip 55.4 kB 55.4 kB -15 B
Overall change -9 B
Client Pages Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.83 kB 1.9 kB ⚠️ +67 B
_app.js gzip 881 B 905 B ⚠️ +24 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 601 B 600 B -1 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB ⚠️ +1 B
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 289 B 290 B ⚠️ +1 B
Overall change ⚠️ +67 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.72 kB 1.79 kB ⚠️ +68 B
_app.module.js gzip 838 B 865 B ⚠️ +27 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change ⚠️ +68 B

Diffs

Diff for main-HASH.js
@@ -289,7 +289,7 @@ var _interopRequireDefault = __webpack_require__("KI45");
 exports.__esModule = true;
 exports.render = render;
 exports.renderError = renderError;
-exports["default"] = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = exports.version = void 0;
+exports["default"] = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = void 0;
 
 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
 
@@ -338,13 +338,12 @@ if (!window.Promise) {
 
 var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
 window.__NEXT_DATA__ = data;
-var version = "9.0.5";
-exports.version = version;
 var props = data.props,
     err = data.err,
     page = data.page,
     query = data.query,
     buildId = data.buildId,
+    dynamicBuildId = data.dynamicBuildId,
     assetPrefix = data.assetPrefix,
     runtimeConfig = data.runtimeConfig,
     dynamicIds = data.dynamicIds;
@@ -517,6 +516,8 @@ function () {
             return window.__NEXT_PRELOADREADY(dynamicIds);
 
           case 22:
+            if (false) {}
+
             exports.router = router = (0, _router.createRouter)(page, query, asPath, {
               initialProps: props,
               pageLoader: pageLoader,
@@ -547,7 +548,7 @@ function () {
             render(renderCtx);
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 27:
           case "end":
             return _context.stop();
         }
@@ -1425,7 +1426,7 @@ function preloadScript(url) {
   var link = document.createElement('link');
   link.rel = 'preload';
   link.crossOrigin = "anonymous";
-  link.href = encodeURI(url);
+  link.href = url;
   link.as = 'script';
   document.head.appendChild(link);
 }
@@ -1434,6 +1435,8 @@ var PageLoader =
 /*#__PURE__*/
 function () {
   function PageLoader(buildId, assetPrefix) {
+    var _this3 = this;
+
     _classCallCheck(this, PageLoader);
 
     this.buildId = buildId;
@@ -1441,6 +1444,9 @@ function () {
     this.pageCache = {};
     this.pageRegisterEvents = (0, _mitt["default"])();
     this.loadingRoutes = {};
+    this.promisedBuildId = _promise["default"].resolve();
+
+    if (false) {}
 
     if (false) {}
   } // Returns a promise for the dependencies for a particular route
@@ -1469,7 +1475,7 @@ function () {
   }, {
     key: "loadPage",
     value: function loadPage(route) {
-      var _this3 = this;
+      var _this4 = this;
 
       route = this.normalizeRoute(route);
       return new _promise["default"](function (resolve, reject) {
@@ -1477,9 +1483,9 @@ function () {
           var error = _ref.error,
               page = _ref.page;
 
-          _this3.pageRegisterEvents.off(route, fire);
+          _this4.pageRegisterEvents.off(route, fire);
 
-          delete _this3.loadingRoutes[route];
+          delete _this4.loadingRoutes[route];
 
           if (error) {
             reject(error);
@@ -1489,7 +1495,7 @@ function () {
         }; // If there's a cached version of the page, let's use it.
 
 
-        var cachedPage = _this3.pageCache[route];
+        var cachedPage = _this4.pageCache[route];
 
         if (cachedPage) {
           var error = cachedPage.error,
@@ -1499,7 +1505,7 @@ function () {
         } // Register a listener to get the page
 
 
-        _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+        _this4.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
         // rather downloading it again.
 
 
@@ -1507,11 +1513,11 @@ function () {
           return;
         }
 
-        if (!_this3.loadingRoutes[route]) {
+        if (!_this4.loadingRoutes[route]) {
           if (false) {} else {
-            _this3.loadRoute(route);
+            _this4.loadRoute(route);
 
-            _this3.loadingRoutes[route] = true;
+            _this4.loadingRoutes[route] = true;
           }
         }
       });
@@ -1529,13 +1535,22 @@ function () {
           while (1) {
             switch (_context.prev = _context.next) {
               case 0:
+                if (true) {
+                  _context.next = 3;
+                  break;
+                }
+
+                _context.next = 3;
+                return _this.promisedBuildId;
+
+              case 3:
                 route = _this.normalizeRoute(route);
                 scriptRoute = route === '/' ? '/index.js' : route + ".js";
                 url = _this.assetPrefix + "/_next/static/" + encodeURIComponent(_this.buildId) + "/pages" + scriptRoute;
 
                 _this.loadScript(url, route, true);
 
-              case 4:
+              case 7:
               case "end":
                 return _context.stop();
             }
@@ -1546,7 +1561,7 @@ function () {
   }, {
     key: "loadScript",
     value: function loadScript(url, route, isPage) {
-      var _this4 = this;
+      var _this5 = this;
 
       var script = document.createElement('script');
 
@@ -1558,13 +1573,13 @@ function () {
       }
 
       script.crossOrigin = "anonymous";
-      script.src = encodeURI(url);
+      script.src = url;
 
       script.onerror = function () {
         var error = new Error("Error loading script " + url);
         error.code = 'PAGE_LOAD_ERROR';
 
-        _this4.pageRegisterEvents.emit(route, {
+        _this5.pageRegisterEvents.emit(route, {
           error: error
         });
       };
@@ -1575,7 +1590,7 @@ function () {
   }, {
     key: "registerPage",
     value: function registerPage(route, regFn) {
-      var _this5 = this;
+      var _this6 = this;
 
       var register = function register() {
         try {
@@ -1583,21 +1598,21 @@ function () {
               error = _regFn.error,
               page = _regFn.page;
 
-          _this5.pageCache[route] = {
+          _this6.pageCache[route] = {
             error: error,
             page: page
           };
 
-          _this5.pageRegisterEvents.emit(route, {
+          _this6.pageRegisterEvents.emit(route, {
             error: error,
             page: page
           });
         } catch (error) {
-          _this5.pageCache[route] = {
+          _this6.pageCache[route] = {
             error: error
           };
 
-          _this5.pageRegisterEvents.emit(route, {
+          _this6.pageRegisterEvents.emit(route, {
             error: error
           });
         }
@@ -1620,6 +1635,15 @@ function () {
           while (1) {
             switch (_context2.prev = _context2.next) {
               case 0:
+                if (true) {
+                  _context2.next = 3;
+                  break;
+                }
+
+                _context2.next = 3;
+                return _this2.promisedBuildId;
+
+              case 3:
                 route = _this2.normalizeRoute(route);
                 scriptRoute = (route === '/' ? '/index' : route) + ".js";
 
@@ -1630,69 +1654,69 @@ function () {
                 url = isDependency ? route : _this2.assetPrefix + "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + scriptRoute; // n.b. If preload is not supported, we fall back to `loadPage` which has
                 // its own deduping mechanism.
 
-                if (!document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
-                  _context2.next = 6;
+                if (!(document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"]") || document.querySelector("script[data-next-page=\"" + route + "\"]"))) {
+                  _context2.next = 9;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 6:
+              case 9:
                 if (!(cn = navigator.connection)) {
-                  _context2.next = 9;
+                  _context2.next = 12;
                   break;
                 }
 
                 if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
-                  _context2.next = 9;
+                  _context2.next = 12;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 9:
+              case 12:
                 if (true) {
-                  _context2.next = 15;
+                  _context2.next = 18;
                   break;
                 }
 
                 ;
-                _context2.next = 13;
+                _context2.next = 16;
                 return _this2.getDependencies(route);
 
-              case 13:
+              case 16:
                 _context2.t0 = function (url) {
                   _this2.prefetch(url, true);
                 };
 
                 _context2.sent.forEach(_context2.t0);
 
-              case 15:
+              case 18:
                 if (!hasPreload) {
-                  _context2.next = 18;
+                  _context2.next = 21;
                   break;
                 }
 
                 preloadScript(url);
                 return _context2.abrupt("return");
 
-              case 18:
+              case 21:
                 if (!isDependency) {
-                  _context2.next = 20;
+                  _context2.next = 23;
                   break;
                 }
 
                 return _context2.abrupt("return");
 
-              case 20:
+              case 23:
                 if (!(document.readyState === 'complete')) {
-                  _context2.next = 24;
+                  _context2.next = 27;
                   break;
                 }
 
                 return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
 
-              case 24:
+              case 27:
                 return _context2.abrupt("return", new _promise["default"](function (resolve) {
                   window.addEventListener('load', function () {
                     _this2.loadPage(route).then(function () {
@@ -1703,7 +1727,7 @@ function () {
                   });
                 }));
 
-              case 25:
+              case 28:
               case "end":
                 return _context2.stop();
             }
Diff for commons.HASH.js
@@ -1287,11 +1287,9 @@ function _loadGetInitialProps() {
             throw new Error(_message);
 
           case 15:
-            if (false) {}
-
             return _context.abrupt("return", props);
 
-          case 17:
+          case 16:
           case "end":
             return _context.stop();
         }
@@ -3308,7 +3306,7 @@ function () {
           var routeMatch = route_matcher_1.getRouteMatcher(rr)(asPathname);
 
           if (!routeMatch) {
-            console.error('The provided `as` value is incompatible with the `href` value. This is invalid. https://err.sh/zeit/next.js/incompatible-href-as');
+            console.error("Your `<Link>`'s `as` value is incompatible with the `href` value. This is invalid.");
             return resolve(false);
           } // Merge params into `query`, overwriting any specified in search
Diff for main-HASH.module.js
@@ -361,7 +361,7 @@ var _interopRequireDefault = __webpack_require__("KI45");
 exports.__esModule = true;
 exports.render = render;
 exports.renderError = renderError;
-exports.default = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = exports.version = void 0;
+exports.default = exports.emitter = exports.ErrorComponent = exports.router = exports.dataManager = void 0;
 
 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
 
@@ -410,14 +410,13 @@ if (!window.Promise) {
 
 const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
 window.__NEXT_DATA__ = data;
-const version = "9.0.5";
-exports.version = version;
 const {
   props,
   err,
   page,
   query,
   buildId,
+  dynamicBuildId,
   assetPrefix,
   runtimeConfig,
   dynamicIds
@@ -532,6 +531,8 @@ function () {
       yield window.__NEXT_PRELOADREADY(dynamicIds);
     }
 
+    if (false) {}
+
     exports.router = router = (0, _router.createRouter)(page, query, asPath, {
       initialProps: props,
       pageLoader,
@@ -1338,7 +1339,7 @@ function preloadScript(url) {
   const link = document.createElement('link');
   link.rel = 'preload';
   link.crossOrigin = "anonymous";
-  link.href = encodeURI(url);
+  link.href = url;
   link.as = 'script';
   document.head.appendChild(link);
 }
@@ -1350,6 +1351,9 @@ class PageLoader {
     this.pageCache = {};
     this.pageRegisterEvents = (0, _mitt.default)();
     this.loadingRoutes = {};
+    this.promisedBuildId = _promise.default.resolve();
+
+    if (false) {}
 
     if (false) {}
   } // Returns a promise for the dependencies for a particular route
@@ -1420,6 +1424,8 @@ class PageLoader {
     var _this = this;
 
     return (0, _asyncToGenerator2.default)(function* () {
+      if (false) {}
+
       route = _this.normalizeRoute(route);
       let scriptRoute = route === '/' ? '/index.js' : route + ".js";
       const url = _this.assetPrefix + "/_next/static/" + encodeURIComponent(_this.buildId) + "/pages" + scriptRoute;
@@ -1439,7 +1445,7 @@ class PageLoader {
     }
 
     script.crossOrigin = "anonymous";
-    script.src = encodeURI(url);
+    script.src = url;
 
     script.onerror = () => {
       const error = new Error("Error loading script " + url);
@@ -1487,6 +1493,8 @@ class PageLoader {
     var _this2 = this;
 
     return (0, _asyncToGenerator2.default)(function* () {
+      if (false) {}
+
       route = _this2.normalizeRoute(route);
       let scriptRoute = (route === '/' ? '/index' : route) + ".js";
 
@@ -1497,7 +1505,7 @@ class PageLoader {
       const url = isDependency ? route : _this2.assetPrefix + "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + scriptRoute; // n.b. If preload is not supported, we fall back to `loadPage` which has
       // its own deduping mechanism.
 
-      if (document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+      if (document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"]") || document.querySelector("script[data-next-page=\"" + route + "\"]")) {
         return;
       } // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
Diff for commons.HASH.module.js
@@ -668,8 +668,6 @@ async function loadGetInitialProps(Component, ctx) {
     throw new Error(message);
   }
 
-  if (false) {}
-
   return props;
 }
 
@@ -2639,7 +2637,7 @@ class Router {
         const routeMatch = route_matcher_1.getRouteMatcher(rr)(asPathname);
 
         if (!routeMatch) {
-          console.error('The provided `as` value is incompatible with the `href` value. This is invalid. https://err.sh/zeit/next.js/incompatible-href-as');
+          console.error("Your `<Link>`'s `as` value is incompatible with the `href` value. This is invalid.");
           return resolve(false);
         } // Merge params into `query`, overwriting any specified in search
Diff for _app.js
@@ -118,7 +118,8 @@ function (_react$default$Compon) {
   }]);
 
   return App;
-}(_react["default"].Component);
+}(_react["default"].Component); // @deprecated noop for now until removal
+
 
 exports["default"] = App;
 App.childContextTypes = {
@@ -126,17 +127,15 @@ App.childContextTypes = {
 };
 App.origGetInitialProps = appGetInitialProps;
 App.getInitialProps = appGetInitialProps;
-var warnContainer;
-var warnUrl;
-
-if (false) {} // @deprecated noop for now until removal
-
 
 function Container(p) {
-  if (false) {}
   return p.children;
 }
 
+var warnUrl = (0, _utils.execOnce)(function () {
+  if (false) {}
+});
+
 function createUrl(router) {
   // This is to make sure we don't references the router object at call time
   var pathname = router.pathname,
@@ -144,40 +143,40 @@ function createUrl(router) {
       query = router.query;
   return {
     get query() {
-      if (false) {}
+      warnUrl();
       return query;
     },
 
     get pathname() {
-      if (false) {}
+      warnUrl();
       return pathname;
     },
 
     get asPath() {
-      if (false) {}
+      warnUrl();
       return asPath;
     },
 
     back: function back() {
-      if (false) {}
+      warnUrl();
       router.back();
     },
     push: function push(url, as) {
-      if (false) {}
+      warnUrl();
       return router.push(url, as);
     },
     pushTo: function pushTo(href, as) {
-      if (false) {}
+      warnUrl();
       var pushRoute = as ? href : '';
       var pushUrl = as || href;
       return router.push(pushRoute, pushUrl);
     },
     replace: function replace(url, as) {
-      if (false) {}
+      warnUrl();
       return router.replace(url, as);
     },
     replaceTo: function replaceTo(href, as) {
-      if (false) {}
+      warnUrl();
       var replaceRoute = as ? href : '';
       var replaceUrl = as || href;
       return router.replace(replaceRoute, replaceUrl);
Diff for _app.module.js
@@ -121,7 +121,8 @@ class App extends _react.default.Component {
     }));
   }
 
-}
+} // @deprecated noop for now until removal
+
 
 exports.default = App;
 App.childContextTypes = {
@@ -129,17 +130,15 @@ App.childContextTypes = {
 };
 App.origGetInitialProps = appGetInitialProps;
 App.getInitialProps = appGetInitialProps;
-let warnContainer;
-let warnUrl;
-
-if (false) {} // @deprecated noop for now until removal
-
 
 function Container(p) {
-  if (false) {}
   return p.children;
 }
 
+const warnUrl = (0, _utils.execOnce)(() => {
+  if (false) {}
+});
+
 function createUrl(router) {
   // This is to make sure we don't references the router object at call time
   const {
@@ -149,40 +148,40 @@ function createUrl(router) {
   } = router;
   return {
     get query() {
-      if (false) {}
+      warnUrl();
       return query;
     },
 
     get pathname() {
-      if (false) {}
+      warnUrl();
       return pathname;
     },
 
     get asPath() {
-      if (false) {}
+      warnUrl();
       return asPath;
     },
 
     back: () => {
-      if (false) {}
+      warnUrl();
       router.back();
     },
     push: (url, as) => {
-      if (false) {}
+      warnUrl();
       return router.push(url, as);
     },
     pushTo: (href, as) => {
-      if (false) {}
+      warnUrl();
       const pushRoute = as ? href : '';
       const pushUrl = as || href;
       return router.push(pushRoute, pushUrl);
     },
     replace: (url, as) => {
-      if (false) {}
+      warnUrl();
       return router.replace(url, as);
     },
     replaceTo: (href, as) => {
-      if (false) {}
+      warnUrl();
       const replaceRoute = as ? href : '';
       const replaceUrl = as || href;
       return router.replace(replaceRoute, replaceUrl);

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
buildDuration 23.1s 24.8s ⚠️ +1.7s
nodeModulesSize 41.8 MB 42.7 MB ⚠️ +898 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.js 17.8 kB 17.9 kB ⚠️ +84 B
main-HASH.js gzip 6.56 kB 6.56 kB ⚠️ +3 B
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
commons.HASH.js 190 kB 190 kB -46 B
commons.HASH.js gzip 61.6 kB 61.6 kB -20 B
Overall change ⚠️ +38 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
zeit/next.js canary huv1k/next.js dirname-fix Change
main-HASH.module.js 16.2 kB 16.2 kB ⚠️ +37 B
main-HASH.module.js gzip 6.29 kB 6.28 kB -10 B
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH.module.js gzip 746 B 746 B
commons.HASH.module.js 171 kB 171 kB -46 B
commons.HASH.module.js gzip 55.4 kB 55.4 kB -15 B
Overall change -9 B
Client Pages Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.js 1.83 kB 1.9 kB ⚠️ +67 B
_app.js gzip 881 B 905 B ⚠️ +24 B
_error.js 12.1 kB 12.1 kB
_error.js gzip 4.76 kB 4.76 kB
hooks.js 1.06 kB 1.06 kB
hooks.js gzip 600 B 600 B
index.js 343 B 343 B
index.js gzip 237 B 237 B
link.js 8.13 kB 8.13 kB
link.js gzip 3.49 kB 3.49 kB
routerDirect.js 429 B 429 B
routerDirect.js gzip 292 B 292 B
withRouter.js 439 B 439 B
withRouter.js gzip 290 B 290 B
Overall change ⚠️ +67 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_app.module.js 1.72 kB 1.79 kB ⚠️ +68 B
_app.module.js gzip 838 B 865 B ⚠️ +27 B
_error.module.js 10.6 kB 10.6 kB
_error.module.js gzip 4.31 kB 4.31 kB
hooks.module.js 596 B 596 B
hooks.module.js gzip 354 B 354 B
index.module.js 319 B 319 B
index.module.js gzip 238 B 238 B
link.module.js 8.52 kB 8.52 kB
link.module.js gzip 3.67 kB 3.67 kB
routerDirect.module.js 417 B 417 B
routerDirect.module.js gzip 292 B 292 B
withRouter.module.js 427 B 427 B
withRouter.module.js gzip 291 B 291 B
Overall change ⚠️ +68 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary huv1k/next.js dirname-fix Change
_error.js 246 kB 247 kB ⚠️ +885 B
_error.js gzip 66.1 kB 66.3 kB ⚠️ +191 B
hooks.html 2.85 kB 2.87 kB ⚠️ +23 B
hooks.html gzip 851 B 865 B ⚠️ +14 B
index.js 247 kB 248 kB ⚠️ +830 B
index.js gzip 66.5 kB 66.6 kB ⚠️ +100 B
link.js 254 kB 255 kB ⚠️ +830 B
link.js gzip 68.7 kB 68.8 kB ⚠️ +134 B
routerDirect.js 248 kB 248 kB ⚠️ +830 B
routerDirect.js gzip 66.4 kB 66.5 kB ⚠️ +147 B
withRouter.js 248 kB 248 kB ⚠️ +830 B
withRouter.js gzip 66.7 kB 66.6 kB -11 B
Overall change ⚠️ +4.23 kB

@timneutkens timneutkens closed this Sep 6, 2019
@tomthornton
Copy link

Very excited for this feature. My API involves reading and writing files so this will be great.

@BrunoBernardino
Copy link

Thank you so much for this @huv1k! For @Timer : Is there anything I can do to help get this merged/shipped more quickly?

@Timer Timer modified the milestones: 9.0.9, 9.1.1, 9.1.2 Oct 7, 2019
@Timer
Copy link
Member

Timer commented Oct 16, 2019

Closing this as we decided to go with a simpler variant that doesn't parse the webpack output. We'll post updates here when we have movement on it.

@Timer Timer closed this Oct 16, 2019
@BrunoBernardino
Copy link

Thanks @Timer! Is there a rough ETA? Like before EOY or whenever more people ask for it?

@timneutkens
Copy link
Member

I've de-prioritized this work as we're currently focused on other improvements that have more impact than this change and this change is quite tricky to get right (would require quite a bit of maintenance overhead).

@huv1k huv1k deleted the dirname-fix branch October 16, 2019 09:08
@BrunoBernardino
Copy link

BrunoBernardino commented Oct 16, 2019

That makes sense, I'll make sure to build a separate lambda that handles the file reading, then.

Thanks for the honesty, @timneutkens!

@timneutkens
Copy link
Member

Feel free to take on this issue / investigate a solution btw!

@BrunoBernardino
Copy link

Would you be willing to share your thoughts on:

we decided to go with a simpler variant that doesn't parse the webpack output

? I'm happy to try and implement something with very few pointers. This PR actually seemed like a pretty simple solution to me, so I'm probably missing a ton of context.

@Albert-Gao
Copy link
Contributor

Any updates on this? just migrated my API to Now serverless, and encounter this problem when using Prisma2, don't want to change my deployment solution.

@lupelius
Copy link

lupelius commented Mar 6, 2020

this is quite an impactful piece of next.js, the whole /api/ capability, without this no one can serve xml pages etc on production builds... Quite a limitation for next.js over php...

@Vrq
Copy link

Vrq commented Aug 17, 2021

Why was closed and what is the other option @Timer

@timneutkens
Copy link
Member

This is currently in progress: #25538

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next.js API routes (and pages) should support reading files
9 participants