22#
33# Use of this source code is governed by an MIT-style license that can be
44# found in the LICENSE file at https://angular.io/license
5- """Implementation of the ng_package rule.
5+ """Package Angular libraries for npm distribution
6+
7+ If all users of an Angular library use Bazel (e.g. internal usage in your company)
8+ then you should simply add your library to the `deps` of the consuming application.
9+
10+ These rules exist for compatibility with non-Bazel consumers of your library.
11+
12+ It packages your library following the Angular Package Format, see the
13+ specification of this format at https://goo.gl/jB3GVv
614"""
715
816load ("@build_bazel_rules_nodejs//:internal/collect_es6_sources.bzl" , "collect_es6_sources" )
@@ -352,6 +360,18 @@ NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
352360# some/path/to/my/package/index.js
353361# we assume the files should be named "package.*.js"
354362def primary_entry_point_name (name , entry_point , entry_point_name ):
363+ """This is not a public API.
364+
365+ Compute the name of the primary entry point in the library.
366+
367+ Args:
368+ name: the name of the `ng_package` rule, as a fallback.
369+ entry_point: The starting point of the application, see rollup_bundle.
370+ entry_point_name: if set, this is the returned value.
371+
372+ Returns:
373+ name of the entry point, which will appear in the name of generated bundles
374+ """
355375 if entry_point_name :
356376 # If an explicit entry_point_name is given, use that.
357377 return entry_point_name
@@ -364,6 +384,19 @@ def primary_entry_point_name(name, entry_point, entry_point_name):
364384 return name
365385
366386def ng_package_outputs (name , entry_point , entry_point_name ):
387+ """This is not a public API.
388+
389+ This function computes the named outputs for an ng_package rule.
390+
391+ Args:
392+ name: value of the name attribute
393+ entry_point: value of the entry_point attribute
394+ entry_point_name: value of the entry_point_name attribute
395+
396+ Returns:
397+ dict of named outputs of the rule
398+ """
399+
367400 basename = primary_entry_point_name (name , entry_point , entry_point_name )
368401 outputs = {
369402 "fesm5" : "fesm5/%s.js" % basename ,
@@ -384,3 +417,6 @@ ng_package = rule(
384417 attrs = NG_PACKAGE_ATTRS ,
385418 outputs = ng_package_outputs ,
386419)
420+ """
421+ ng_package produces an npm-ready package from an Angular library.
422+ """
0 commit comments