apigee-127 / sway

A library that simplifies OpenAPI (fka Swagger) integrations/tooling.
MIT License
190 stars 92 forks source link

Cannot compile webpack: ERROR in ./node_modules/sway/lib/validation/validators.js Module not found: Error: Can't resolve 'swagger-schema-official/schema' #180

Closed HuskyMoonMoon closed 6 years ago

HuskyMoonMoon commented 6 years ago

In lib/validation/validators.json at line 31

var swaggerSchema = require('swagger-schema-official/schema');

It seems like this line is preventing webpack to resolve for schema.json file in swagger-schema-official package

I fixed it by add .json to allow webpack to correctly resolve JSON dependency.

var swaggerSchema = require('swagger-schema-official/schema.json');
whitlockjc commented 6 years ago

This is likely a deficiency in webpack as Node.js module loading treats .json files as requirable without the .json extension. The same source base works fine (without modification) in browserify as well. I'm going to close this since it's not something I'll likely change but if you cannot find a way to make webpack work right (configuration, loader, ...) it should be reopened.