I'm trying to implement a node module which should be installable on another module and be responsible to bundle it into a react app for me. (similar to create react app)
A simplified proof of concept can be found here
example
is an hello world module.
example
depends from bundler
which uses webpack
+babel
to bundle example
into an app.
Currently running npm run build
on example
results into an error as webpack
is not able to resolve react
and react-dom
which are transitive dependencies present in bundler
Running npm run build
on example
works as intended if bundler
is installed via an npm pack instead of a local path such as
"devDependencies": {
"bundler": "../bundler"
}
because during the installation npm lifts the transitive dependencies inside example/node_module
(this doesn't happen when installing from a local path like I currently do)
I'm aware I could add the following config to webpack to "fix the issue":
resolve: {
modules: [
'node_modules',
'node_modules/bundler/node_modules'
],
},
But in my opinion this is not a real solution because if example
depends on another local module example2
webpack would then fail to resolve transitive dependencies coming from example2
and another resolve.modules
entry would need to be added.
Is there a way to make this work keeping the modules separate and not nested?