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

Closed
oncletom opened this Issue Jan 8, 2013 · 8 comments

3 participants

@oncletom

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

/usr/local/lib/node_modules/webmake/node_modules/deferred/lib/_ext.js:76
                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
@medikoo
Owner

@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

@oncletom

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.

Thanks!

@medikoo
Owner

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

@puzrin

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.

@medikoo
Owner

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
c3da9ba
@medikoo
Owner

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
@puzrin

Thanks

@oncletom

I'll do; thank you!

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