Babel-loader: Final loader didn't return a Buffer or String

Created on 7 Jan 2017  路  7Comments  路  Source: babel/babel-loader

I'm submitting a bug report

Webpack Version:
1.14.0

Babel Core Version:
6.21.0

Babel Loader Version:
6.2.10

Please tell us about your environment:
OSX 10.x

Current behavior:
ERROR in ./example/client/app/app.js
Module build failed: Error: Final loader didn't return a Buffer or String
at DependenciesBlock.onModuleBuild (/Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:299:42)
at nextLoader (/Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
at runSyncOrAsync (/Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:160:12)
at nextLoader (/Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:290:3)
at /Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
at Object.context.callback (/Users/fjywan/wandacode/newfancyui/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
at Object.module.exports (/Users/fjywan/wandacode/newfancyui/node_modules/babel-loader/lib/index.js:134:8)

Expected/desired behavior:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

  • What is the expected behavior?
    babel-loader return a Buffer or String after processing js

Most helpful comment

That error is from ng-annotate and not ng-annotate-loader so I bet you forgot to install ng-annotate-loader, and because the -loader suffix is optional in Webpack 1.x, you are loading the wrong module, rather than getting an error about a missing loader.

npm install --save-dev ng-annotate-loader

All 7 comments

How do you know it is the babel-loader? Please provide more information (babel config, webpack config, ...) or a reproducable case.

babel config:

{
  "presets": ["es2015"]
}

webpack config:

{ devtool: 'sourcemap',
  entry: 
   { vendor: [ 'angular', 'jquery' ],
     app: 
      [ 'webpack-hot-middleware/client?reload=true',
        './example/client/app/app.js' ] },
  module: { loaders: [
      { test: /\.js$/, exclude: [/app\/lib/, /node_modules\/(?!(fancyui)\/).*/], loader: 'ng-annotate!babel' },
      { test: /\.html$/, loader: 'raw-loader' },
      { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
      { test: /\.css$/, loader: 'style-loader!css-loader' },
      // IMAGE
      {
        test: /.(gif|jpg|png)$/,
        loader: 'file?name=img-[hash].[ext]'
      },
      {
        test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
        loader: require.resolve('file-loader')
      }
    ]},
  resolve: { alias: { angular: '/Users/fjywan/node_modules/angular' } },
  plugins: 
   [new HtmlWebpackPlugin({
      template: './example/client/index.html',
      inject: 'body',
      excludeChunks:['vendor'],
      hash: true
    }),

    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }) ],
  output: { filename: '[name].bundle.js',
     chunkFilename: '[name].min.js',
     publicPath: '/',
     path: '/Users/fjywan/w/client' } 
}

babel-loader is present in your stack trace, but you can see several nextLoader calls in the stack trace above it. Babel loader is not the cause here, it is some loader running after babel-loader.

@loganfsmyth { test: /.js$/, exclude: [/app\/lib/, /node_modules\/(?!(fancyui)\/).*/], loader: 'ng-annotate!babel' } does this mean babel is the final loader?

Seems like the easiest way would be to start removing things until you get a different error. I bet you'll still get the same error if you remove !babel from that string.

@loganfsmyth when removed babel loader, i got :

ERROR in ./example/client/app/app.js
Module build failed: TypeError: Cannot read property 'list' of undefined
    at Object.ngAnnotate (/Users/fjywan/wandacode/newfancyui/node_modules/ng-annotate/build/es5/ng-annotate-main.js:1038:16)

That error is from ng-annotate and not ng-annotate-loader so I bet you forgot to install ng-annotate-loader, and because the -loader suffix is optional in Webpack 1.x, you are loading the wrong module, rather than getting an error about a missing loader.

npm install --save-dev ng-annotate-loader
Was this page helpful?
0 / 5 - 0 ratings