aurelia / loader-webpack

An implementation of Aurelia's loader interface to enable webpack.
MIT License
26 stars 9 forks source link

causes webpack to source every module in node_modules/package.json and my project whether it is used by my code (as in transitively included by an entrypoint) or not. #24

Closed insidewhy closed 7 years ago

insidewhy commented 8 years ago

In my package.json (and therefore node_modules) I have dependencies for the front-end and the back-end. When I run webpack using the config from the esnext skeleton I get a lot of errors like this:

<snip>
    large error about webpack's inability to deal with a commonjs
    feature in `express-static/index.js` here ...
</snip>
 @ ./~/express-static/index.js
 @ ./client ^\.\/.*$
 @ ./~/aurelia-loader-webpack/dist/commonjs/aurelia-loader-webpack.js

Something in aurelia-loader-webpack.js pulls in every single dependency listed in my package.json and/or node_modules?

insidewhy commented 8 years ago

Looks related to:

insidewhy commented 8 years ago

I had to make config.externals a list of every server-side only package. Not sure why this is necessary... would have though webpack would know exactly which modules the client is using.

insidewhy commented 8 years ago

It includes every module in package.json and in my project. I was surprised to see a module that wasn't transitively reachable from any entrypoint end up in my build.

I'm convinced now that the way loader-webpack works is by taking every accessible module, whether from node_modules or my source directories. Could you explain why this is the case? In every other webpack project I've been using only modules that are actually used are included in the bundles.

niieani commented 8 years ago

This will soon be fixed. Stay tuned.

sebastien-roch commented 8 years ago

@niieani any news on this? I added a d.ts file in my project and webpack tries to load it, which fails of course because no loader takes care of this kind of files. Thanks!

niieani commented 8 years ago

@sebastien-roch this will be fixed by https://github.com/aurelia/skeleton-navigation/issues/714. PR is ready, so it's a matter for days before you can use it.

sebastien-roch commented 8 years ago

@niieani thanks for the update, looking forward to this merge. For now do you have any workaround to handle those *.d.ts files? Is there currently a way to exclude them from bundling?

niieani commented 8 years ago

Hmm, you could move them our of the src directory, that should help.

sebastien-roch commented 8 years ago

I thought there would be a better workaround ;-) Will try that for now, thanks!

mredbishop commented 7 years ago

Is this PR in yet? This is a real pain if we need to manually track the externals.

Can I help at all in testing, coding or reviewing this as we would really benefit from it?

Cheers,

Ed

peterver commented 7 years ago

I can confirm that the 2.0.0 release works perfectly :] thank @niieani !

I know this is speaking of a different repo, but for people using https://github.com/aurelia/bootstrapper-webpack/, the issue will remain until https://github.com/aurelia/bootstrapper-webpack/issues/14 is closed ( i have added a pr for it there ).

Cheers !

niieani commented 7 years ago

Fixed by https://github.com/aurelia/skeleton-navigation/pull/714