-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat: pha 源码链路 #507
feat: pha 源码链路 #507
Conversation
examples/with-rax-pha/README.md
Outdated
@@ -0,0 +1,3 @@ | |||
# with rax mpa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
examples/with-rax-pha/README.md
Outdated
@@ -0,0 +1,3 @@ | |||
# with rax mpa | |||
|
|||
https://github.com/ice-lab/icejs/tree/master/examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
地址改下吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
examples/with-rax-pha/build.json
Outdated
{ | ||
"targets": ["web"], | ||
"web": { | ||
"mpa": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mpa 的配置去掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
examples/with-rax-pha/package.json
Outdated
@@ -0,0 +1,22 @@ | |||
{ | |||
"name": "with-rax", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with-rax-pha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/plugin-rax-pha/src/index.js
Outdated
}); | ||
|
||
onGetWebpackConfig(target, (config) => { | ||
function setEntry(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数单独放个文件吧,放这里有点不好看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/plugin-rax-pha/src/index.js
Outdated
.add(appWorkerPath) | ||
.end() | ||
.output | ||
.path(path.resolve(rootDir, outputDir, 'web')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outputDir 在 onGetWebpckConfig 的回调里拿吧,这里拿的是最新的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/plugin-rax-pha/src/index.js
Outdated
.end() | ||
.devServer | ||
.inline(false) | ||
.hot(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pha 不需要 hot reload 吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
能力还没实现
packages/plugin-rax-pha/src/index.js
Outdated
.end() | ||
.output | ||
.path(path.resolve(rootDir, outputDir, 'web')) | ||
.filename('[name].js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里默认就是 [name].js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (config.plugins.has('CopyWebpackPlugin')) { | ||
config.plugin('CopyWebpackPlugin').tap(() => { | ||
return [ | ||
[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该只用去除 public 那个吧,如果用户有别的需要复制的,会挂掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
都不需要 copy 吧,copy 也是在 web target,不是 pha target
packages/plugin-rax-pha/src/index.js
Outdated
}); | ||
// app.json to manifest.json | ||
config.plugin('ManifestJSONPlugin') | ||
.use(class ManifestJSONPlugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
插件代码单独抽出去吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const { userConfig, rootDir } = context; | ||
const { outputDir = 'build' } = userConfig; | ||
|
||
const appWorkerPath = path.resolve(rootDir, 'src/pha-worker' + (type === 'ts' ? '.ts' : '.js')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.resolve
如果不存在的情况下是不是会异常
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path 只是字符串拼接, 不存在 io 操作; fs 里面有可能 IOException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ClarkXia 下面有 pathExist 的判断
packages/plugin-rax-pha/src/index.js
Outdated
|
||
onGetWebpackConfig(target, (config) => { | ||
setEntry(context, config, 'ts'); | ||
setEntry(context, config, 'js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两次 setEntry 理解上有点奇怪,可以内部消化掉 ts/js 文件逻辑
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* chore: bump version * feat: pha 源码链路 (#507) * chore: code lint * chore: add address npm * chore: code refactor * chore: fix test * chore: version back * chore: setEntry code optimization Co-authored-by: boiawang <zhengwang.z@alibaba-inc.com> Co-authored-by: 狒狒神 <fushen.jzw@alibaba-inc.com> * feat: support mock (#506) * fix: chunk load (#505) * fix: chunk load * chore: add comment * feat: add dev info to temp file (#511) * feat: support specified targets (#508) * feat: support specified targets * feat: add cancel task * fix: entry * chore: rename cli targets * feat: add compiled time (#515) * chore: bump version (#514) * chore: bump version * chore: bump beta version * chore: bump version Co-authored-by: 岭伊 <zhengwang2314@gmail.com> Co-authored-by: boiawang <zhengwang.z@alibaba-inc.com>
#444
build.json 配置