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

Add warning for API export routes #8250

Merged
merged 3 commits into from
Aug 5, 2019
Merged

Add warning for API export routes #8250

merged 3 commits into from
Aug 5, 2019

Conversation

huv1k
Copy link
Contributor

@huv1k huv1k commented Aug 5, 2019

This PR adds a warning to API exported routes and skip exporting of them.

@ijjk
Copy link
Member

ijjk commented Aug 5, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js api-export Change
Build Duration 12.9s 12.6s -300ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +553 B
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.4 kB
Client main gzip Size 5.35 kB 5.35 kB
Client commons Size 188 kB 188 kB
Client commons gzip Size 61.1 kB 61.1 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 702 kB 702 kB
Click to expand serverless stats
zeit/next.js canary huv1k/next.js api-export Change
Build Duration 14.6s 14.6s ⚠️ +70ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +553 B
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.4 kB
Client main gzip Size 5.35 kB 5.35 kB
Client commons Size 188 kB 188 kB
Client commons gzip Size 61.1 kB 61.1 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Serverless pages/link Size 251 kB 251 kB
Serverless pages/link gzip Size 67.8 kB 67.8 kB
Serverless pages/index Size 244 kB 244 kB
Serverless pages/index gzip Size 65.6 kB 65.6 kB
Serverless pages/_error Size 243 kB 243 kB
Serverless pages/_error gzip Size 65.4 kB 65.4 kB -1 B
Serverless pages/routerDirect Size 244 kB 244 kB
Serverless pages/routerDirect gzip Size 65.6 kB 65.6 kB
Serverless pages/withRouter Size 244 kB 244 kB
Serverless pages/withRouter gzip Size 65.7 kB 65.7 kB
Build Dir Size 1.89 MB 1.89 MB

@ijjk
Copy link
Member

ijjk commented Aug 5, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary huv1k/next.js api-export Change
Build Duration 13.6s 13.1s -464ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +553 B
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.4 kB
Client main gzip Size 5.35 kB 5.35 kB
Client commons Size 188 kB 188 kB
Client commons gzip Size 61.1 kB 61.1 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 702 kB 702 kB
Click to expand serverless stats
zeit/next.js canary huv1k/next.js api-export Change
Build Duration 14.8s 14.5s -321ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +553 B
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.4 kB
Client main gzip Size 5.35 kB 5.35 kB
Client commons Size 188 kB 188 kB
Client commons gzip Size 61.1 kB 61.1 kB
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Serverless pages/link Size 251 kB 251 kB
Serverless pages/link gzip Size 67.8 kB 67.8 kB ⚠️ +1 B
Serverless pages/index Size 244 kB 244 kB
Serverless pages/index gzip Size 65.6 kB 65.6 kB
Serverless pages/_error Size 243 kB 243 kB
Serverless pages/_error gzip Size 65.4 kB 65.4 kB
Serverless pages/routerDirect Size 244 kB 244 kB
Serverless pages/routerDirect gzip Size 65.6 kB 65.6 kB
Serverless pages/withRouter Size 244 kB 244 kB
Serverless pages/withRouter gzip Size 65.7 kB 65.7 kB ⚠️ +1 B
Build Dir Size 1.89 MB 1.89 MB

@huv1k huv1k merged commit abcaba7 into vercel:canary Aug 5, 2019
@huv1k huv1k deleted the api-export branch August 5, 2019 22:46
Copy link
Member

@Timer Timer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -35,6 +36,7 @@ export default async function (dir, options, configuration) {
const threads = options.threads || Math.max(cpus().length - 1, 1)
const distDir = join(dir, nextConfig.distDir)
const subFolders = nextConfig.exportTrailingSlash
let apiPage = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a more descriptive name (e.g. warnedAboutApiPage) or use the execOnce helper.

// Warn about API pages export
if (isApiRoute && !apiPage) {
apiPage = true
log(` API pages are not supported in export`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message should be flashier IMO, plus it's missing an err.sh link explaining it.

Unactionable messages are against our logging guidelines.

If I'm a user, what do I do next? Not use next export? Delete my API Routes? Customize my export path map?

@@ -285,6 +286,17 @@ function runTests (serverless = false) {
}
})

if (!serverless) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this have to do with the serverless target?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next export can only be used with server

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should note that as a comment

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.

4 participants