Coder Social home page Coder Social logo

rig's Introduction

rig

中文文档

Get started

0.Prerequisites

Install yarn

yarn global add rigjs

Rigjs use yarn workspaces to achieve module-hoisting. About yarn workspaces.

NodeJS version >= 14

Use n to update NodeJS.

yarn global add n
#upgrade to lts
sudo n lts 
#or specify the version.
sudo n 14.19.1

1.Initialize rigjs configuration。

#in your project's root path(same level with package.json):
rig init

package.rig.json5 will be added in root path.

2.Use rigjs to install existing repos.

2.1 Method-one:rig add

rig add [your-git-ssh-url] [tag]

example:

rig add [email protected]:FlashHand/rig-demo-1.git 0.0.1

import or require the module.

const {hello} = require('rig-demo-1');
hello();

2.2 Method-two:change package.rig.json5

{
  dependencies: {
    'rig-demo-1': {
      source: '[email protected]:FlashHand/rig-demo-1.git',
      version: '0.0.1',
    }
  }
}

then

yarn install

3.Use rigjs to develop an existing repo.

3.1 Method-one:rig dev

rig dev [package's name|git-ssh-url]

When package is already in package.rig.json5:

rig dev rig-demo-1

When package is not in package.rig.json5:

rig dev [email protected]:FlashHand/rig-demo-1.git

rig-demo-1 will be installed in rig_dev directory.And a symlink of the module will be created in node_modules.

3.1 Method-two:change package.rig.json5

{
  dependencies: {
    'rig-demo-1': {
      source: '[email protected]:FlashHand/rig-demo-1.git',
      version: '0.0.1',
      dev: true //false by default
    }
  }
}

then

yarn install

4.Create and develop a new rigjs module。

4.1 Create a git repo。

get git-ssh url: [email protected]:FlashHand/rig-demo-1.git

4.2 Start developing your modules in rigjs dependencies

rig dev [email protected]:FlashHand/rig-demo-1.git

4.3 Initialize your module

cd your_project_path
cd rig_dev/rig-demo-1
yarn init 
echo "module.export={hello:()=>{console.log('hello')}}" > index.js

4.4 Use rigjs modules in your main project。

const {hello} = require('rig-demo-1');
hello();

4.5 Use rigjs module in production。

publish tag

cd rig_dev/rig-demo-1
git add .
git commit -m 'demo for rig'
git tag 0.0.1
git push origin your_branch --tag

Modify package.rig.json5

  • Change the module's version
  • Set dev to false.Don't use dev mode in production and should specify the version you need.
{
  dependencies: {
    'rig-demo-1': {
      source: '[email protected]:FlashHand/rig-demo-1.git',
      version: '0.0.1',
//      dev:true//Don't use dev mode in production.
    }
  }
}

In Electron Project

In Vite Project

Advantages

  • 💡Rigjs only needs git.No need to publish packages to private registry.
  • ⚡️Instant code sharing between multiple projects and multiple developers.Packages can be easily installed by git-ssh-url and tag.
  • ⚙️Auto npm link in dev mode.Import or require packages just like normal node_modules with friendly code suggestion.
  • 🔍Easily develop packages within your projects.Packages in dev mode are all in rig_dev folder.
  • 💨Easily transform existing code into a sharable package for multiple projects.
  • 📏Large content scale.You can share from a simple js file to multiple files that contains many pages.
  • 🧹Flat dependencies.No need to worry complex packages' relationship.

Goals

Sharing codes or files.

  1. Reuse codes between different developers or different projects in most flexible and unobtrusive way.
  2. Easily turn modules into developing mode,no need to use npm link or change package.json.
  3. Also support sharing files between projects like '.eslintrc.js' or 'tsconfig.json'...
  4. Developing one website in multiple modules.

Serverless CI/CD

  1. Build multiple versions for different environments at same time.
  2. Support deploying and publishing(Only support ali-cloud's oss and cdn by now).

Remote modules' helper(in development)

  • Working with webpack5's module federation.
  • Easily active modules' developing mode.
  • Friendly Code suggestion.
  • Simple router that can brings you everywhere.
  • Sandbox,state sharing....

Current Limits

  • Rigjs packages can share source code directly in node_modules.So transpiling or compiling might be needed.
  • Rigjs can not remove redundant codes for remote modules.
  • Although rigjs supports developing one website in multiple repos, But they all need to be built together into one application package. So it wastes time to build those unchanged modules ,which seems wrong when your website has hundreds or thousands of pages.
  • CI/CD only supports ali-cloud's oss and cdn.I don't have plans to make it better for now.

I'm still developing new features in most flexible and unobtrusive way.So my team won't cost extra time to upgrade their applications' architecture.

Rigjs works great for my team in development of vue-apps,uni-apps,electron apps and nodejs apps.If you don't need many remote modules,it will work fine for you too.

rig's People

Contributors

flashhand avatar ralphwayne avatar alkaidding avatar

Stargazers

 avatar Junyi avatar Lingfeng Yang avatar  avatar chen avatar MaoMAO0oo avatar jimmyZhao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.