Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

TypeError: text.forEach is not a function #43

Closed
HairyRabbit opened this issue Feb 10, 2017 · 2 comments
Closed

TypeError: text.forEach is not a function #43

HairyRabbit opened this issue Feb 10, 2017 · 2 comments
Assignees

Comments

@HairyRabbit
Copy link
Contributor

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 :)

@GijsGoudzwaard
Copy link

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

@michael-ciniawsky
Copy link
Member

@GijsGoudzwaard @yuffiy Mind sending a PR 😛 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants