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

De-experimentalize the public/ folder #8661

Merged
merged 11 commits into from
Oct 6, 2019
Next Next commit
Remove experimental.publicDirectory config
  • Loading branch information
ijjk committed Sep 6, 2019
commit e74695d0e4301eaed1baa51d1110659ebac7e4c0
6 changes: 1 addition & 5 deletions packages/next/export/index.js
Original file line number Diff line number Diff line change
@@ -165,11 +165,7 @@ export default async function (dir, options, configuration) {

const publicDir = join(dir, CLIENT_PUBLIC_FILES_PATH)
// Copy public directory
if (
nextConfig.experimental &&
nextConfig.experimental.publicDirectory &&
existsSync(publicDir)
) {
if (existsSync(publicDir)) {
log(' copying "public" directory')
await recursiveCopy(publicDir, outDir, {
filter (path) {
1 change: 0 additions & 1 deletion packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ const defaultConfig: { [key: string]: any } = {
profiling: false,
documentMiddleware: false,
granularChunks: false,
publicDirectory: false,
modern: false,
},
future: {
5 changes: 1 addition & 4 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
@@ -258,10 +258,7 @@ export default class Server {
},
]

if (
this.nextConfig.experimental.publicDirectory &&
fs.existsSync(this.publicDir)
) {
if (fs.existsSync(this.publicDir)) {
routes.push(...this.generatePublicRoutes())
}

11 changes: 3 additions & 8 deletions packages/next/server/next-dev-server.js
Original file line number Diff line number Diff line change
@@ -293,14 +293,9 @@ export default class DevServer extends Server {
})
} catch (err) {
if (err.code === 'ENOENT') {
if (this.nextConfig.experimental.publicDirectory) {
// Try to send a public file and let servePublic handle the request from here
await this.servePublic(req, res, pathname)
return null
} else {
res.statusCode = 404
return this.renderErrorToHTML(null, req, res, pathname, query)
}
// Try to send a public file and let servePublic handle the request from here
await this.servePublic(req, res, pathname)
return null
}
if (!this.quiet) console.error(err)
}
3 changes: 0 additions & 3 deletions test/integration/basic/next.config.js
Original file line number Diff line number Diff line change
@@ -4,9 +4,6 @@ module.exports = {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
},
experimental: {
publicDirectory: true
},
webpack (config) {
config.module.rules.push({
test: /pages[\\/]hmr[\\/]about/,
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ describe('Promise in next config', () => {
module.exports = {
target: 'server',
experimental: {
publicDirectory: true
something: true
}
}
`)
@@ -52,7 +52,7 @@ describe('Promise in next config', () => {
module.exports = (phase) => ({
target: 'server',
experimental: {
publicDirectory: true
something: true
}
})
`)
3 changes: 0 additions & 3 deletions test/integration/export/next.config.js
Original file line number Diff line number Diff line change
@@ -9,9 +9,6 @@ module.exports = phase => {
serverRuntimeConfig: {
bar: 'bar'
},
experimental: {
publicDirectory: true
},
exportTrailingSlash: true,
exportPathMap: function () {
return {
3 changes: 0 additions & 3 deletions test/integration/production/next.config.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,5 @@ module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
},
experimental: {
publicDirectory: true
}
}
3 changes: 0 additions & 3 deletions test/integration/serverless-trace/next.config.js
Original file line number Diff line number Diff line change
@@ -4,9 +4,6 @@ module.exports = {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
},
experimental: {
publicDirectory: true
},
// make sure error isn't thrown from empty publicRuntimeConfig
publicRuntimeConfig: {}
}
3 changes: 0 additions & 3 deletions test/integration/serverless/next.config.js
Original file line number Diff line number Diff line change
@@ -4,9 +4,6 @@ module.exports = {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
},
experimental: {
publicDirectory: true
},
// make sure error isn't thrown from empty publicRuntimeConfig
publicRuntimeConfig: {}
}