-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix instrumentation with only pages (#62622)
This ensures we properly transpile `instrumentation.ts` when only `pages` is being used as previously we were relying on the `app` specific loaders which aren't configured when an `app` directory isn't present. We regressed on this in #60984 as it was working as expected prior to this commit x-ref: [slack thread](https://vercel.slack.com/archives/C011GK1JUBA/p1709075846401649?thread_ts=1706643408.233909&cid=C011GK1JUBA) Closes NEXT-2632
- Loading branch information
Showing
10 changed files
with
117 additions
and
20 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
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,3 @@ | ||
export async function register() { | ||
console.log('instrumentation log') | ||
} |
67 changes: 67 additions & 0 deletions
67
test/e2e/opentelemetry/instrumentation-pages-app-only.test.ts
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,67 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { retry } from 'next-test-utils' | ||
|
||
for (const { app, src, pathname, text } of [ | ||
{ | ||
pages: true, | ||
src: false, | ||
pathname: '/pages/param/getServerSideProps', | ||
text: 'Page', | ||
}, | ||
{ | ||
pages: true, | ||
src: true, | ||
pathname: '/pages/param/getServerSideProps', | ||
text: 'Page', | ||
}, | ||
{ | ||
app: true, | ||
src: false, | ||
pathname: '/app/param/rsc-fetch', | ||
text: 'Page', | ||
}, | ||
{ | ||
app: true, | ||
src: true, | ||
pathname: '/app/param/rsc-fetch', | ||
text: 'Page', | ||
}, | ||
]) { | ||
describe(`instrumentation ${app ? 'app' : 'pages'}${ | ||
src ? ' src/' : '' | ||
}`, () => { | ||
const curDir = app ? 'app' : 'pages' | ||
const oppositeDir = app ? 'pages' : 'app' | ||
|
||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
env: { | ||
NEXT_PUBLIC_SIMPLE_INSTRUMENT: '1', | ||
}, | ||
skipDeployment: true, | ||
packageJson: { | ||
scripts: { | ||
'setup-dir': `mv instrumentation-minimal.ts instrumentation.ts; rm -rf ${oppositeDir}${ | ||
src | ||
? `; mkdir src; mv ${curDir} src/; mv instrumentation.ts src/` | ||
: '' | ||
}`, | ||
dev: 'pnpm setup-dir && next dev', | ||
build: 'pnpm setup-dir && next build', | ||
start: 'next start', | ||
}, | ||
}, | ||
startCommand: `pnpm ${(global as any).isNextDev ? 'dev' : 'start'}`, | ||
buildCommand: `pnpm build`, | ||
dependencies: require('./package.json').dependencies, | ||
}) | ||
|
||
it('should start and serve correctly', async () => { | ||
const html = await next.render(pathname) | ||
expect(html).toContain(text) | ||
retry(() => { | ||
expect(next.cliOutput).toContain('instrumentation log') | ||
}) | ||
}) | ||
}) | ||
} |
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