I'm using typegoose to unify my interfaces + db schemas shared across ~6 apps. It helps me keep my data structure consistent.
Now that means that most of my types/interfaces in my Angular app are coming from an external project.
Because of this I have:
"typegoose": "^5.9.0",
"@types/mongoose": "^5.5.17",
"mongoose": "^5.6.12",
"@tlabs/models": "^1.7.13",
added as dev dependencies. All works fine and I can even build but when I try to build using universal, I can see this warning:
WARNING in ./node_modules/mongoose/lib/index.js 11:28-64
Critical dependency: the request of a dependency is an expression
x5 times about mongodb/mongoose
And when I check my lambda function log, I can see:
2019-09-17T14:56:59.691Z undefined ERROR (node:8) DeprecationWarning: This Package got moved, please use `@hasezoey/typegoose` | github:hasezoey/typegoose
which comes from typegoose so that gets me confused.
I'm 100% using only as types, if I attempt to use it by instantiating a class object using one of the types, the whole app won't work at all.
Is there something I'm missing about the configuration of webpack here?
I also got similar errors when dealing with angular universal and other SQL databases. But, there is a solution that at least worked for me.
And that is the
webpack-node-externalspackage. Which simply makes webpack ignore your node_modules folder.Link to the NPM page >> https://www.npmjs.com/package/webpack-node-externals
assuming everything else in your
webpack.server.config.jsthis should solve those errors and make your bundle size much much smaller. (keep in mind that you will need to include your node_modules folder when deploying to other environments)Brief Tutorial
npm i webpack-node-externalswebpack.server.config.jsin a text editor