@builder.io/monorepo v0.0.1-mono
@builder.io/monorepo
Contains utility function which allows requiring code from modules compiled as mono-repo.
For example @builder.io/qwik
is compiled from repos/@builder.io/qwik
but we want to require it from @builder.io/qwik
.
The utility allows requiring code from @builder.io/qwik
and it rewrites node_modules
so that even thought @builder.io/qwik
source is not in the node_module
it can still see other items in the node_module
.
Usage
Note: example uses jsx-lite/core
as an example of a facade package
- create a
@jsx-lite/core
facade inrepos
folder. - create
package.json
which containsindex.js
like so:const monorepoRequire = require('../../monorepo-require'); module.exports = monorepoRequire('jsx-lite/packages/core/src/index.js', module.parent);
- Result is that one can import
@jsx/lite-core
directly from facade, but will receive implementation from mono-repo. - The tricky part is that the implementation of
@jsx/lite-core
will have visibility to the importingnode_modules
making it look like as if the code was actualy in thenode_modules
What would happen without this package.
imagine:
- packages
- api
- node_modules
- @jsx-lite/core => ../../jsx-lite/packages/jsx-lite_core.js
- bar_pkg
- jsx-lite
- packages
- jsx-lite_core.js
Without the @builder.io/monorepo
importing @jsx-lite/core
would result in import from jsx-lite_core.js
. So far so good. However, if the would try to import bar_pkg
from jsx-lite_core.js
it would fail because jsx-lite_core.js
does not have a node_module
nearby with bar_pkg
. The whole purpos of @builder.io/monorepo
is to make it look like the cod of jsx-lite_core.js
is actually in packages/api/node_modules
.
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago