jaredpalmer / backpack

🎒 Backpack is a minimalistic build system for Node.js projects.
MIT License
4.44k stars 169 forks source link

Should config.resolve.modules be undefined when overriding backpack? #140

Open gitleet opened 5 years ago

gitleet commented 5 years ago

I have a multi nodejs project setup like this:

project1
project2
shared
backpack.config.js
package.json

So I want to be able to reference the shared folder code from within my other projects. To do this I have to add path ./ to the NODE_PATH when I run my project1 for example:

"scripts": {
    "dev:project1": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env 
    DIR=api backpack"
  }

So I need to add the value of NODE_PATH to my resolve modules in the backpack config:

config.resolve.modules.push(nodePath);

Should the config.resolve.modules be undefined at this point? (that is what I am seeing) so I am doing this instead:

  config.resolve.modules = [nodePath];

The reason I am confused is because this other project that uses backpack is a .push call https://github.com/withspectrum/spectrum/blob/alpha/backpack.config.js#L36

When I try the same thing I can see that the modules array is actually undefined.

gitleet commented 5 years ago

Another thing I noticed is that now that I set the modules to [nodePath], when I start my app using

yarn run dev:project1

It only looks in ./node_modules not in ./project1/node_modules

So I didn't append the ./ to the module resolution lookup correctly.

Any tips?

jhalvorson commented 5 years ago

Hey @gitleet, did you ever get this resolved? I'm having the same issue.

schester44 commented 4 years ago

@jhalvorson just create it if it doesn't exist

config.resolve.modules = (config.resolve.modules || []).concat([nodePath])