This issue is not particularly related to typewriting, but it is a common problem on how to bundle two javascript packages together and prevent libraries from loading several times. The decisive factor depends on which assembly / linker you are using. I think this response to stackflow is pretty good if you only care about the deduplication reaction.
Here is an example of a solution to this problem using a web package.
First of all, make sure that any common dependencies in your child package are devDependencies and peerDependencies, and your parent package sets them as necessary dependencies and devDependencies.
A - package.json
{ "dependencies": { "B": "1.0.0", "react": "xxx", }, "devDependencies": { "@types/react": "xxx" } }
B - package.json
{ "version": "1.0.0", "peerDependencies": { "@types/react": "xxx", "react": "xxx" }, "devDependencies": { "@types/react": "xxx", "react": "xxx" } }
If you are working with a web package from package A, you must definitely enable node_modules, if applicable only from package A node_modules.
const path = require('path') module.exports = { // rest of your webpack condig... resolve: { modules: [path.resolve(__dirname, 'node_modules'), 'node_modules'] } }
Here is another solution using response-app-rewired that does the same
const path = require('path') module.exports = function override(config) { config.resolve = Object.assign({}, config.resolve, { modules: [path.resolve(__dirname, 'node_modules'), ...config.resolve.modules] }) return config }
jjbskir
source share