forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match public files priority in dev (vercel#8641)
* Match public files priority in dev * Remove un-needed old public file handling * Run public file priority test for non-dev also * Make sure to enable publicDirectory * Add checking for conflicting pages in dev and during build * Add error for public dir middleware conflict * Add err.sh for _next conflict * Move up public dir conflict checking * Only run _next conflict check in dev when path contains it
- Loading branch information
1 parent
369eceb
commit 4e9e510
Showing
24 changed files
with
202 additions
and
37 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,29 @@ | ||
# Conflicting Public File and Page File | ||
|
||
#### Why This Error Occurred | ||
|
||
One of your public files has the exact same path as a page file which is not supported. Since only one resource can reside at the URL both public files and page files must be unique. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Rename either the public file or page file that is causing the conflict. | ||
|
||
Example conflict between public file and page file | ||
``` | ||
public/ | ||
hello | ||
pages/ | ||
hello.js | ||
``` | ||
|
||
Non-conflicting public file and page file | ||
``` | ||
public/ | ||
hello.txt | ||
pages/ | ||
hello.js | ||
``` | ||
|
||
### 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Public \_next folder Conflict | ||
|
||
#### Why This Error Occurred | ||
|
||
In your `./public` folder you added a `_next` folder which conflicts with the internal usage of `_next`. Due to this conflicting this folder name is not allowed inside of your `public` folder. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Rename the `_next` folder in your `public` folder to something else or remove it. |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
module.exports = { | ||
experimental: { | ||
publicDirectory: true | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/integration/conflicting-public-file-page/pages/another/conflict.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 @@ | ||
export default () => `oops this is doesn't work` |
1 change: 1 addition & 0 deletions
1
test/integration/conflicting-public-file-page/pages/another/index.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 @@ | ||
export default () => `oops this is doesn't work` |
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 () => `oops this is doesn't work` |
1 change: 1 addition & 0 deletions
1
test/integration/conflicting-public-file-page/public/another/conflict
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 @@ | ||
oops this is doesn't work |
1 change: 1 addition & 0 deletions
1
test/integration/conflicting-public-file-page/public/another/index
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 @@ | ||
oops this is doesn't work |
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 @@ | ||
oops this is doesn't work |
1 change: 1 addition & 0 deletions
1
test/integration/conflicting-public-file-page/public/normal.txt
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 @@ | ||
no conflict here |
42 changes: 42 additions & 0 deletions
42
test/integration/conflicting-public-file-page/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,42 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import path from 'path' | ||
import { | ||
nextBuild, | ||
launchApp, | ||
findPort, | ||
killApp, | ||
renderViaHTTP, | ||
waitFor | ||
} from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5 | ||
const appDir = path.join(__dirname, '..') | ||
|
||
describe('Errors on conflict between public file and page file', () => { | ||
it('Throws error during development', async () => { | ||
const appPort = await findPort() | ||
const app = await launchApp(appDir, appPort) | ||
const conflicts = ['/another/conflict', '/another/index', '/hello'] | ||
|
||
for (const conflict of conflicts) { | ||
const html = await renderViaHTTP(appPort, conflict) | ||
expect(html).toMatch( | ||
/A conflicting public file and page file was found for path/ | ||
) | ||
} | ||
await waitFor(1000) | ||
await killApp(app) | ||
}) | ||
|
||
it('Throws error during build', async () => { | ||
const conflicts = ['/another/conflict', '/another', '/hello'] | ||
const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) | ||
const output = results.stdout + results.stderr | ||
expect(output).toMatch(/Conflicting public and page files were found/) | ||
|
||
for (const conflict of conflicts) { | ||
expect(output.indexOf(conflict) > 0).toBe(true) | ||
} | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module.exports = { | ||
experimental: { | ||
modern: true | ||
modern: true, | ||
publicDirectory: true | ||
} | ||
} |
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 @@ | ||
hello world |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.