-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
De-experimentalize the
public/
folder (#8661)
* Remove experimental.publicDirectory config * Error when public is set as an output dir * Remove experimental.publicDirectory checks * Update publicFiles checking in next build
- Loading branch information
1 parent
1a02dfd
commit e2d713f
Showing
15 changed files
with
97 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Can't Override Next Props | ||
|
||
#### Why This Error Occurred | ||
|
||
Either you set `distDir` to `public` in your `next.config.js` or during `next export` you tried to export to the `public` directory. | ||
|
||
This is not allowed due to `public` being a special folder in Next.js used to serve static assets. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Use a different `distDir` or export to a different folder. | ||
|
||
### Useful Links | ||
|
||
- [Static file serving docs](https://nextjs.org/docs#static-file-serving-eg-images) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default () => 'hi' |
37 changes: 37 additions & 0 deletions
37
test/integration/errors-on-output-to-public/test/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { nextBuild, nextExport } from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
const appDir = path.join(__dirname, '..') | ||
const nextConfig = path.join(appDir, 'next.config.js') | ||
|
||
describe('Errors on output to public', () => { | ||
it('Throws error when `distDir` is set to public', async () => { | ||
await fs.writeFile(nextConfig, `module.exports = { distDir: 'public' }`) | ||
const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) | ||
expect(results.stdout + results.stderr).toMatch( | ||
/The 'public' directory is reserved in Next.js and can not be set as/ | ||
) | ||
await fs.remove(nextConfig) | ||
}) | ||
|
||
it('Throws error when export out dir is public', async () => { | ||
await fs.remove(nextConfig) | ||
await nextBuild(appDir) | ||
const outdir = path.join(appDir, 'public') | ||
const results = await nextExport( | ||
appDir, | ||
{ outdir }, | ||
{ | ||
stdout: true, | ||
stderr: true | ||
} | ||
) | ||
expect(results.stdout + results.stderr).toMatch( | ||
/The 'public' directory is reserved in Next.js and can not be used as/ | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters