-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript): add JSNamedModuleInfo provider to ts_library outputs (
#1215) 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
- Loading branch information
1 parent
f9e48e4
commit bb1f9b4
Showing
29 changed files
with
480 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""NpmPackageInfo providers and apsect to collect node_modules from deps. | ||
""" | ||
|
||
# NpmPackageInfo provider is provided by targets that are npm dependencies by the | ||
# `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", | ||
fields = { | ||
"direct_sources": "Depset of direct source files in this npm package", | ||
"sources": "Depset of direct & transitive source files in this npm package and in its dependencies", | ||
"workspace": "The workspace name that this npm package is provided from", | ||
}, | ||
) | ||
|
||
def _node_modules_aspect_impl(target, ctx): | ||
providers = [] | ||
|
||
# provide NpmPackageInfo if it is not already provided there are NpmPackageInfo deps | ||
if not NpmPackageInfo in target: | ||
sources_depsets = [] | ||
workspace = None | ||
if hasattr(ctx.rule.attr, "deps"): | ||
for dep in ctx.rule.attr.deps: | ||
if NpmPackageInfo in dep: | ||
if workspace and dep[NpmPackageInfo].workspace != workspace: | ||
fail("All npm dependencies need to come from a single workspace. Found '%s' and '%s'." % (workspace, dep[NpmPackageInfo].workspace)) | ||
workspace = dep[NpmPackageInfo].workspace | ||
sources_depsets.append(dep[NpmPackageInfo].sources) | ||
if workspace: | ||
providers.extend([NpmPackageInfo(direct_sources = depset(), sources = depset(transitive = sources_depsets), workspace = workspace)]) | ||
|
||
return providers | ||
|
||
node_modules_aspect = aspect( | ||
_node_modules_aspect_impl, | ||
attr_aspects = ["deps"], | ||
) |
Oops, something went wrong.