banli17 / note

学习记录
https://banli17.github.io/note/docs/intro
MIT License
17 stars 2 forks source link

写一个 rollup-plugin-babel 插件 #81

Open banli17 opened 2 years ago

banli17 commented 2 years ago
import babel from "@babel/core";
export default function (config) {
  // 插件配置参数
  console.log("config", config);

  return {
    name: "my-babel",
    watchChange(){
      console.log('watchChange')
      // process.exit()
    },
    async transform(code, id) {
      const result = await babel.transformAsync(code, {
        // presets: ["@babel/preset-env"],
      });
      console.log(result)
      return result;
    },
  };
}