-
Notifications
You must be signed in to change notification settings - Fork 522
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
Infer module_name
and module_root
from providers.
#278
Comments
Sorry, this isn't quite clear to me. What's the shape of the graph? A Also, why does the module name get set in this way? Is that because Kotlin compiler produces commonjs require statements that make some assumptions about how the modules will be named? |
Yes, this would mean the
Yes the Kotlin2-js compiler sees a I toyed around with changing the output to use the
This just felt very unidiomatic. |
Okay I tried out your node example in rules_kotlin and looked in I think you're just suggesting that you could remove this code if we changed But maybe another answer is just for your |
Yes you got it. I did have a look at What about the following provider ? # Or NodeJsInfo
JsModuleInfo = provider(
fields = {
# in the case of Kotlin this is always a single file, not minified though.
"runfiles": "depset of file. Will contain .js files, .js.map files and any other files needed at runtime. At least a single js file has to be present",
"runtime_deps": "depset of NodeModuleInfo, optional. The transitive dependencies",
"module_name": "str. The module name",
# This might be better as a file ?
"module_root": "str: The module root",
}
) With the On a side note with this approach or what you suggested there would be a dependency between kotlin_rules for js support and node_rules but I think this is unavoidable. There are some internal macros / action macros that I could conceivably make use of in the kotlin rules (the rollup actions for example). I can see they have been written for reuse, would be good to have some documentation as to weather they may be reused in other rules. |
BTW I updated the kotlin stdlib breaks the naming conventions for the jar names -- the module name of the jar |
I think we need a Provider symbol exported by rules_nodejs that is expected from rules in the deps, and which transports the needed info. Then you need to export this provider in order to work with nodejs rules. TypeScript already needs this, there's a TODO in this repo to stop special-casing the typescript provider in jasmine_node_test for example. |
@alexeagle I'm also interested in this. We are using higher-level rules to ensure we track external NPM dependencies at a fine enough level that for each "module" we can generate a package.json file with the dependency section automatically generated. Currently I'm using macros and wrap outputs in a js_library rule to get the module-mapping to work. It would be much clearer and simplify the code if we started using a provider. |
This is resolved in 1.5.0 which adds a |
Kotlin rules will have JS support soon. The node rules are currently inferring the
module_name
andmodule_root
attributes from the attributes.The
module_root
will always belabel + ".js"
in kotlin andmodule_name
currently has to be the same as the label as the kotlinc-js compiler infers the module name from the jar.So rules nodejs should also look at the providers for
module_name
andmodule_root
. Should we use a proper provider here (a provider exported from these rules) or a legacy provider ?To be clear I mean the following by a legacy provider:
The text was updated successfully, but these errors were encountered: