LoginSignup
9
9

More than 5 years have passed since last update.

Babel6 + rollup.jsをやるにあたってちょっとハマった話

Last updated at Posted at 2016-01-27

2016/09/06追記: Babel 6.13以上より、presetsのオプションとして、modules指定ができるようになったため、babel-preset-es2015-rollupは不要になったようです。
詳しくはrollup-plugin-babelをご確認下さい


ちょっと調べれば良い事だけどちょっとハマったのでメモ

発端

とりあえずbabel公式ページのrollupのinstallにしたがってみたがどうにもうまくいかない

何が起きたか?

It looks like your Babel configuration specifies a module transformer. Please disable it. If you're using the "es2015" preset, consider using "es2015-rollup" instead. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information
Error: It looks like your Babel configuration specifies a module transformer. Please disable it. If you're using the "es2015" preset, consider using "es2015-rollup" instead. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information

こんなエラーが。

解決

結局babel-preset-es2015-rollupが必要ということだった。

$ npm install rollup -D
$ npm install rollup-plugin-babel -D
$ npm install babel-preset-es2015-rollup -D # これが必要

babelの設定もあわせてこんな感じで行う

package.json
    :
  "babel": {
    "presets": [
      "es2015-rollup"
    ]
  },
   :

あとはrollupの設定

rollup.config.js
import babel from "rollup-plugin-babel"
export default {
  entry: "src/index.js",
  dest: "dest/index.js",
  plugins: [babel()]
}

うまくいった!

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9