require('blabla/file.json') does not work #17

oncletom opened this Issue Jan 8, 2013 · 8 comments

3 participants


It seems requiring a JSON file is not a working case of the require shim.
It's called with a relative path, not absolute like explained in your README.

$ webmake index.js dist/tld.js

                throw this.value;
Error: Module '/Users/oncletom/workspace/tld.js/src/rules.json' not found, as required in '/Users/oncletom/workspace/tld.js/index.js'
    at /usr/local/lib/node_modules/webmake/lib/parser.js:159:13
    at Function.exports._onresolve.then (/usr/local/lib/node_modules/webmake/node_modules/deferred/lib/_ext.js:61:14)
    at Object.Deferred.resolve (/usr/local/lib/node_modules/webmake/node_modules/deferred/lib/deferred.js:118:26)
    at dirExists (/usr/local/lib/node_modules/webmake/lib/parser.js:37:7)
    at Object.oncomplete (fs.js:297:15)
$ ls src/
rules-legacy.json rules.json
@medikoo medikoo was assigned Jan 8, 2013

@oncletom json files support was added into Node with v0.6 version, and unfortunately Webmake doesn't support them yet, but it's scheduled for next major update: v0.4


Oh that's nice to know :-)

So far, I deal with concat task to wrap my unique JSON file as a module.
But it causes quite much supplementary work just to make something working… automatically.



It will definitely be added. I'll leave this issue open until we have it with v0.4


I also suggest to support require for YAML files (*.yml and *.yaml). That works exactly as with json, after you do require(js-yaml); in your code.


With new version it would be possible to configure handling of any specific file format. So even if support for *.yml won't be provided out of a box, it'll be straightforward to configure such.

@medikoo medikoo added a commit that referenced this issue May 14, 2013
@medikoo Final configuration providing support for JSON
Million thanks to @puzrin for sponsoring work on Webmake, and making
this feature available sooner than it was initially planned :)

Addresses #17

I've just published version of Webmake (v0.3.16) that provides support for JSON files.
It's highly recommended to upgrade, as it also brings other improvements.

Support for YAML files is possible via webmake-yaml extension

Thanks @puzrin for pushing work on that forward! :)

@oncletom please reopen if you have any issues.

@medikoo medikoo closed this May 15, 2013



I'll do; thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment