-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for resolving modules with context within monorepos #95
Comments
@Rugvip very good point. Will add this as an option (in order not to break current |
@Rugvip , just curious, is your workaround intended to fix errors like this?
|
@uccmen No, although it's not impossible there are situations where the workaround would resolve that error just due to the dependency graph being changed. |
Imo, you are also able to use https://github.com/liady/webpack-node-externals#optionsadditionalmoduledirs- |
additionalModuleDirs doesn't fix this problem. The workaround provided by Rugvip does. |
External dependencies seem to always be resolved from the context of the entrypoint package rather than the package that imports the external dependencies.
For example consider
In this case we'll be resolving
'express'
from the context of something likepackages/main/dist/main.js
, assumingmain
is the package where we set up the webpack build. Ifa
happens to have its own version of express installed atpackages/a/node_modules/express
, that may end up not being used in favor of one installed in themain
package or in the rootnode_modules
.A possible way to fix this is to pass the
context
to theimportType
option to allow a custom resolution logic to be set up, but it could also be something to build into this library either as an option or by default.See the workaround here for more context: https://github.com/backstage/backstage/blob/d7f30a800db6e0dcee5de1a08b9ed88428dfe573/packages/cli/src/lib/bundler/config.ts#L312
The text was updated successfully, but these errors were encountered: