简体   繁体   中英

Create shared library with Webpack's DllPlugin

I want to create a core NPM package that contains all dependencies which rarely change, eg Angular. Since different projects will use this NPM package and Webpack is the preferred bundling and build tool, I thought Webpack's DLL plugin would be a good choice.

But somehow the consumer packages cannot resolve the contents of the library package created with the DLL plugin. I've created a minimal example here https://github.com/matoilic/webpack-dll-example . The core module only contains Angular and the consumer module should then be able to use Angular from there. But the build of the consumer package fails with the error, that 'angular' could not be found.

Module not found: Error: Can't resolve 'angular' in '.../packages/poc-module/src/application'

Does anyone have an idea what the issue could be?

It seems like the DLL plugin doesn't handle symlinks properly. In my case, I have a mono-repo with multiple packages which are linked to each other.

https://github.com/webpack/webpack/issues/3489

The workaround is to create an installable package through npm pack and to install the resulting archive instead of using npm link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM