Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using json-loader, require(file.json) is broken for server-only libs #36

Closed
happypoulp opened this issue Dec 8, 2015 · 2 comments

Comments

@happypoulp
Copy link

Hi,

I got this error when using json-loader + express:

[webpack-isomorphic-tools] [error] asset not found: ./~/statuses/codes.json
/app/node_modules/statuses/index.js:7
status.codes = Object.keys(codes).map(function (code) {
                      ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at Object.<anonymous> (/app/node_modules/statuses/index.js:7:23)
    at Module._compile (module.js:435:26)
    at Module._extensions..js (module.js:442:10)
    at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-core/lib/api/register/node.js:214:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/app/node_modules/http-errors/index.js:2:16)

It seems that webpack-isomorphic-tools new require is trying to handle resources that are only used server-side (like express).

Here is the webpack-isomorphic-tools config that I use:

export default {
  debug: true,
  assets: {
    json: {
      extensions: ['json']
    },
    svg: {
      extensions: ['svg']
    },
    scss: {
      extensions: ['scss']
    },
  }
}

Thanks.

@catamphetamine
Copy link
Owner

Yes, you should narrow down your "json" extension scope.
See include and exclude asset type parameters.
https://github.com/halt-hammerzeit/webpack-isomorphic-tools#configuration

@happypoulp
Copy link
Author

Good to know, thanks a lot!

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

No branches or pull requests

2 participants