yarn global add rigjs
Rigjs use yarn workspaces to achieve module-hoisting. About yarn workspaces.
Use n to update NodeJS.
yarn global add n
#upgrade to lts
sudo n lts
#or specify the version.
sudo n 14.19.1
#in your project's root path(same level with package.json):
rig init
package.rig.json5 will be added in root path.
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();
{
dependencies: {
'rig-demo-1': {
source: '[email protected]:FlashHand/rig-demo-1.git',
version: '0.0.1',
}
}
}
then
yarn install
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.
{
dependencies: {
'rig-demo-1': {
source: '[email protected]:FlashHand/rig-demo-1.git',
version: '0.0.1',
dev: true //false by default
}
}
}
then
yarn install
get git-ssh url: [email protected]:FlashHand/rig-demo-1.git
rig dev [email protected]:FlashHand/rig-demo-1.git
cd your_project_path
cd rig_dev/rig-demo-1
yarn init
echo "module.export={hello:()=>{console.log('hello')}}" > index.js
const {hello} = require('rig-demo-1');
hello();
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.
}
}
}
- 💡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.
- Reuse codes between different developers or different projects in most flexible and unobtrusive way.
- Easily turn modules into developing mode,no need to use npm link or change package.json.
- Also support sharing files between projects like '.eslintrc.js' or 'tsconfig.json'...
- Developing one website in multiple modules.
- Build multiple versions for different environments at same time.
- Support deploying and publishing(Only support ali-cloud's oss and cdn by now).
- Working with webpack5's module federation.
- Easily active modules' developing mode.
- Friendly Code suggestion.
- Simple router that can brings you everywhere.
- Sandbox,state sharing....
- 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.