Skip to content
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

WIP feat: support vue #628

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

WIP feat: support vue #628

wants to merge 8 commits into from

Conversation

xierenyuan
Copy link
Member

No description provided.

@@ -1,6 +1,6 @@
#!/usr/bin/env node

require('v8-compile-cache');
// require('v8-compile-cache');
Copy link
Member

Choose a reason for hiding this comment

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

删了吧,引这个会有其他异常

Copy link
Member Author

Choose a reason for hiding this comment

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

是的 昨晚被坑了 1个小时

Copy link
Member

Choose a reason for hiding this comment

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

具体是啥问题?看 Umi 也把这个去掉了

Copy link
Member Author

Choose a reason for hiding this comment

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

无法使用 esm 的包 比如 vite 使用会有问题

Copy link
Member

@xiaohuoni xiaohuoni Apr 20, 2023

Choose a reason for hiding this comment

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

umi 非 dev 的时候,这代码进不去
const { build } = await import("./build.js");

@xiaohuoni
Copy link
Member

这算不算重复做好几次,umi father dumi?

@xierenyuan
Copy link
Member Author

xierenyuan commented Apr 14, 2023

这算不算重复做好几次,umi father dumi?

不是场景不一样, 考虑过共用的问题 成本过高 不过可以做的事情 比如把 babel-preset-vue 维护到 umi

@xiaohuoni
Copy link
Member

babel-preset-vue 是不是可以用 babel-preset-umi 加几个配置?

@@ -5,3 +5,8 @@ export type {
IFatherConfig,
IJSTransformer,
} from './types';

export type {
ILoaderOutput,
Copy link
Member

Choose a reason for hiding this comment

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

导出得加个前缀了,IBundlessLoaderXXX


console.log(dirname(this.paths.fileAbsPath));

const [{ output }] = (await viteBuilder({
Copy link
Member

Choose a reason for hiding this comment

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

所以 Vue 组件的 bundless 构建本质上是对每个 .vue 文件 bundle 再单独输出?这里用 Vite 是生态缘故还是因为快,如果 bundle/bundless 统一用 webpack 会有问题吗

Copy link
Member Author

Choose a reason for hiding this comment

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

这里其实更多是 复用当前架构吧, 复用 father 现在的代码逻辑不做大的变化, 完全用 vite 处理会更简单一点(ps 如果重名的复杂度太高可能会考虑 完成用 vite(rullup) 处理), 用 webpack 其实以没有问题 这里主要考虑还是生态问题 vite 是现在 vue 官方默认的选项 长远来看 可能 vite 更合适

@@ -0,0 +1,43 @@
// MIT: copy from https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/require-hook.ts
Copy link
Member

Choose a reason for hiding this comment

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

这部分逻辑能直接做在 bundler-webpack 里吗

Copy link
Member Author

Choose a reason for hiding this comment

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

bundler-webpack 有这部分逻辑, deps 有细微差异 我晚点在 bundler-webpack 处理看看

@@ -1,6 +1,6 @@
#!/usr/bin/env node

require('v8-compile-cache');
// require('v8-compile-cache');
Copy link
Member

Choose a reason for hiding this comment

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

具体是啥问题?看 Umi 也把这个去掉了

suites/babel-preset-vue/src/index.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,45 @@
import type Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
Copy link
Member

Choose a reason for hiding this comment

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

能否依赖 @umijs/preset-vue 这个包,直接引用里面的 config 逻辑,这样只需要维护一处

Copy link
Member Author

Choose a reason for hiding this comment

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

直接依赖 有成本 如果抽离一个包 共享感觉是一个方案

@fz6m
Copy link
Member

fz6m commented Apr 18, 2023

  1. vue 组件库最好用 rollup 或 vite library 模式,vite 才是 v 生态最好的环境,综合来看 vite library 是最佳实践,自己造一个有点小题大做。

  2. 需要搭配 vue-tsc 生成类型,这里做的比较简陋,有待加强(其实是这里面东西很多,所以建议 vite 😰)

@xierenyuan
Copy link
Member Author

  1. vue 组件库最好用 rollup 或 vite library 模式,vite 才是 v 生态最好的环境,综合来看 vite library 是最佳实践,自己造一个有点小题大做。
  2. 需要搭配 vue-tsc 生成类型,这里做的比较简陋,有待加强(其实是这里面东西很多,所以建议 vite 😰)

哈哈 还没有搞完, 其实是需要封装的 直接用 vite 也需要搞配置(我目前想的是尽量复用 father 的代码)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants