sonatype-nexus-community / copy-modules-webpack-plugin

A Webpack plugin which copies module sources to a separate directory
Apache License 2.0
18 stars 7 forks source link

Angular does not build anymore - v2.2.0 #25

Closed deleonio closed 3 years ago

deleonio commented 3 years ago

Sorry - this case I does not test before - I checked it with my react or preact projects.

But: https://github.com/deleonio/poc-flexible-web-application-architecture/actions/runs/464487469

Angular does not build anymore - but I dont know why.

If I remove the plugin the build works.

Reproduce:

mkdir demo
cd demo
npm i @leanup/cli@next @leanup@cli-angular@next --no-save
npx angular create
npm run build

Remove plugin (node_modules\@leanup\stack-webpack\lib\webpack.config.js):

            plugins: [
                // new CopyModulesWebpackPlugin({
                //     destination: '.reports/nexus-iq',
                //     includePackageJsons: true,
                // }),
                new ESBuildPlugin(),
            ],
rpokorny commented 3 years ago

In the angular 9 example project that I have access to, I have just tried upgrading copy-modules-webpack-plugin to v2.2.0 and rebuilding and it had no issue. This may be a problem in your leanup code or somewhere else.

deleonio commented 3 years ago

@rpokorny

That sounds good. Is it possible for your to share the relevant parts of your webpack.config.js with us?

rpokorny commented 3 years ago

You can see the setup here: https://github.com/hboutemy/angular9-example-app . It uses @angular-builders/custom-webpack:browser and the actual webpack config is quite simple, containing only the copy-modules-webpack-plugin settings.

deleonio commented 3 years ago

Hi @rpokorny,

we does not use the Angular CLI - we use for the angular framework the @ngtools/webpack Webpack plugin. The @leanup Stack seeks to be as uniform as possible across all frameworks.

I have invest somt time to debug the issue. I see that the files extension is in the emit method "JS" instead "TS". So all src files are not found.

image

image

The big question is - why is that different by @angular to all other frameworks.

deleonio commented 3 years ago

Exact the same index.js module file for copy-modules-webpack-plugin for @facebook react.

No warnings and no errors.

image

rpokorny commented 3 years ago

I have investigated this by checking out the demo project here and making some tweaks. From what I can tell, angular adds non-existent paths to the fileDependencies collection, but also keeps all of the relevant real paths in the collection. This means that all we need to do is check for file existence before calling lstat in order to avoid the error. I have created a PR which does that, please let me know if those changes work for you.

rpokorny commented 3 years ago

@deleonio since you mentioned in #27 that you were using Angular 11 along with @ngtools/webpack, I have attempted to create a demo project that follows that setup in the hopes of reproducing the issue. You can find that repo here: https://github.com/rpokorny/angular-11-playground. Unfortunately, I was not able to reproduce. That demo project builds successfully, in the sense that webpack reports no errors and the copy-modules-webpack-plugin does run and copy files as expected. Could you take a look and see what difference between that repo and your work might explain the difference in behavior? One thing I notice is that the file which you show triggering the error, angular.main.ts, does not exist in the starter-app files that I generated in my repo using ng new. Where did your angular.main.ts file come from? FWIW that repo uses webpack 5. What webpack version were you using?

rpokorny commented 3 years ago

Closing as unable to reproduce