Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use both the ES6 loader and the brfs transform in webpack?

I have a big webpack generated ui written in ES6 and I want to add an npm module that uses fs.readFileSync() named lumenize. The package is normally built with browserify. I'm having trouble configuring webpack to use bfrs from inside of ES6 code.

I've tried this configuration:

loaders: [
  "transform?brfs",
  "babel-loader"
],

and reversed the order, but neither works.

I've thought of trying to import the browserified version of the package, but that browserified version exposes a global polyfill for require() for use directly in the browser. I understand that's a no-no for webpack. Is that true? I could fork the project and remove that global exposure, but help with that configuration would be appreciated.

like image 595
Larry Maccherone Avatar asked Oct 19 '22 14:10

Larry Maccherone


1 Answers

Try to put transform in the postLoaders section as it was described in transform-loader Readme:

postLoaders: [
  {
    loader: "transform?brfs"
  }
],
loaders: [
  {
    test: /\.js$/,
    loader: "babel"
  }
]
like image 123
just-boris Avatar answered Oct 21 '22 06:10

just-boris