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

项目拉下来无法运行需要添加@babel/plugin-proposal-optional-chaining支持 #30

Closed
iceshu opened this issue Feb 25, 2021 · 10 comments

Comments

@iceshu
Copy link

iceshu commented Feb 25, 2021

如题,项目用了ts 的 ?。的方法去做 但是没有支持的插件

image

所以需要在
genesis.ts 里 webpackchai增加下支持

class ChainingPlugin extends Plugin {
    /**
     * 修改webpack的配置
     */
    public chainWebpack({ config }: WebpackHookParams) {
        config.module
            .rule("ts")
            .test(/\.(t)sx?$/)
            .use("babel")
            .loader("babel-loader")
            .tap(options => {
                const { plugins } = options;
                plugins.push(["@babel/plugin-proposal-optional-chaining"]);
                options.plugins = plugins;
                return options;
            })
            .end();
    }
}

//这里增加下刚写的
ssr.plugin.use(new ChainingPlugin (ssr));
@lzxb
Copy link
Owner

lzxb commented Feb 25, 2021

这个是@babel/preset-env的bug导致的。它没有根据当前node的版本号,来引入对应的插件。
你的node的版本号多少?

@lzxb
Copy link
Owner

lzxb commented Feb 25, 2021

你可以看下这个配置:
https://fmfe.github.io/genesis-docs/core/#build-browsers
修改一下node的版本号,降低一些,比如我使用12.6就不会有这个问题。

@lzxb
Copy link
Owner

lzxb commented Feb 25, 2021

奈斯。

@lzxb lzxb closed this as completed Feb 25, 2021
@iceshu
Copy link
Author

iceshu commented Feb 25, 2021

@JWong1105
这里引用的 我的node版本v14.15.1

import { SSR, Renderer, Plugin, WebpackHookParams } from "@fmfe/genesis-core";

@lzxb
Copy link
Owner

lzxb commented Feb 26, 2021

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

No branches or pull requests

3 participants
@iceshu @lzxb and others