-
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
feat(typescript): add JSNamedModuleInfo provider to ts_library outputs #1215
feat(typescript): add JSNamedModuleInfo provider to ts_library outputs #1215
Conversation
b12ed7a
to
4fb81dd
Compare
2202a02
to
21e4e48
Compare
internal/common/node_module_info.bzl
Outdated
doc = "Provides sources for npm dependencies installed with yarn_install and npm_install rules", | ||
# `node_module_library` targets via the `node_modules_aspect` below. | ||
NodeModuleInfo = provider( | ||
doc = "Provides information about npm dependencies", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI to remove js_library I think I'd like to produce this provider from npm_package too. Would be nice to include package name (could add in later PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had sources
as direct and transitive_sources
as direct + transitive but changed to just sources which are direct + transitive similar to what we decided for the JS providers. Does that sounds like the right approach for this?
+1 for adding package
(or module_name
) or later PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. In JS tooling we sometimes want a strict-deps policy that requires distinguishing direct and transitive sources. I would bet we'll need direct for something sometime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm. I like the idea of being able to differentiate as well even in the new JS providers. It would have solved my karma runtime_deps issue I saw earlier today by being able to just access sources
of JSNamedModuleInfo instead of having to take all of transitive_sources
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with sources
and direct_sources
which now matches what we have in the JS providers. DeclarationInfo still differs with declarations
and transitive_declarations
however.
61f5516
to
e6fed92
Compare
internal/npm_install/test/golden/@angular/core/BUILD.bazel.golden
Outdated
Show resolved
Hide resolved
elif hasattr(d, "files"): | ||
files = depset(transitive = [files, d.files]) | ||
files_depsets = [depset(ctx.files.srcs)] | ||
for dep in ctx.attr.deps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this want to be a helper in providers.bzl
? seems like I've seen the same impl many times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just two places (karma & protractor). those two rules are due for a cleaning so will note that down to look at.
7d8f36c
to
8b43e6c
Compare
17947b3
to
14df712
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks close, will give it one more look later
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""NpmPackageInfo providers and apsect to collect node_modules from deps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like it shouldn't be in internal/
- maybe providers.bzl or next to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providers.bzl seems like the right place as I don't think we want to introduce too many load points. where do you think for node_modules_aspect
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kick this downstream to later PR
# `node_module_library` rule as well as other targets that have direct or transitive deps on | ||
# `node_module_library` targets via the `node_modules_aspect` below. | ||
NpmPackageInfo = provider( | ||
doc = "Provides information about npm dependencies", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need a bunch more doc here as it should be a public API
@@ -677,7 +677,7 @@ node_module_library( | |||
node_module_library( | |||
name = "core__contents", | |||
srcs = [":core__files"], | |||
scripts = [ | |||
named_module_srcs = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kinda breaking for users, huh?
maybe we can paste a buildozer script into the release notes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anyone is using node_module_library directly as it is still private API and their generated build files will be re-generated on update
All rules that require devmode named sources are updated to use JSNamedModuleInfo. The rules affected are karma, protractor, ts_devserver, ts_proto_library (in labs) & npm_package. Some related non-breaking changes: * node_module_library scripts attribute renamed to named_module_srcs. node_module_library is currently not part of the public API and in user code the npm targets are generated by generate_build_file.ts by yarn_install & npm_install. BREAKING CHANGES: The following breaking changes are from internal details so they should not affect most users. Some some downstream projects, however, such as Angular rely on these internal details and will need to be updated accordingly when updating to the next release. * sources_aspect from /internal/node/node.bzl and /internal/common/sources_aspect.bzl is removed; its functionality was duplicate to what JSNamedModuleInfo providers * NodeModuleSources is removed and its sources field is moved to NpmPackageInfo; sources in the removed scripts field are provided by the JSNamedModuleInfo provider which node_module_library now provides * collect_node_modules_aspect renamed to just node_modules_aspect fix: nodejs_binary doesn't need declaration files
e7b6788
to
35fff2b
Compare
All rules that require devmode named sources are updated to use JSNamedModuleInfo. The rules affected are karma, protractor, ts_devserver, ts_proto_library (in labs) & npm_package.
Some related non-breaking changes:
scripts
attribute renamed tonamed_module_srcs
.node_module_library
is currently not part of the public API and in user code the npm targets are generated bygenerate_build_file.ts
byyarn_install
&npm_install
.BREAKING CHANGES:
The following breaking changes are from internal details so they should not affect most users. Some some downstream projects, however, such as Angular rely on these internal details and will need to be updated accordingly when updating to the next release.
sources_aspect
from/internal/node/node.bzl
and/internal/common/sources_aspect.bzl
is removed; its functionality was duplicate to what JSNamedModuleInfo providerssources
field is moved to NpmPackageInfo; sources in the removedscripts
field are provided by the JSNamedModuleInfo provider which node_module_library now providescollect_node_modules_aspect
renamed to justnode_modules_aspect