jaredpalmer / jaredpalmer/backpack

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

Open
#140 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
164
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start with backpack.config.js and package.json, then inspect how config.resolve.modules is initialized before user overrides are applied. Compare the referenced Spectrum backpack.config.js pattern and run the project command to observe the resulting resolve.modules value. Done means the configuration behavior is clarified and the NODE_PATH use case no longer depends on pushing to an undefined array.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, webpack
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.