@builder.io/monorepo
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-mono • Public • Published

@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

  1. create a @jsx-lite/core facade in repos folder.
  2. create package.json which contains index.js like so:
    const monorepoRequire = require('../../monorepo-require');
    module.exports = monorepoRequire('jsx-lite/packages/core/src/index.js', module.parent);
    
  3. Result is that one can import @jsx/lite-core directly from facade, but will receive implementation from mono-repo.
  4. The tricky part is that the implementation of @jsx/lite-core will have visibility to the importing node_modules making it look like as if the code was actualy in the node_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.

Readme

Keywords

none

Package Sidebar

Install

npm i @builder.io/monorepo

Weekly Downloads

1

Version

0.0.1-mono

License

none

Unpacked Size

6.31 kB

Total Files

4

Last publish

Collaborators

  • builderio-bot
  • kylefowler
  • midhunadarvin
  • sidmohanty11
  • anaghavarhade
  • harmeet.builder
  • armela
  • strd6
  • murtaza-haveliwala
  • gustavohgs
  • sanyamkamat
  • shyam-builder
  • manucorporat
  • steve8708
  • samijaber
  • teleaziz123
  • mrkoreye
  • mhevery
  • adamdbradley