Skip to content

Commit

Permalink
Fix tracing edge-runtime dependencies (#39009)
Browse files Browse the repository at this point in the history
* Fix tracing edge-runtime dependencies

* update compiled

* remove old console log
  • Loading branch information
ijjk committed Jul 26, 2022
1 parent 8ae6f28 commit fd7bd12
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/next/build/utils.ts
Expand Up @@ -1148,7 +1148,6 @@ export async function copyTracedFiles(
const symlink = await fs.readlink(tracedFilePath).catch(() => null)

if (symlink) {
console.log('symlink', path.relative(tracingRoot, symlink))
await fs.symlink(symlink, fileOutputPath)
} else {
await fs.copyFile(tracedFilePath, fileOutputPath)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/edge-runtime/index.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions packages/next/taskfile.js
Expand Up @@ -296,6 +296,15 @@ export async function ncc_edge_runtime(task, opts) {
.source(opts.src || relative(__dirname, require.resolve('edge-runtime')))
.ncc({ packageName: 'edge-runtime', externals })
.target('compiled/edge-runtime')

const outputFile = join(__dirname, 'compiled/edge-runtime/index.js')

await fs.writeFile(
outputFile,
(
await fs.readFile(outputFile, 'utf8')
).replace(/eval\("require"\)/g, 'require')
)
}

// eslint-disable-next-line camelcase
Expand Down
34 changes: 34 additions & 0 deletions test/production/required-server-files.test.ts
Expand Up @@ -1243,4 +1243,38 @@ describe('should set-up next', () => {
expect(envVariables.envProd).not.toBeUndefined()
expect(envVariables.envLocal).toBeUndefined()
})

it('should run middleware correctly without minimalMode', async () => {
await killApp(server)
const testServer = join(next.testDir, 'standalone/server.js')
await fs.writeFile(
testServer,
(
await fs.readFile(testServer, 'utf8')
).replace('minimalMode: true', 'minimalMode: false')
)
appPort = await findPort()
server = await initNextServerScript(
testServer,
/Listening on/,
{
...process.env,
PORT: appPort,
},
undefined,
{
cwd: next.testDir,
onStderr(msg) {
if (msg.includes('top-level')) {
errors.push(msg)
}
stderr += msg
},
}
)

const res = await fetchViaHTTP(appPort, '/')
expect(res.status).toBe(200)
expect(await res.text()).toContain('index page')
})
})
1 change: 1 addition & 0 deletions test/production/required-server-files/middleware.js
@@ -1,5 +1,6 @@
import { NextResponse } from 'next/server'

export async function middleware(req) {
console.log('middleware', req.url)
return NextResponse.next()
}

0 comments on commit fd7bd12

Please sign in to comment.