Skip to content

Commit

Permalink
build: reduce package size (#18517)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Oct 30, 2024
1 parent 192d555 commit b83f60b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 86 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
59 changes: 2 additions & 57 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
>
Expand Down Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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': [
{
Expand Down
12 changes: 0 additions & 12 deletions patches/acorn@8.14.0.patch

This file was deleted.

21 changes: 9 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b83f60b

Please sign in to comment.