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

core-js降版本 #4

Closed
yali213 opened this issue Jun 3, 2020 · 9 comments
Closed

core-js降版本 #4

yali213 opened this issue Jun 3, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@yali213
Copy link

yali213 commented Jun 3, 2020

发现项目里面用的是core3,如果我项目需要用core2,请问需要怎么配置呢?

@yali213 yali213 changed the title core-js版本 core-js降版本 Jun 3, 2020
@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

你这是打包新项目还是老项目?

@yali213
Copy link
Author

yali213 commented Jun 3, 2020

老项目

@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

明白了,稍等一下,我刚才试了一下,通过插件的机制去修改有点问题。我修复一下这个bug先。

@yali213
Copy link
Author

yali213 commented Jun 3, 2020

好咧,大佬加油~~~

@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

第一步,安装依赖

npm install @fmfe/genesis-core@0.0.59-alpha.0
npm install @fmfe/genesis-compiler@0.0.59-alpha.0 @babel/runtime-corejs2 -D

第二步,新增babel.ts文件

import { Plugin, BabelConfig } from '@fmfe/genesis-core';

export class BabelPlugin extends Plugin {
    public babel(config: BabelConfig) {
        config.presets.forEach((preset) => {
            if (Array.isArray(preset) && preset[0] === '@babel/preset-env') {
                // 修改 babel 配置
                preset[1].corejs = 2;
            }
        });
    }
}

genesis.dev.ts 和 genesis.build.ts 使用这个插件

ssr.plugin.use(BabelPlugin);

@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

你看看能不能解决你的问题。我在本地试了一下ok

@lzxb lzxb added the bug Something isn't working label Jun 3, 2020
@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

相关文档,后续我补上。

@yali213
Copy link
Author

yali213 commented Jun 3, 2020

可以的,已经解决了~

@lzxb
Copy link
Contributor

lzxb commented Jun 3, 2020

👌,有问题随时联系。

@lzxb lzxb closed this as completed Jun 3, 2020
@lzxb lzxb reopened this Jun 8, 2020
@lzxb lzxb closed this as completed Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants