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

import 进来的包 没有过babel吗? #1719

Closed
Zahariel1942 opened this issue Dec 27, 2018 · 6 comments
Closed

import 进来的包 没有过babel吗? #1719

Zahariel1942 opened this issue Dec 27, 2018 · 6 comments
Labels
question Further information is requested

Comments

@Zahariel1942
Copy link

问题描述
构建H5,引入了一个包, 他里面有 => 箭头方法。 构建出来的H5中直接引进来了。 导致在某些环境下无法运行。

//app.tsx
import * as test from "testpackage";

//testpackage
module.exports = {
  arrow: () => 20,
  assign: function(a, b) {
    return Object.assign(a, b);
  }
};


// dist/js/app.js 中的相关代码
  function(e, t, n) {
    "use strict";
    e.exports = {
      arrow: () => 20,
      assign: function(e, t) {
        return Object.assign(e, t);
      }
    };
  }

期望行为
引入的包也es5ify

@taro-bot
Copy link

taro-bot bot commented Dec 27, 2018

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@luckyadam
Copy link
Member

config/index.jsweapp.compile 配置里加上 include 这个配置,里面写你的 npm 包

weapp: {
  compile: {
    include: []
  }
}

@luckyadam luckyadam added question Further information is requested answered labels Dec 27, 2018
@Zahariel1942
Copy link
Author

Zahariel1942 commented Dec 27, 2018

config/index.jsweapp.compile 配置里加上 include 这个配置,里面写你的 npm 包

weapp: {
  compile: {
    include: []
  }
}

我加在 h5里了,但是并没有什么效果。 这个是需求taro某个版本号的配置项吗?

  h5: {
    publicPath: '/',
    staticDirectory: 'static',
    module: {
      postcss: {
        autoprefixer: {
          enable: true
        }
      }
    },
    compile: {
      include:[
        'testpackage'
      ]
    }
  }

@luckyadam
Copy link
Member

我加在 h5里了,但是并没有什么效果。 这个是需求taro某个版本号的配置项吗?

H5 的话是这个配置

https://nervjs.github.io/taro/docs/config-detail.html#h5esnextmodules

@taro-bot
Copy link

taro-bot bot commented Dec 27, 2018

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@Zahariel1942
Copy link
Author

resolve

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

No branches or pull requests

2 participants