build: reduce package size (#18517)

This commit is contained in:
Bjorn Lu 2024-10-30 13:07:32 +08:00 committed by GitHub
parent 192d555f88
commit b83f60b159
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 86 deletions

View File

@ -103,8 +103,7 @@
},
"patchedDependencies": {
"http-proxy@1.18.1": "patches/http-proxy@1.18.1.patch",
"sirv@3.0.0": "patches/sirv@3.0.0.patch",
"acorn@8.14.0": "patches/acorn@8.14.0.patch"
"sirv@3.0.0": "patches/sirv@3.0.0.patch"
},
"peerDependencyRules": {
"allowedVersions": {

View File

@ -448,33 +448,6 @@ Repository: git+https://github.com/sapphi-red/artichokie.git
---------------------------------------
## astring
License: MIT
By: David Bonnet
Repository: https://github.com/davidbonnet/astring.git
> Copyright (c) 2015, David Bonnet <david@bonnet.cc>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------
## braces, fill-range, is-number, micromatch
License: MIT
By: Jon Schlinkert, Brian Woodward, Elan Shanker, Eugene Sharygin, hemanth.hm
@ -1490,10 +1463,10 @@ Repository: vercel/ms
---------------------------------------
## object-assign, pify
## object-assign
License: MIT
By: Sindre Sorhus
Repositories: sindresorhus/object-assign, sindresorhus/pify
Repository: sindresorhus/object-assign
> The MIT License (MIT)
>
@ -1906,34 +1879,6 @@ Repository: https://github.com/TrySound/postcss-value-parser.git
---------------------------------------
## read-cache
License: MIT
By: Bogdan Chadkin
Repository: git+https://github.com/TrySound/read-cache.git
> The MIT License (MIT)
>
> Copyright 2016 Bogdan Chadkin <trysound@yandex.ru>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of
> this software and associated documentation files (the "Software"), to deal in
> the Software without restriction, including without limitation the rights to
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
> the Software, and to permit persons to whom the Software is furnished to do so,
> subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
## readdirp
License: MIT
By: Thorsten Lorenz, Paul Miller

View File

@ -43,7 +43,17 @@ const clientConfig = defineConfig({
const sharedNodeOptions = defineConfig({
treeshake: {
moduleSideEffects: 'no-external',
moduleSideEffects(id, external) {
// These nested dependencies should be considered side-effect free
// as it's not set within their package.json
if (
id.includes('node_modules/astring') ||
id.includes('node_modules/acorn')
) {
return false
}
return !external
},
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
},
@ -133,13 +143,18 @@ const nodeConfig = defineConfig({
},
],
// postcss-import uses the `resolve` dep if the `resolve` option is not passed.
// However, we always pass the `resolve` option. Remove this import to avoid
// bundling the `resolve` dep.
// However, we always pass the `resolve` option. It also uses `read-cache` if
// the `load` option is not passed, but we also always pass the `load` option.
// Remove these two imports to avoid bundling them.
'postcss-import/index.js': [
{
src: 'const resolveId = require("./lib/resolve-id")',
replacement: 'const resolveId = (id) => id',
},
{
src: 'const loadContent = require("./lib/load-content")',
replacement: 'const loadContent = () => ""',
},
],
'postcss-import/lib/parse-styles.js': [
{

View File

@ -1,12 +0,0 @@
diff --git a/package.json b/package.json
index 795cf83eff64d757a9c9d5283230f20a3964c06f..4fb82701406e05017adbd9de5b497cfee0be7eef 100644
--- a/package.json
+++ b/package.json
@@ -46,5 +46,6 @@
},
"bin": {
"acorn": "bin/acorn"
- }
+ },
+ "sideEffects": false
}

View File

@ -10,9 +10,6 @@ overrides:
packageExtensionsChecksum: 632c5477927702fb9badd3e595784820
patchedDependencies:
acorn@8.14.0:
hash: d727lkisx442fz7p2mupxdcooa
path: patches/acorn@8.14.0.patch
http-proxy@1.18.1:
hash: qqiqxx62zlcu62nljjmhlvexni
path: patches/http-proxy@1.18.1.patch
@ -213,7 +210,7 @@ importers:
devDependencies:
acorn:
specifier: ^8.14.0
version: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
version: 8.14.0
picocolors:
specifier: ^1.1.1
version: 1.1.1
@ -9128,15 +9125,15 @@ snapshots:
mime-types: 2.1.35
negotiator: 0.6.3
acorn-jsx@5.3.2(acorn@8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)):
acorn-jsx@5.3.2(acorn@8.14.0):
dependencies:
acorn: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
acorn: 8.14.0
acorn-walk@8.3.2: {}
acorn@7.4.1: {}
acorn@8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa): {}
acorn@8.14.0: {}
add-stream@1.0.0: {}
@ -10044,8 +10041,8 @@ snapshots:
espree@10.2.0:
dependencies:
acorn: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
acorn-jsx: 5.3.2(acorn@8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa))
acorn: 8.14.0
acorn-jsx: 5.3.2(acorn@8.14.0)
eslint-visitor-keys: 4.1.0
esquery@1.6.0:
@ -11108,7 +11105,7 @@ snapshots:
miniflare@3.20241022.0:
dependencies:
'@cspotcode/source-map-support': 0.8.1
acorn: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
acorn: 8.14.0
acorn-walk: 8.3.2
capnp-ts: 0.7.0
exit-hook: 2.2.1
@ -11176,7 +11173,7 @@ snapshots:
mlly@1.7.2:
dependencies:
acorn: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
acorn: 8.14.0
pathe: 1.1.2
pkg-types: 1.2.0
ufo: 1.5.4
@ -12417,7 +12414,7 @@ snapshots:
terser@5.36.0:
dependencies:
'@jridgewell/source-map': 0.3.3
acorn: 8.14.0(patch_hash=d727lkisx442fz7p2mupxdcooa)
acorn: 8.14.0
commander: 2.20.3
source-map-support: 0.5.21