Skip to content

Commit

Permalink
Fix folders included in trace (#46011)
Browse files Browse the repository at this point in the history
We should not include directories themselves in the trace files so this
ensures they are excluded and adds a test case for this.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1676568891229219?thread_ts=1676543026.736539&cid=C03S8ED1DKM)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
  • Loading branch information
ijjk authored Feb 16, 2023
1 parent ade7264 commit f3b231c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,12 +1717,16 @@ export default async function build(
require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob')
const glob = (pattern: string): Promise<string[]> => {
return new Promise((resolve, reject) => {
globOrig(pattern, { cwd: dir }, (err, files) => {
if (err) {
return reject(err)
globOrig(
pattern,
{ cwd: dir, nodir: true, dot: true },
(err, files) => {
if (err) {
return reject(err)
}
resolve(files)
}
resolve(files)
})
)
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
content
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
},
experimental: {
outputFileTracingIncludes: {
'/index': ['include-me/*'],
'/index': ['include-me/**/*'],
},
outputFileTracingExcludes: {
'/index': ['public/exclude-me/**/*'],
Expand Down
11 changes: 11 additions & 0 deletions test/integration/build-trace-extra-entries/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ describe('build trace with extra entries', () => {
expect(
indexTrace.files.some((file) => file.endsWith('hello.json'))
).toBeFalsy()
expect(
indexTrace.files.some((file) => file.endsWith('some-dir'))
).toBeFalsy()
expect(
indexTrace.files.some((file) =>
file.endsWith('.dot-folder/another-file.txt')
)
).toBe(true)
expect(
indexTrace.files.some((file) => file.endsWith('some-dir/file.txt'))
).toBe(true)
expect(
indexTrace.files.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
Expand Down

0 comments on commit f3b231c

Please sign in to comment.