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
a7932cbb
Unverified
Commit
a7932cbb
authored
Oct 09, 2021
by
Tim Neutkens
Committed by
GitHub
Oct 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add trace span for module readFile (#29759)
parent
2e2c558a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
profiling-plugin.ts
packages/next/build/webpack/plugins/profiling-plugin.ts
+23
-14
No files found.
packages/next/build/webpack/plugins/profiling-plugin.ts
View file @
a7932cbb
...
@@ -10,11 +10,6 @@ const moduleSpansByCompilation = new WeakMap<
...
@@ -10,11 +10,6 @@ const moduleSpansByCompilation = new WeakMap<
>
()
>
()
export
const
webpackInvalidSpans
=
new
WeakMap
<
any
,
Span
>
()
export
const
webpackInvalidSpans
=
new
WeakMap
<
any
,
Span
>
()
function
getNormalModuleLoaderHook
(
compilation
:
any
)
{
// @ts-ignore TODO: Remove ignore when webpack 5 is stable
return
NormalModule
.
getCompilationHooks
(
compilation
).
loader
}
export
class
ProfilingPlugin
{
export
class
ProfilingPlugin
{
compiler
:
any
compiler
:
any
runWebpackSpan
:
Span
runWebpackSpan
:
Span
...
@@ -146,15 +141,29 @@ export class ProfilingPlugin {
...
@@ -146,15 +141,29 @@ export class ProfilingPlugin {
moduleSpans
!
.
set
(
module
,
span
)
moduleSpans
!
.
set
(
module
,
span
)
})
})
getNormalModuleLoaderHook
(
compilation
).
tap
(
const
moduleHooks
=
NormalModule
.
getCompilationHooks
(
compilation
)
pluginName
,
// @ts-ignore TODO: remove ignore when using webpack 5 types
(
loaderContext
:
any
,
module
:
any
)
=>
{
moduleHooks
.
readResource
.
for
(
undefined
).
intercept
({
register
(
tapInfo
:
any
)
{
const
fn
=
tapInfo
.
fn
tapInfo
.
fn
=
(
loaderContext
:
any
,
callback
:
any
)
=>
{
const
moduleSpan
=
loaderContext
.
currentTraceSpan
.
traceChild
(
`read-resource`
)
fn
(
loaderContext
,
(
err
:
any
,
result
:
any
)
=>
{
moduleSpan
.
stop
()
callback
(
err
,
result
)
})
}
return
tapInfo
},
})
moduleHooks
.
loader
.
tap
(
pluginName
,
(
loaderContext
:
any
,
module
:
any
)
=>
{
const
moduleSpan
=
moduleSpansByCompilation
const
moduleSpan
=
moduleSpansByCompilation
.
get
(
compilation
)
.
get
(
compilation
)
?.
get
(
module
)
?.
get
(
module
)
loaderContext
.
currentTraceSpan
=
moduleSpan
loaderContext
.
currentTraceSpan
=
moduleSpan
}
})
)
compilation
.
hooks
.
succeedModule
.
tap
(
pluginName
,
(
module
:
any
)
=>
{
compilation
.
hooks
.
succeedModule
.
tap
(
pluginName
,
(
module
:
any
)
=>
{
moduleSpansByCompilation
?.
get
(
compilation
)?.
get
(
module
)?.
stop
()
moduleSpansByCompilation
?.
get
(
compilation
)?.
get
(
module
)?.
stop
()
...
...
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