mikach / requirejs-babel

An AMD loader plugin for Babel
117 stars 32 forks source link

Usage with Webpack 2 #27

Open crazyjat opened 7 years ago

crazyjat commented 7 years ago

How can I use this and webpack 2? When i bundle my code with Webpack 2 I get the following errors:

'Uncaught Error: Cannot find module "es6!./fdt.datetime.controller"'

Is there a known way to remove the es6! just for webpack?

prantlf commented 2 years ago

You probably face the issue in using an AMD/UMD import among ESM imports. Making the es6 plugin not process the module produced webpack would help. Currently there is no filename-based whitelist, but you can exclude the module in your RequireJS configuration:

config: {
  es6: {
    resolveModuleSource: function(sourcePath, currentFile, options) {
      if (sourcePath is your AMD/UMD module path) return sourcePath;
      return 'es6!' + sourcePath;
    }
  }
}

It is similar to other discussion.