Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ad4c7855
Commit
ad4c7855
authored
Mar 27, 2026
by
Jude Gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Webpack] Transpile external TypeScript files imported by instrumentation-client in pages layer
parent
3cee3a37
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
0 deletions
+85
-0
webpack-config.ts
packages/next/src/build/webpack-config.ts
+10
-0
layout.tsx
...pp-dir/instrumentation-client-external-dir/app/layout.tsx
+8
-0
page.tsx
.../app-dir/instrumentation-client-external-dir/app/page.tsx
+13
-0
instrumentation-client-external-dir.test.ts
...-external-dir/instrumentation-client-external-dir.test.ts
+44
-0
instrumentation-client.ts
...rumentation-client-external-dir/instrumentation-client.ts
+4
-0
next.config.js
...pp-dir/instrumentation-client-external-dir/next.config.js
+6
-0
No files found.
packages/next/src/build/webpack-config.ts
View file @
ad4c7855
...
@@ -1766,6 +1766,16 @@ export default async function getBaseWebpackConfig(
...
@@ -1766,6 +1766,16 @@ export default async function getBaseWebpackConfig(
},
},
]
]
:
[]),
:
[]),
{
test
:
codeCondition
.
test
,
exclude
:
codeCondition
.
exclude
,
issuerLayer
:
WEBPACK_LAYERS
.
pagesDirBrowser
,
use
:
[
...
reactRefreshLoaders
,
defaultLoaders
.
babel
,
reactCompilerLoader
,
].
filter
(
Boolean
),
},
{
{
...
codeCondition
,
...
codeCondition
,
use
:
[
use
:
[
...
...
test/e2e/app-dir/instrumentation-client-external-dir/app/layout.tsx
0 → 100644
View file @
ad4c7855
import
{
ReactNode
}
from
'react'
export
default
function
Root
({
children
}:
{
children
:
ReactNode
})
{
return
(
<
html
>
<
body
>
{
children
}
</
body
>
</
html
>
)
}
test/e2e/app-dir/instrumentation-client-external-dir/app/page.tsx
0 → 100644
View file @
ad4c7855
'use client'
import
{
useEffect
,
useState
}
from
'react'
export
default
function
Page
()
{
const
[
result
,
setResult
]
=
useState
<
string
>
(
''
)
useEffect
(()
=>
{
setResult
((
window
as
any
).
__INSTRUMENTATION_CLIENT_RESULT
||
'not-set'
)
},
[])
return
<
p
id=
"result"
>
{
result
}
</
p
>
}
test/e2e/app-dir/instrumentation-client-external-dir/instrumentation-client-external-dir.test.ts
0 → 100644
View file @
ad4c7855
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
retry
}
from
'next-test-utils'
import
fs
from
'fs'
import
path
from
'path'
describe
(
'instrumentation-client-external-dir'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
skipDeployment
:
true
,
skipStart
:
true
,
})
beforeAll
(
async
()
=>
{
// Create the external package directory outside the project root
// to simulate a monorepo sibling package with TypeScript files
const
externalDir
=
path
.
join
(
next
.
testDir
,
'..'
,
'external-package'
)
await
fs
.
promises
.
mkdir
(
externalDir
,
{
recursive
:
true
})
await
fs
.
promises
.
writeFile
(
path
.
join
(
externalDir
,
'utils.ts'
),
`
interface InitOptions {
debug: boolean
}
export function initClient(options: InitOptions): string {
const message: string = options.debug
? 'external-package-init-debug'
: 'external-package-init'
return message
}
`
)
await
next
.
start
()
})
it
(
'should transpile TypeScript files imported from outside the project root in instrumentation-client'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
await
retry
(
async
()
=>
{
const
result
=
await
browser
.
elementById
(
'result'
).
text
()
expect
(
result
).
toBe
(
'external-package-init-debug'
)
})
})
})
test/e2e/app-dir/instrumentation-client-external-dir/instrumentation-client.ts
0 → 100644
View file @
ad4c7855
import
{
initClient
}
from
'../external-package/utils'
const
result
=
initClient
({
debug
:
true
})
;(
window
as
any
).
__INSTRUMENTATION_CLIENT_RESULT
=
result
test/e2e/app-dir/instrumentation-client-external-dir/next.config.js
0 → 100644
View file @
ad4c7855
/**
* @type {import('next').NextConfig}
*/
const
nextConfig
=
{}
module
.
exports
=
nextConfig
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment