-
Notifications
You must be signed in to change notification settings - Fork 207
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
Allow configuring DDC module type #904
Comments
Hm... I just realized that I probably need to write something like |
The main work is changing the bootstrapping logic, which is fairly specific to require.js right now. Would require a bit of reorganization in this package to support it well but it wouldn't be too difficult. Making a node specific package is probably reasonable as well, we could extract the summary and module specific logic out of the build_web_compilers package as well which would help. |
Thanks @jakemac53 ! I already forked this repo and basing my work on it (it turns out there is a lot of logic around Modules in here). If you don't mind I'd like keep this issue open to ask questions along the way? |
Yep, sounds good |
Also, we can chat on gitter here https://gitter.im/dart-lang/source_gen. We have a lot of follow-up meetings today but will be more available next week. |
Awesome, no rush at all. Here is a couple of questions I have so far. For DDC modules to work with Node I'm thinking (after reading a lot) I need to put everything generated by DDC in a I see build_runner creates Is there a way to customize output folders somehow? Second question: I have a
Is it possible? Any advise would help a lot! (also, I wanted to rename |
This is a very interesting question - I think creating directories under node_modules conceptually maps to a
There is the This should also essentially answer your 2nd question, about moving the web directory to the top level (I think the output dir matches what you want there).
We have a hardcoded whitelist of common top level directories that are treated as inputs by default. To include other directories you need to create a build.yaml which looks something like this: targets:
$default:
sources:
- "lib/**"
- "node/**" |
It also looks like node supports a package.json file, as well as require.paths global which might be useful to avoid creating an actual node_modules directory. |
Looks like it was removed from the API a while ago. Though it'd be great if it was there. Something like this: // somewhere in main.dart.bootstrap.js
var Module = require('module');
var originalRequire = Module.prototype.require;
Module.prototype.require = function () {
var id = arguments['0'];
if (id.startsWith('packages/') {
// assume this is a DDC module, pseudo-code
var path = modulePaths[id];
arguments['0'] = path;
return originalRequire.apply(this, arguments);
}
return originalRequire.apply(this, arguments);
};
Ideally I'd need to use npm to install JS packages next to the generated ones.
It didn't seem to work for me from the first try. Thanks a lot for your help! I already got some positive results executing a basic DDC-compiled app in Node with |
If you want to modify the files that you can load from your package you'll need to add a |
I think generating a |
What is the actionable item for |
Two possibilities for what we could do in
If we can see a prototype of this running that would help us make a decision. |
Sounds good. I'll label this as BWC for now. |
I should have a prototype in a couple of days. |
Small update: I managed to get DDC working with my playground project with only these changes: Basic test with dart2js was successful without any changes (except adding node_preamble to dart2js output). I will be looking at getting npm dependencies and generating packages.json next. But it looks very promising so far. Will have some more updates soon. |
I have a demo app here: I pushed more changes to It's a bit more cleaner now, but I didn't do any large refactorings. Also, the trick to override target default sources to allow |
Duplicating my questions from Gitter channel here: @jakemac53 @natebosch hi guys! Just checking in about this issue. I pushed a small update to DDC part last night. Also had some success updating firebase_admin interop library with all tests passing in both DDC and dart2js (in this branch https://github.com/pulyaevskiy/firebase-admin-interop/tree/dart20). I'd like to move forward on this. I thought I could build another package on top of build_web_compilers, but all Module and ScratchSpace APIs are hidden so I can't really reuse it. I see three options at this point:
Option 3 is least favorite. Option 1 is probably least risky, the new package's functionality may eventually be merged back to build_web_compilers if we see a need for it. What do you guys think? |
We talked about this a bit more, and I think where we want to go is most similar to your option 1. Essentially, we can separate out the The main downside is we would end up with some duplicate code between Also users would not be required to do any explicit configuration, they just depend on the package they want. Thoughts? |
This sounds good to me! Looking at the list of builders:
The first three would go in This is actually already helpful. Do you guys think you'd have an opportunity to work on extracting those builders any time soon? No problem if not. If it's ok I'd be happy to contribute here. The way I was thinking to approach this is make a copy of build_web_compilers in this repository and name it build_node_compilers. Then create new Let me know what works best for you. |
Yep
Either way, we could likely do this within the next few weeks (could be sooner, we are just a bit swamped after dartconf). It shouldn't be much work though. Happy to take pull requests as well if you would like something sooner.
I would prefer to break out the other packages first if you don't mind - it limits the number of breaking releases we need to do for packages. We could do this bottom up so first
If you are willing to own it, my feeling is its good for the ecosystem to have more externally owned/maintained packages. Plus I think you know more about actually running in node than I do at least haha. |
Is there a strong rationale to creating too many sub-packages, i.e. |
In theory this will be helpful for Kernel because we'll add We're also concerned about the version constraint propagation more challenging, but it's probably better than the alternatives. Having Exposing Another nice thing about the separate packages is that they could potentially become useful in other ways. For instance if there ever becomes a benefit to the VM consuming kernel files the module and kernel packages could be put together for that. Or if we decide to revisit the idea of a summary backed Resolver (which could improve startup times for the first build in a fresh vm) we could use the module and summary packages. |
How about planning for that now, and just calling it
Maybe. Though couldn't |
(Just trying to avoid this becoming pkg/test) |
That's part of the problem here. Once I'm open to the idea of |
It's just not clear to me anyone would want to use build_modules and not kernel/summaries :) |
Please see #959 where I've submitted initial draft for splitting modules and summaries from build_web_compilers. I wasn't entirely sure if scratch space could be broken apart so I just left it in build_modules for now and wait for your feedback. |
That is fair - I am fine with us creating just build_modules today. The only thing this prevents is mixing and matching analyzer versus kernel summaries. |
I could see that being a problem if Dart2JS is using Kernel and DDC is using analyzer. Maybe? |
Yes, but I think we could split up the packages at that point if it does in fact become an issue |
Looking at the source code I see that
build_web_compilers
has hardcodedamd
module type when building for web.Is there a way to override this default behavior?
I'm working on some packages which are designed for NodeJS and this requires
common
module type.The text was updated successfully, but these errors were encountered: