nar
nar copied to clipboard
Unable to NAR when leveraging Semantic-UI or Angular2
Whenever I create a NAR package that references semantic-ui or angular2 from package.json, I get errors such as:
- Error: Cannot find module 'semantic-ui' from '/Users/steveg/Desktop/workspace/linehaul/linehaul-web'
I suspect that's something inside these two projects particularly that's tripping nar up.
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
What if I did a script-step that went through and scanned for every package.json, and then simply checked for:
- Missing a main-field?
- Create a
.js file in folder. - Set that as the main.
As a pre-step before NAR?
*Caveat: Yes, I know how crappy this is. People are using NPM to ship XML/JSON files.... *
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.
Let check it in detail and I'll give a definitive answer.
Cheers,
In the meantime I've worked around the issue by creating:
- https://github.com/steve-gray/nar/
What I've done is:
- Added the disable-ignorefiles commandline option. It's part of the API but was missing from the CLI spec.
- Hacked out the hardcoded ignoring of node_modules.
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.
Is there any recommendation on a more solid fix? My hacky fork isn't particularly a wise idea.
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.
semantic-ui package should be resolved in [email protected]. Try it again upgraging nar.
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?
I've simply added an resolution path extension in resolve-tree package. This should fix your particular issue.