aurelia / webpack-plugin

A plugin for webpack that enables bundling Aurelia applications.
MIT License
90 stars 36 forks source link

Multi project builds with shared config #115

Closed ckotzbauer closed 7 years ago

ckotzbauer commented 7 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: Multi project builds with shared configs are not possible. Like described here: https://stackoverflow.com/questions/44428239/aurelia-multi-project-build-with-webpack

Addition: Cause of the peer-dependency of this plugin to webpack it is not possible to install this plugin in each project.

Expected/desired behavior: This plugin can resolve app entrypoints in other directories too.

jods4 commented 7 years ago

Let's copy your points from the link:

this.root in GlobDependenciesPlugin points to the current cwd of the node process, which is the build folder (there is no way to configure the value)

Is there a reason you don't run the command from the right folder and/or modify cwd as part of your build? That might help with other issues below.

only the last "node_modules" folder in the modules array from the config is used for searching. The others are filtered out, cause of relative paths.

I am not 100% sure I understand, do you have a specific example? Also note that module resolution is done by Webpack, so that might be a Webpack issue?

Cause of the peer-dependency of this plugin to webpack it is not possible to install this plugin in each project.

Because Webpack would be in a parent folder node_modules or inside build/node_modules? The first should work and if it doesn't that's an invalid NPM/Yarn warning I think. The latter would not work given how node_modules are scanned -- or I missed a point?

ckotzbauer commented 7 years ago

The reason for the directory change was, that the webpack loaders could not be resolved if the execution directory was not the build directory. I fixed this with the resolveLoaders option from webpack now, so the change of the execution directory is not necessary anymore. That took me a big step forward.

But to clarify:

modules: [`${projectDir}/app`, `${projectDir}/node_modules`, "node_modules"]

The first and second folder in this array pointed to folders in the specific project directory which is not a subfolder of the build folder (the execution directory). This applies only to the last folder. The other ones are filtered out here.

Webpack would be inside build/node_modules, so not a parent of the project directories.

I think this could be closed for now, cause there's no known bug in the plugin related to this. My projects are not fully runnable yet, but this is unrelated to this issue. Thanks for your fast help. 👍

jods4 commented 7 years ago

modules is a first and foremost a Webpack option to configure module resolution (folders where Webpack looks for absolute module names). It would not work with a relative path that's not in the execution path, but you should try absolute paths.

modules is also used by Aurelia plugin to normalize runtime module ids, but I think that should work with absolute paths.

If you can get everything working except specific plugins that lack flexibility, let me know. For example, if it would really be useful to add a cwd option to GlobDependenciesPlugin, I can do it.