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

feat: pha 源码链路 #507

Merged
merged 7 commits into from
Nov 30, 2020
Merged

feat: pha 源码链路 #507

merged 7 commits into from
Nov 30, 2020

Conversation

boiawang
Copy link
Contributor

#444

build.json 配置

{
  "web": {
    "pha": true
  }
}

@@ -0,0 +1,3 @@
# with rax mpa
Copy link
Contributor

Choose a reason for hiding this comment

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

pha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,3 @@
# with rax mpa

https://github.com/ice-lab/icejs/tree/master/examples
Copy link
Contributor

Choose a reason for hiding this comment

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

地址改下吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
"targets": ["web"],
"web": {
"mpa": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

mpa 的配置去掉?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,22 @@
{
"name": "with-rax",
Copy link
Contributor

Choose a reason for hiding this comment

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

with-rax-pha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

});

onGetWebpackConfig(target, (config) => {
function setEntry(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个函数单独放个文件吧,放这里有点不好看

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

.add(appWorkerPath)
.end()
.output
.path(path.resolve(rootDir, outputDir, 'web'))
Copy link
Contributor

Choose a reason for hiding this comment

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

outputDir 在 onGetWebpckConfig 的回调里拿吧,这里拿的是最新的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

.end()
.devServer
.inline(false)
.hot(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

pha 不需要 hot reload 吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

能力还没实现

.end()
.output
.path(path.resolve(rootDir, outputDir, 'web'))
.filename('[name].js')
Copy link
Contributor

Choose a reason for hiding this comment

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

这里默认就是 [name].js

Copy link
Contributor Author

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 [
[],
Copy link
Contributor

Choose a reason for hiding this comment

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

这里应该只用去除 public 那个吧,如果用户有别的需要复制的,会挂掉

Copy link
Contributor Author

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

});
// app.json to manifest.json
config.plugin('ManifestJSONPlugin')
.use(class ManifestJSONPlugin {
Copy link
Contributor

Choose a reason for hiding this comment

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

插件代码单独抽出去吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

SoloJiang
SoloJiang previously approved these changes Nov 26, 2020
const { userConfig, rootDir } = context;
const { outputDir = 'build' } = userConfig;

const appWorkerPath = path.resolve(rootDir, 'src/pha-worker' + (type === 'ts' ? '.ts' : '.js'));
Copy link
Contributor

Choose a reason for hiding this comment

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

path.resolve 如果不存在的情况下是不是会异常

Copy link
Contributor

Choose a reason for hiding this comment

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

path 只是字符串拼接, 不存在 io 操作; fs 里面有可能 IOException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ClarkXia 下面有 pathExist 的判断


onGetWebpackConfig(target, (config) => {
setEntry(context, config, 'ts');
setEntry(context, config, 'js');
Copy link
Contributor

Choose a reason for hiding this comment

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

两次 setEntry 理解上有点奇怪,可以内部消化掉 ts/js 文件逻辑

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SoloJiang SoloJiang changed the base branch from master to release-next November 30, 2020 03:21
@SoloJiang SoloJiang merged commit 126051c into release-next Nov 30, 2020
@SoloJiang SoloJiang deleted the feat/pha branch November 30, 2020 03:23
@SoloJiang SoloJiang mentioned this pull request Dec 3, 2020
SoloJiang added a commit that referenced this pull request Dec 3, 2020
* 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>
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.

4 participants