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
7035a036
Unverified
Commit
7035a036
authored
May 21, 2021
by
Tobias Koppers
Committed by
GitHub
May 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lazy load postcss plugins (#25317)
Improves startup performance for vercel/front by ~1s
parent
1f9e958e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
plugins.ts
packages/next/build/webpack/config/blocks/css/plugins.ts
+20
-3
No files found.
packages/next/build/webpack/config/blocks/css/plugins.ts
View file @
7035a036
...
@@ -42,6 +42,23 @@ function isIgnoredPlugin(pluginPath: string): boolean {
...
@@ -42,6 +42,23 @@ function isIgnoredPlugin(pluginPath: string): boolean {
return
true
return
true
}
}
const
createLazyPostCssPlugin
=
(
fn
:
()
=>
import
(
'postcss'
).
AcceptedPlugin
):
import
(
'postcss'
).
AcceptedPlugin
=>
{
let
result
:
any
=
undefined
const
plugin
=
(...
args
:
any
[])
=>
{
if
(
result
===
undefined
)
result
=
fn
()
as
any
if
(
result
.
postcss
===
true
)
{
return
result
(...
args
)
}
else
if
(
result
.
postcss
)
{
return
result
.
postcss
}
return
result
}
plugin
.
postcss
=
true
return
plugin
}
async
function
loadPlugin
(
async
function
loadPlugin
(
dir
:
string
,
dir
:
string
,
pluginName
:
string
,
pluginName
:
string
,
...
@@ -60,13 +77,13 @@ async function loadPlugin(
...
@@ -60,13 +77,13 @@ async function loadPlugin(
if
(
isIgnoredPlugin
(
pluginPath
))
{
if
(
isIgnoredPlugin
(
pluginPath
))
{
return
false
return
false
}
else
if
(
options
===
true
)
{
}
else
if
(
options
===
true
)
{
return
require
(
pluginPath
)
return
createLazyPostCssPlugin
(()
=>
require
(
pluginPath
)
)
}
else
{
}
else
{
const
keys
=
Object
.
keys
(
options
)
const
keys
=
Object
.
keys
(
options
)
if
(
keys
.
length
===
0
)
{
if
(
keys
.
length
===
0
)
{
return
require
(
pluginPath
)
return
createLazyPostCssPlugin
(()
=>
require
(
pluginPath
)
)
}
}
return
require
(
pluginPath
)(
options
)
return
createLazyPostCssPlugin
(()
=>
require
(
pluginPath
)(
options
)
)
}
}
}
}
...
...
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