h2non / nar

node.js application archive - create self-contained binary like executable applications that are ready to ship and run
MIT License
428 stars 23 forks source link

Unable to NAR when leveraging Semantic-UI or Angular2 #135

Open steve-gray opened 8 years ago

steve-gray commented 8 years ago

Whenever I create a NAR package that references semantic-ui or angular2 from package.json, I get errors such as:

I suspect that's something inside these two projects particularly that's tripping nar up.

h2non commented 8 years ago

Seems like those package cannot be resolved via node.js module lookup algorithm. I would have to add some exception for those packages, or ask to the package mintainers to add a 'main' field in package.json

steve-gray commented 8 years ago

What if I did a script-step that went through and scanned for every package.json, and then simply checked for:

As a pre-step before NAR?

__Caveat: Yes, I know how crappy this is. People are using NPM to ship XML/JSON files.... __

steve-gray commented 8 years ago

Ugh, that seems to not work. Is there any way to basically do a 'ignore dependencies' but then also 'include all of the things' - basically a brute force .//.\ glob? I'm getting module load errors when I try something a bit like:

nar create --omit-dependencies -i /.\ -e

Update On further analysis it appears that the ignore-like files option is precluding the node_modules manually being packed in, which then leads to the interesting situation where we're now missing the ability to ignore ignore-like-files.

Is there a quick-and-dirty fix for this? I'm keen to demo NAR with our app tomorrow to someone.

h2non commented 8 years ago

Let check it in detail and I'll give a definitive answer.

steve-gray commented 8 years ago

Cheers,

In the meantime I've worked around the issue by creating:

What I've done is:

Then when it's installed globally, you can use:

nar create -e -l -n

(Executable, disable ignorefiles, dont process dependencies)

This packs the application and works because it basically just vacuums up the whole workspace, including node_modules - it's awful, but will suffice as an interim measure whilst we await a more official solution.

steve-gray commented 8 years ago

Is there any recommendation on a more solid fix? My hacky fork isn't particularly a wise idea.

h2non commented 8 years ago

Sorry for the silence these days. One solution could be as simple as adding an resolution exception here: https://github.com/h2non/resolve-tree/blob/master/index.js#L7-L13

That solution won't be transversal to other similar scenario, but should fix your issue. Regarding to your fork, the CLI flag should be added to nar. Feel free to create a PR if you want.

Additionally, as feature request, I would like to consider supporting the ability to ignore certain dependency packages.

h2non commented 8 years ago

semantic-ui package should be resolved in nar@0.3.37. Try it again upgraging nar.

steve-gray commented 8 years ago

Cheers: Was there something about Angular2 that meant it couldn't get the same lovin' or have they fixed something whilst I wasn't looking?

h2non commented 8 years ago

I've simply added an resolution path extension in resolve-tree package. This should fix your particular issue.