-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order of building components and isolation - discussion #1663
Comments
Currently, there is no About isolation, there is an option In general, we do support cyclic dependencies when tagging components. |
saveDependenciesAsComponents - but I don't want to do that, I want to save components as node modules dependencies, in order to isolate the component. |
@qballer How would you do this?
|
You will add a link file that will redirect you to the node_modules
'@bit-[hash]/B' |
It seem that there is a bug. when compiling just aaa component in the uploaded example, bbb doesn't get build and when running a it explodes. this should be solved by ordering components in topological sort. |
@qballer I'm aware of this bug for a long time. |
It has to be sorted in topological sort to build dependencies correctly. |
@qballer , how topological sort will solve cyclic dependencies? |
It won't, (though it is a step in the right direction) but it will solve the fact that typescript builds all components and dependencies for each component build. Then with some luck we can reuse component A build in the build of B (which depends on A). This hinders performance greatly, and doesn't allow TS users to use .d.ts files. I've made some performance improvements that make the community compiler useable but they rely on the main file being the first in the files array. Can this property be supported in bit's current compiler API? (@davidfirst ) Cyclic dependencies can be solved with compiling twice and generating empty module definition for dependencies in the first compile. This requires additional API's for the compiler writer (thats me):
If that dependency has a types file then do nothing, if it doesn't, then generate a generic one in the dist. This should workout performance and cyclic all together. |
@qballer , according to your last message, if I understand correctly, there is no need to toposort the components. All you need is the data about the dependencies. I prepared a small snippet that you can copy/paste to your compiler. It answers your questions # 1 and # 2 above. For this, no changes are needed, you get already all the data inside the In addition, I created a new branch
An example of the output I got when running it on 3 component (
|
I was spitballing ideas here but after further considerations this seems to be something bit needs to support - toposorted order of compilations. The way I see it, given a graph of dependencies bit does the traversal on the graph and node processing (a.k.a compilation) is done by the compiler. |
I agree with @qballer . It should be bit's responsibility. |
Implemented on #1781 PR. |
I am working on created a descent typescript compiler for the bit. Right now our main issue, that current compiler doesn't emit definition and implementation from the community take a long time to run. In order to resolve that we would like to isolate each component from the workspace, build it in this isolation with type emitting (.d.ts files).
This should be a non issue when working with node modules, but does pose a problem when working with bit components.
Order
We have two components A,B and A --uses-->B, this means that B must be compiled before that in order to have it's type information available when compiling A. In more complex example you reach the conclusion that order of component must be in topological sort.
When we reach the compilation phase of A the code may look something as following:
I am wondering what is the build order of components inside a bit workspace? I believe that it should be toposorted (perhaps with double pass if we cyclic dependencies)
isolation
When A will be isolated, it doesn't need to have access to the source of B. In the isolation layer it should reach a link file to node_modules (so TS compiler will not try to read B's source code).
There in the node_modules there must be a version of B waiting with the type information which was just build.
Would love some input from on what goes on with bit today. and how can we create an API which helps to accomplish that. This presents the case of typescript, but I'm sure these ideas can benefit other sides of the product.
The text was updated successfully, but these errors were encountered: