Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

perf: pre-bundle deps for bundler-vite #440

Merged
merged 7 commits into from
Mar 10, 2022
Merged

Conversation

PeachScript
Copy link
Member

@PeachScript PeachScript commented Mar 8, 2022

Description

移除不需要的 rollup-plugin-polyfill,且对 bundler-vite 的以下依赖做预打包:

  • @vitejs/plugin-legacy
  • caniuse-lite
  • express
  • less (新增,vite 的 peerDeps 之一,与 bundler-webpack 保持一致默认集成 less)
  • rollup-plugin-copy
  • rollup-plugin-visualizer (类型没声明在 package.json,暂时用了旧版本的 @types/rollup-plugin-visualizer 解决)

效果:
图片

未成功打包的依赖:

  • @svgr/core (types 的类型声明路径有问题,已提 PR fix(core): types path in package.json gregberge/svgr#693 )
  • @vitejs/plugin-react (源码用了动态 import,子依赖没法打包)
  • postcss-preset-env (依赖较复杂,后续和 bundler-esbuild、bundler-webpack 一起处理)

额外增加 bundler-vite/scripts/afterBundleDeps.ts 做后置任务:

  1. 根据 externals 规则生成 @umijs/bundler-utils@umijs/utils 中预打包产物的类型映射,解决 bundler-vite 预打包类型声明产物中 external 的包 import 不到的问题
  2. 手动拷贝 vite client 脚本的 sourcemap 文件到预打包产物里

@vercel
Copy link

vercel bot commented Mar 8, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/umijs/umi-next/BiiL83VBi6HqqsT7isDoL1DbhM1L
✅ Preview: https://umi-next-git-feature-bundler-vite-deps-umijs.vercel.app

@PeachScript PeachScript requested a review from sorrycc March 8, 2022 06:45
@@ -0,0 +1,30 @@
import fs from 'fs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1 @@
export * from '@umijs/bundler-utils/compiled/esbuild';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥会有 esbuild.d.ts 和 fs-extra.d.ts?这两个文件不像自动打出来的。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afterBundleDeps.ts 输出的,为了解类型 external 的问题,在 PR 描述里有做说明

@sorrycc sorrycc merged commit a42328f into master Mar 10, 2022
@delete-merged-branch delete-merged-branch bot deleted the feature/bundler-vite-deps branch March 10, 2022 06:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Umi 4 RC
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

2 participants