igorklopov / enclose

Compile your Node.js project into an executable
http://enclosejs.com
Other
936 stars 43 forks source link

Missing require() dependencies (JSON files) #2

Closed simast closed 9 years ago

simast commented 9 years ago

It seems require(...) calls that don't use simple strings as a module path are not resolved (and not included in the generated binary).

Example:

var jsPath = "../some/path/";
var jsModule = require(jsPath + "test");

Will throw an unhandled path not found exception. Is there any known workaround for including dependencies that cannot be referenced with plain strings? Could I use the --config option and scripts callback as a workaround? The docs are a bit lacking on the config option right now, not sure how to approach this.

igorklopov commented 9 years ago

I have just added new example for you how to use "scripts" from config. https://github.com/igorklopov/enclose/tree/master/examples/31-scripts - Please look through it. In your case you should add ../some/path/test to "scripts". Or even ../some/path/**/*.js

igorklopov commented 9 years ago

The docs are lacking indeed - i will finish them soon.

simast commented 9 years ago

Thank you for the example, however, I did forget to mention that the scripts I am trying to include are actually .json and not .js files. Node.js require supports loading JSON files, but with the scripts directive I get the following error during the compilation process:

{ stage: 'parsing source file',
  file: '/path/to/some.json',
  directory: '/path/to' }
undefined:0
igorklopov commented 9 years ago

Please update to recent enclose 0.0.17. It seems to gather JSON files properly.

simast commented 9 years ago

I had a look at the latest version and noticed another issue with paths that have relative .. directories. Please see this example project where the data.json file is not resolved: https://drive.google.com/file/d/0B-ZXYfeVKweHUGdIek1QdW5Fcms/view?usp=sharing

Run npm install and then node compile.js.

igorklopov commented 9 years ago

I fixed your dataPath bug. Please update to enclose@0.2.1 and try again

simast commented 9 years ago

It works now - thanks! Although I spotted another minor issue with argv - will open a new bug for this. Thanks for the fix.