Comments (8)
Thanks for this explication !
In fact in devv we have all the app with their composent installed at the sale time.
For prod because we want the smalest build possible and have micro services build (but still use à monorepo) we are copying one app and the with a script and the help of bit show and version specific of out workspace we are keeping only what we need.
Will try to provide you a veru simple repo with the script
from bit.
Can you elaborate more on the use-case why all these dependencies are in workspace.jsonc although they're not in use?
In general, I'm not aware of such an option to ignore part of workspace.jsonc and install only the ones that are used by the components.
What you might want to do is the opposite - remove all dependencies from workspace.jsonc so then bit install
searches for the dependencies from the components only. (you'll need --add-missing-deps
if those deps are newly introduced)
from bit.
The idea is that we are trying to build the best dev experience about workspace management for our team.
ATM bit show app
. and bit status
help a lot to identify what dependencies are needed or missing.
We don't want to manage manually by app/component the deps (and forgot to remove then etc..), because BIT can do it for us via git show (identified what is needed and missing) so that we have them globally inside workspace.jsonc
.
The solution you do propose could be cool but how could we indicate that we want a specific version of dependencies ? We couldn't just get the latest one available ;) (and aliases etc)
We thought about something that bit can install only app/component we would want to limit the dependencies install for build production for eg.
from bit.
So if I understand correctly, you have like a pool of dependencies with specific versions that you want bit install
to use.
This way, when a component needs one of these dependencies, it'll find the version in that pool instead of using the latest.
Specifying them in workspace.jsonc doesn't work for you because then all of them get installed and you want to install only the dependencies you use.
@GiladShoham @zkochan , maybe you guys have an idea.
from bit.
You can do something like create a temp workspace and bring only the app component into it (bit import it). Then it will only install its dependencies.
Or you can even make a temp folder (non even bit workspace) and just npm install the app component itself.
from bit.
Thanks for the suggestions !
- About the
create a temp workspace and bring only the app component into it (bit import it)
Yes but how to do that because we don't havepackage.json/lock
per component for deps, they are only managed by ourworkspace.jsonc
. And we need specific versions of dependencies, some with aliases ... So don't know how to not have theworkspace.jsonc
- Not really possible with
npm install
because we don't want to manage our component manually via npm (we removed package.lock and deps inside package.json to benefit of bit dependencies detection !)
For the moment what I am trying on is:
bit install the full deps
- Call a script that will get deps from
bit show ${app}
and generate the list of dependencies necessary (with sub-deps nedeed by all local packages) - The script will filter dev dependencies and not use dependencies
- Export the list inside the property dependencies of
workspace.jsonc
- Remove
node-modules
and lock file, - Reinstall
I think that this way I am cleaning the useless element for production build and have the minimum required.
Inside the script I am using chlid_process
of node to call bit cli , I would have prefer to use the API of @teambit
, do you guys can indicate if there is a way to call this command bit show/bit install....
programatically?
from bit.
- when you create a new workspace and import the app component into it, the app component itself contains all the dependencies it needs. so you don't need to have any dependencies in the workspace.jsonc. they will be just installed correctly during the
bit import
process. if you do want to change some versions by force, you can run thebit show
on the real workspace, then copy some dependencies to the policy in the workspace.jsonc of the temp one and modify the versions. (or even set overrides in the temp workspace) - I was talking about running npm install on a temp empty folder, so in that case any way you don't need bit dependency detection. it's only a temp folder of your app for running/deploying it.
Your method that you are trying to do now, will not work.
even if you remove the dependencies from the policy in the worksapce.jsonc, when you do bit install, bit will recognize all dependencies used by the components in the workspace, and will install them.
from bit.
So here is a script I did for our project
- it removed not needed deps based on
bit show
+ dev deps - It update
workspace.jsonc
to keep only needed packages for a specific app - It list the sub deps of related packages, that means I need to first do a bit install , then run the script, then bit install
In the end by running you should get only needed deps for an app and re-running bit install
you will get only the needed deps and sub-deps (of packages)
npx tsx scripts/clean-prod-deps.ts -p front
"pino-pretty": "npm:[email protected]",
"commander": "^12.0.0",
"chalk": "^5.3.0",
"redis": "^2.8.0",
"redislatest": "npm:redis@latest",
"twilio": "^4.11.2",
"uuid": "^9.0.1",
"wrtc": "npm:@avahq/[email protected]"
It's usefull because in the end it prevent you to have one package.json per apps/packages but manage them globally and in a prod container only get the needed deps per app , that means you can have a monorepo workspace with micro service
from bit.
Related Issues (20)
- Importing bit vue component to a NUXT project gives error HOT 2
- Vuetify not working with bit component when I import and use it in NUXT project HOT 2
- docs issue on the introduction page in the section "Get started"
- The CJS build of Vite's Node API is deprecated for new workspace with custom react environment HOT 2
- Bit received an error loading teambit.vue/[email protected], due to the error: "Cannot find module '@teambit/legacy/dist/consumer/component/dependencies/files-dependency-builder/detectives/detective-es6'" HOT 3
- In self hoisted or remote scope, when I export the components, I get the message "Processing preview" in the Overview and Preview screen HOT 3
- ERROR [nuxt] [request error] [unhandled] [500] Unexpected token '<' HOT 8
- Best way to uninstall bvm and bit from my system HOT 1
- Using react-native-svg with bit fails on teambit.preview/preview:GeneratePreview HOT 2
- bit build failed: dev+vue.dev-services.linter.v_zh54tchgb56oqy7unumk5ggzty\node_modules\@bitdev\vue.dev-services.linter.vue-eslint-config\dist\index.js': Cannot find module '@typescript-esdev+vue.dev-services.linter.v_zlint/eslint-plugin' HOT 19
- Getting started; is bit 1 GiB large? HOT 3
- Components preview not loading/working while bit start HOT 2
- Bit build error: bitdev.vue/[email protected], task "teambit.preview/preview:GeneratePreview" threw an error You must supply options.input to rollup HOT 19
- Sveltekit app starter template/generator HOT 8
- Docs: Misspelled URL | Introduction
- Next.js Quickstart not working HOT 1
- Vue Vite Tailwind Preview HOT 3
- Can I use Harmony platform with Vue and Node? HOT 1
- Can't resolve 'react-dom/client' after setup new environment? HOT 5
- better docs would be awesome and please stop recursive mentions of what you try to explain HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bit.