nar icon indicating copy to clipboard operation
nar copied to clipboard

Unable to NAR when leveraging Semantic-UI or Angular2

Open steve-gray opened this issue 8 years ago • 10 comments

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.

steve-gray avatar Apr 20 '16 11:04 steve-gray

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

h2non avatar Apr 20 '16 11:04 h2non

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.... *

steve-gray avatar Apr 20 '16 11:04 steve-gray

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.

steve-gray avatar Apr 20 '16 11:04 steve-gray

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

h2non avatar Apr 20 '16 12:04 h2non

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.

steve-gray avatar Apr 20 '16 13:04 steve-gray

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

steve-gray avatar May 01 '16 09:05 steve-gray

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 avatar May 01 '16 11:05 h2non

semantic-ui package should be resolved in [email protected]. Try it again upgraging nar.

h2non avatar May 07 '16 23:05 h2non

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?

steve-gray avatar May 07 '16 23:05 steve-gray

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

h2non avatar May 08 '16 00:05 h2non