0

I am making my first bable plugin that transforms codes during the development.

This plugin will be used with webpack and should handle multiple files.

I need a way to know when babel or webpack has finished the first compilation and starts the watch mode, so at this point, it transforms code after file changed.

Something like this:

export default function ({types: t}) {
  return {
    visitor: {
      Identifier(path) {
        if(COMPILED_SUCCESSFULLY)
        {
           now transform code if file changed.
        }
      }
    }
  };
}

Looking at documentation there is no event, variable, or function that tells if compilation finished, but surely there must be one! any idea?

cyrus-d
  • 749
  • 1
  • 12
  • 29
  • What qualifies as finished? After all the files are transformed, or just one single file? It would help to know what it is that you're trying to do. There is a `post` callback that you could use for the compilation of a single file. – loganfsmyth Mar 30 '20 at 23:53
  • Thanks for the suggestion, as you have mentioned I could use `post` for a single file, but I am dealing with multiple files, I am using this plugin with webpack which will handle compiling multiple files and starts watch mode, at this point, I want to start transforming changed files. – cyrus-d Mar 31 '20 at 07:38

0 Answers0