The Requirements:
I am developing a plugin for popularLibrary.js
. The plugin:
popularLibrary.js
is not present v1.xx
of popularLibrary.js
popularLibrary.js
popularLibrary.js
In example:
<script src="https://some-cdn.com/popularLibrary.js"></script>
<script src="https://some-cdn.com/myMagicalPlugin.js"></script>
The Problems:
popularLibrary.js
as a peerDependency
, it is no longer downloaded on npm install
. How do I continue to develop my plugin when it needs to import and utilize functionality that exists in popularLibrary.js
? popularLibrary.js
and myMagicalPlugin.js
, how does that peerDependency
resolve? Do I need to do anything extra/special in either library to support this scenario? It's been a while since I originally asked this. I ultimately added that same peerDependency
as a devDependency
, as it's needed to develop and test the application.
Ideally, you program to some contract/interface to decouple the plugin from the primary library as much as possible. In a more concrete example, I have two WebPack scripts.
Script 1: Bundles the library and uses excludes
key for any direct dependencies on the primary library (should be avoided if you can help it, ie. Decoupled)
Script 2: For a dev application, uses the primary library, and imports the plugin from source. Used with webpack-dev-server for development/testing
You can use WebPackBundleAnalyzer to make sure you're not accidentally bundling peerDeps
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.