bit icon indicating copy to clipboard operation
bit copied to clipboard

How do I build bit I forked?

Open ZyJoey opened this issue 5 years ago • 5 comments

Description

Hello! I forked bit and modified the source code. Now I want to build and publish it as a npm package on our own registry. But I don't know how to build it. I know install bit-harmony by BVM. I've researched the process that BVM install bit, however it too complicated. Is there an easier way to build it?

Specifications

  • Bit version: 0.0.529
  • Node version: 16.11.1
  • npm / yarn version: 8.0.0
  • Platform: mac os
  • Bit compiler (include version): -
  • Bit tester (include version): -

ZyJoey avatar Oct 20 '21 08:10 ZyJoey

Can you elaborate on what exactly are you trying to achieve? In general you don't have to use bvm, you can publish it to npm and install it directly.

GiladShoham avatar Oct 26 '21 08:10 GiladShoham

Hello, @GiladShoham ! As far as I know, bit harmony compiled code are all in node_modules, but I couldn't publish compiled code to private registry directly. For one thing npm packages are not allowed to include node_modules, for another these files sizes are too large to exceed max_body_size. So I intend to upload node_modules to our cloud server during prepublished and download the files after installing npm package. Here are my code. package.json

{
  ... 
 "scripts": {
    "prepublishOnly": "sh ./scripts/prepublish.sh"
  }
}

./scripts/prepublish.sh

#!/usr/bin/env bash

npm run clean
npm run build
npm run build:types
bit compile
rm -rf node_modules/@teambit/legacy
mkdir node_modules/@teambit/legacy
cp -rfv package.json dist node_modules/@teambit/legacy
ver=$(cat ../package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | xargs echo -n)
tarName="mbit-${ver}.tar.gz"
tar -czvf $tarName node_modules

# upload .tag.gz file to cloud server
node ./scripts/upload-tar.js

./bin/bit.js

#!/usr/bin/env node

const { spawnSync } = require('child_process');
const { version } = require('../package.json')
const path = require('path');

try {
  require('../node_modules/@teambit/bit/dist/app');
} catch {
  const fetchFile = () => {
    // fetch .tar.gz file from cloud server
  }

  fetchFile().then(() => {
    spawnSync('tar', ['-xzvf', `mbit-${version}.tar.gz`], {
      cwd: path.resolve(__dirname, '../'),
      detached: true,
      stdio: 'inherit',
    });
  })
}

I've not finished uploading and downloading code so I moved the .tar.gz file in the installed package manually and unzipped. Everything works fine except using bit start. image

How should I resolve this error ? Thanks!

ZyJoey avatar Oct 29 '21 04:10 ZyJoey

I'm still not fully understand why do you need your own fork? If you need changes it will be easier to make a pr and make it part of the main bit.

GiladShoham avatar Oct 29 '21 07:10 GiladShoham

Hello, @GiladShoham. We want to make some changes based on bit to better support our business. For example, we want to add component reference statistics feature and these data can be look up on the self-hosted service. In addition, maybe we will modify configuration file or command in the future. Are we allowed to do that?

ZyJoey avatar Oct 29 '21 08:10 ZyJoey

months ago we moved away from using npm as a way to install @teambit/bit, as the setting this up caused a lot of inconsistencies of sub-dependencies. to have full control over the flow, we opted to bundle an installation and ship it via a dedicated tool. this reduced a lot of inconsistencies and stability issues, and also improved the installation performance. at this point in time, figuring out how to "revert" that and make bit publish-able (and install-able) from a registry is a complex task which we don't aim to solve.

you are allowed to make your changes for Bit as much as you need. we built bit to be extendible, so you don't have to figure out building bit and re-publishing it. bit is using aspect-oriented-dev so you can essentially plugin and extend any part of bit with your own code. this is similar to how we build the bit-angular setup - https://github.com/teambit/bit-angular when your extension is done, you essentially set it up in the workspace.jsonc (or scope.jsonc) file, and bit will load it to memory. we are working on a guide for how to extend bit and customize it better for your needs.

if you are looking to have a modified version of bit, and not use bit's built-in extension system, you will need to build the installation package and build bvm to fetch your asset.

itaymendel avatar Feb 27 '22 11:02 itaymendel