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
319a338a
Unverified
Commit
319a338a
authored
Feb 12, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 12, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use resource to detect feature usage in telemetry (#75917)
This is required for when we start using layers in Pages Router.
parent
6800e1ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
telemetry-plugin.ts
...uild/webpack/plugins/telemetry-plugin/telemetry-plugin.ts
+6
-13
No files found.
packages/next/src/build/webpack/plugins/telemetry-plugin/telemetry-plugin.ts
View file @
319a338a
...
@@ -54,14 +54,6 @@ interface FeatureUsage {
...
@@ -54,14 +54,6 @@ interface FeatureUsage {
invocationCount
:
number
invocationCount
:
number
}
}
/**
* A vertex in the module graph.
*/
interface
Module
{
type
:
string
identifier
():
string
}
/**
/**
* An edge in the module graph.
* An edge in the module graph.
*/
*/
...
@@ -127,16 +119,17 @@ const useCacheTracker = createUseCacheTracker()
...
@@ -127,16 +119,17 @@ const useCacheTracker = createUseCacheTracker()
/**
/**
* Determine if there is a feature of interest in the specified 'module'.
* Determine if there is a feature of interest in the specified 'module'.
*/
*/
function
findFeatureInModule
(
module
:
Module
):
Feature
|
undefined
{
function
findFeatureInModule
(
module
:
webpack
.
Module
):
Feature
|
undefined
{
if
(
module
.
type
!==
'javascript/auto'
)
{
if
(
module
.
type
!==
'javascript/auto'
)
{
return
return
}
}
const
normalizedIdentifier
=
module
.
identifier
().
replace
(
/
\\
/g
,
'/'
)
for
(
const
[
feature
,
path
]
of
FEATURE_MODULE_MAP
)
{
for
(
const
[
feature
,
path
]
of
FEATURE_MODULE_MAP
)
{
if
(
normalizedIdentifier
.
endsWith
(
path
))
{
if
(
(
module
as
webpack
.
NormalModule
).
resource
.
endsWith
(
path
))
{
return
feature
return
feature
}
}
}
}
const
normalizedIdentifier
=
module
.
identifier
().
replace
(
/
\\
/g
,
'/'
)
for
(
const
[
feature
,
regexp
]
of
FEATURE_MODULE_REGEXP_MAP
)
{
for
(
const
[
feature
,
regexp
]
of
FEATURE_MODULE_REGEXP_MAP
)
{
if
(
regexp
.
test
(
normalizedIdentifier
))
{
if
(
regexp
.
test
(
normalizedIdentifier
))
{
return
feature
return
feature
...
@@ -151,7 +144,7 @@ function findFeatureInModule(module: Module): Feature | undefined {
...
@@ -151,7 +144,7 @@ function findFeatureInModule(module: Module): Feature | undefined {
*/
*/
function
findUniqueOriginModulesInConnections
(
function
findUniqueOriginModulesInConnections
(
connections
:
Connection
[],
connections
:
Connection
[],
originModule
:
Module
originModule
:
webpack
.
Module
):
Set
<
unknown
>
{
):
Set
<
unknown
>
{
const
originModules
=
new
Set
()
const
originModules
=
new
Set
()
for
(
const
connection
of
connections
)
{
for
(
const
connection
of
connections
)
{
...
@@ -206,7 +199,7 @@ export class TelemetryPlugin implements webpack.WebpackPluginInstance {
...
@@ -206,7 +199,7 @@ export class TelemetryPlugin implements webpack.WebpackPluginInstance {
async
(
compilation
:
webpack
.
Compilation
,
callback
:
()
=>
void
)
=>
{
async
(
compilation
:
webpack
.
Compilation
,
callback
:
()
=>
void
)
=>
{
compilation
.
hooks
.
finishModules
.
tapAsync
(
compilation
.
hooks
.
finishModules
.
tapAsync
(
TelemetryPlugin
.
name
,
TelemetryPlugin
.
name
,
async
(
modules
:
Iterable
<
Module
>
,
modulesFinish
:
()
=>
void
)
=>
{
async
(
modules
,
modulesFinish
)
=>
{
for
(
const
module
of
modules
)
{
for
(
const
module
of
modules
)
{
const
feature
=
findFeatureInModule
(
module
)
const
feature
=
findFeatureInModule
(
module
)
if
(
!
feature
)
{
if
(
!
feature
)
{
...
...
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