Currently, I am in the process of constructing a complex multi-module project using create-react-app, TypeScript, and Yarn workspaces.
The layout is as follows:
package.json
packages
- create-react-app-project
- other-lib-project
- tsconfig.json
- package.json
- src/
- dist/
Although the lib project builds successfully, I encounter an error upon running it:
Unhandled Rejection (TypeError): Cannot read property 'random' of undefined
In this case, "random" refers to a property within the faker library. After compilation, the import statement for faker shows up like so:
var faker_1 = require("faker");
I initially assumed that webpack would bundle all dependencies of my library when compiling the create-react-app project, but it seems this is not happening as expected.
What steps do I need to take in order to correctly bundle my library with its dependencies so they are available at runtime in the browser?