-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT MERGE] chore(precompile): reduce the size of precompiled dependencies #58038
Conversation
Failing test suitesCommit: 7ddfe33
Expand output● SCSS Support loader handling › production mode › Data Urls › should compile successfully
● SCSS Support loader handling › production mode › Data Urls › should've emitted expected files
Read more about building and testing Next.js in contributing.md. |
Stats from current PRDefault BuildGeneral
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
Next Runtimes
|
find-cache-dir
476df3d
to
04eb4d5
Compare
a3caaed
to
04785e7
Compare
What's the after size? I think the watch pack one might be an oversight and we should re use the pre compiled one |
The final installation size reduction can be seen from the PR stats,
I can bring it up in the PR. This should help reduce the installation size further. Edit: The pre-compiled watchpack is now back. |
It seems that somehow |
@SukkaW If its easier - you could split this up into a few PRs:
|
Per @styfle suggestion, #58038 has been split into multiple PRs for easier review. - Remove `find-cache-dir` - The usage of `find-cache-dir` was removed **4 years ago** (#7013) but the dist and the build script were never removed. - Remove `@segment/ajv-human-errors` - The usage of `@segment/ajv-human-errors` was removed in #56383 by me. Though the build script was also removed in that PR, the dist never got removed.
Per @styfle suggestion, #58038 has been split into multiple PRs for easier review. - Re-add precompile `watchpack` - Next.js has stopped bundling the `watchpack` since #50792. Currently, `watchpack` is a direct dependency of Next.js. The PR adds the pre-compile back. Co-authored-by: Steven <[email protected]>
Per @styfle suggestion, #58038 has been split into multiple PRs for easier review. - Remove `chalk` inside `@next/react-dev-overlay` - `@next/react-dev-overlay` is bundled with Next.js. The usage of `chalk` inside `@next/react-dev-overlay` was not removed in #55992, thus the `chalk` is still being shipped. --------- Co-authored-by: JJ Kasper <[email protected]>
All the subsequent PRs have been merged. The PR can be closed. |
The PR continues from #58038 aiming to reduce the installation size further, and **improve performance in doing so**. Most of `micromatch`'s APIs are essentially wrappers/alias of `picomatch`, supplemented with additional features facilitated by a transitive dependency `braces`. However, Next.js doesn't use those "extra features". Switching from `micromatch` to `picomatch` can avoid introducing the transitive dependency `braces`. The PR also improves some globs' performance by hoisting. - `micromatch.makeRe` is just an alias of `picomatch.makeRe` - https://github.com/micromatch/micromatch/blob/90dc0cd3e186b8ab4dd05bfc41e2b98f5067a49b/index.js#L387C30-L387C30 - `micromatch.isMatch(str, patterns, options)` equals `picomatch(patterns, options)(str)` - https://github.com/micromatch/micromatch/blob/90dc0cd3e186b8ab4dd05bfc41e2b98f5067a49b/index.js#L123 - `micromatch.matcher` is just an alias of `picomatch` - https://github.com/micromatch/micromatch/blob/90dc0cd3e186b8ab4dd05bfc41e2b98f5067a49b/index.js#L104C1-L104C40 --------- Co-authored-by: Sam Ko <[email protected]>
The PR addresses https://twitter.com/hazae41/status/1720557445678858248.
Currently, The installation size of the
next
package is at 73.6 MiB. Among 53 MiB of them are precompiled dependencies.The PR attempts to reduce that size by removing unused ones:
Removechore(precompile): remove obsolete precompiled assets #60316find-cache-dir
find-cache-dir
was removed 4 years ago (Switch to using.next/cache
for flying shuttle and terser #7013) but the dist and the build script were never removed.Removechore(precompile): remove obsolete precompiled assets #60316@segment/ajv-human-errors
@segment/ajv-human-errors
was removed in refactor: rewrite config schema in zod #56383 by me. Though the build script was also removed in that PR, the dist never got removed.Remove Re-add precompilechore(precompile): re-addwatchpack
watchpack
to the precompile #60309watchpack
since Improve compile time on large application #50792. Currently,watchpack
is a direct dependency of Next.js,but the type never got updated and the pre-compiled dist never got removed.the PR adds the pre-compile back.Enable minification ofchore(font): enable minification #60319@next/font
@next/font
is bundled with Next.js.Removerefactor(dev-overlay): removechalk
inside@next/react-dev-overlay
chalk
#60317@next/react-dev-overlay
is bundled with Next.js. The usage ofchalk
inside@next/react-dev-overlay
was not removed in chore: remove chalk in favor of picocolors #55992, thus thechalk
is still being shipped.schema-utils2
andwebpack-sources1
schema-utils@2
andwebpack-sources@1
were only used in webpack 4. After webpack 4 was dropped, they were no longer necessary.loader-utils2
saas-loader
no longer usesloader-utils
whileresolve-url-loader
only usesloader-utils.isUrlRequest
. So it is safe to removeloader-utils2
and replace its usage withloader-utils3
.