webpack-contrib / json-loader

json loader module for webpack - UNMAINTAINED

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: text.forEach is not a function

HairyRabbit opened this issue · comments

Hi, I want to use json-loader with ExtractTextPlugin like this config:

rule: {
  test: /\.json$/,
  loader: ExtractJSON.extract({
    loader: [{
      loader: 'json-loader'
    }]
  })
}

That was throw this error:

ERROR in ./src/index.json
    Module build failed: TypeError: text.forEach is not a function
        at Object.<anonymous> (\node_modules\extract-text-webpack-plugin\loader.js:109:10)
        at Compiler.<anonymous> (\node_modules\webpack\lib\Compiler.js:280:10)
        at \node_modules\webpack\lib\Compiler.js:480:13
        ...

I change the json-loader return value as:

// json-loader/index.js

return "module.exports = " + '`' + JSON.stringify(value, undefined, "\t") + '`' + ";";

It's works fine, but I think it's not a good idea. Anything help for this problem ?

Thanks :)

I'm having the exact same problem and changing the return statement as stated above works for me aswell.

@GijsGoudzwaard @yuffiy Mind sending a PR 😛 ?