0

I am referring to the below blog link and have a very specific question;

https://simplabs.com/blog/2017/02/13/npm-libs-in-ember-cli.html

I am referring to the section "npm dependencies"

Basically this is a host app trying to use a child addon & it's dependencies ("moment" library shown for example). So if the child addon is defining "moment" as a "dependency" (not "devDependencies"), would the host app not just install "moment" & work fine ?

Why are the additional steps shown for the resolver algorithm needed ? So essentially what is the purpose of the following additional code shown on that page;

var momentTree = new Funnel(path.dirname(require.resolve('moment/moment.js')), {
  files: ['moment.js'],
});
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
  • `Since npm deduplicates packages during installation we can not be certain about the path where moment is actually installed though. We need to use a resolver algorithm to find the file inside the node_modules folder. Fortunately Node.js has that algorithm built-in and we can just use it through the require.resolve() function. All we have to do now is modify the momentTree code like this:` -> The paragraph right above the code snippet you shared – Patsy Issa Oct 22 '18 at 12:34
  • I did read that actually...But can you elaborate more on that in the context of a parent/host app & a child addon/engine.. – copenndthagen Oct 22 '18 at 17:10

0 Answers0