Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions examples/angular_view_engine/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")

package(default_visibility = ["//:__subpackages__"])

# ts_library and ng_module use the `//:tsconfig.json` target
Expand All @@ -13,3 +15,23 @@ sh_test(
name = "dummy_test",
srcs = ["dummy_test.sh"],
)

# Here we selectively chose which files to include in node_modules/examples_angular_view_engine
# as node_modules/examples_angular_view_engine is no longer automatically linke to the root of bazel-bin.
# Because ngfactory files are generated with absolute `examples_angular_view_engine/` imports, we need
# to ensure all the files that these imports reference are available under
# node_modules/examples_angular_view_engine for rollup_bundle to find.
pkg_npm(
name = "examples_angular_view_engine",
package_name = "examples_angular_view_engine",
deps = [
"//src:src_esm",
"//src/app:app_esm",
"//src/app/hello-world:hello-world_esm",
"//src/app/home:home_esm",
"//src/app/todos:todos_esm",
"//src/app/todos/reducers:reducers_esm",
"//src/lib/typography:typography_esm",
"//src/shared/material:material_esm",
],
)
7 changes: 7 additions & 0 deletions examples/angular_view_engine/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ ng_module(
],
)

filegroup(
name = "src_esm",
srcs = [":src"],
output_group = "es6_sources",
)

filegroup(
name = "rxjs_umd_modules",
srcs = [
Expand Down Expand Up @@ -137,6 +143,7 @@ rollup_bundle(
},
output_dir = True,
deps = [
"//:examples_angular_view_engine",
"//src",
"@npm//rollup-plugin-amd",
"@npm//rollup-plugin-commonjs",
Expand Down
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ ng_module(
"@npm//@ngrx/store",
],
)

filegroup(
name = "app_esm",
srcs = [":app"],
output_group = "es6_sources",
)
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/app/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ ng_module(
],
)

filegroup(
name = "hello-world_esm",
srcs = [":hello-world"],
output_group = "es6_sources",
)

ts_library(
name = "test_lib",
testonly = 1,
Expand Down
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/app/home/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ ng_module(
"@npm//@angular/router",
],
)

filegroup(
name = "home_esm",
srcs = [":home"],
output_group = "es6_sources",
)
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/app/todos/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ ng_module(
"@npm//rxjs",
],
)

filegroup(
name = "todos_esm",
srcs = [":todos"],
output_group = "es6_sources",
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ ts_library(
"@npm//@ngrx/store",
],
)

filegroup(
name = "reducers_esm",
srcs = [":reducers"],
output_group = "es6_sources",
)
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/lib/typography/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ ng_module(
"@npm//@angular/core",
],
)

filegroup(
name = "typography_esm",
srcs = [":typography"],
output_group = "es6_sources",
)
6 changes: 6 additions & 0 deletions examples/angular_view_engine/src/shared/material/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ ng_module(
"@npm//@angular/material",
],
)

filegroup(
name = "material_esm",
srcs = [":material"],
output_group = "es6_sources",
)
1 change: 1 addition & 0 deletions examples/protocol_buffers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load("@npm//@bazel/terser:index.bzl", "terser_minified")
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_devserver", "ts_library")
load("@npm//http-server:index.bzl", "http_server")
load("@rules_proto//proto:defs.bzl", "proto_library")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this just a warning you're fixing or is it related to the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 where did that symbol come from before I added that load?


proto_library(
name = "tire_proto",
Expand Down
4 changes: 2 additions & 2 deletions examples/protocol_buffers/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {CarServiceClient} from 'examples_protocol_buffers/car_grpc_web_pb';
import {Car} from 'examples_protocol_buffers/car_pb';
import {CarServiceClient} from './car_grpc_web_pb';
import {Car} from './car_pb';

const car = new Car();
car.setMake('Porsche');
Expand Down
4 changes: 2 additions & 2 deletions examples/protocol_buffers/car.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Car} from 'examples_protocol_buffers/car_pb';
import {Tire} from 'examples_protocol_buffers/tire_pb';
import {Car} from './car_pb';
import {Tire} from './tire_pb';

describe('protocol buffers', () => {
it('allows creation of an object described by proto', () => {
Expand Down
8 changes: 1 addition & 7 deletions internal/linker/link_node_modules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ def write_node_modules_manifest(ctx, extra_data = []):
extra_data: labels to search for npm packages that need to be linked (ctx.attr.deps and ctx.attr.data will always be searched)
"""

mappings = {
# We always map the workspace to itself to support absolute require like
# import from 'my_wksp/path/to/file' and it's always links to the bin_dir.
# If source files need to be required then they can be copied to the bin_dir
# with copy_to_bin.
ctx.workspace_name: ["execroot", ctx.bin_dir.path],
}
mappings = {}
node_modules_root = ""

# Look through data/deps attributes to find...
Expand Down
11 changes: 4 additions & 7 deletions internal/linker/test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ sh_binary(
"//internal/linker:index.js",
"//internal/linker/test/integration/static_linked_pkg",
"//internal/linker/test/integration/static_linked_scoped_pkg",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
"@build_bazel_rules_nodejs//toolchains/node:node_bin",
"//internal/linker/test/integration/absolute_import:index.js",
"//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
"//toolchains/node:node_bin",
"//internal/linker:runfiles_helper.js",
],
)

Expand All @@ -53,8 +55,6 @@ linked(
out = "actual",
program = ":run_program",
deps = [
# NB: reference the copy of index.js in the output folder
"//%s/absolute_import:copy_to_bin" % package_name(),
":run_program",
# NB: Verify that a direct dep on :some_program and a transitive dep on
# the same via :run_program works with the linker. These should both
Expand All @@ -80,7 +80,6 @@ linked(
# do not sort
deps = [
# NB: reference the copy of index.js in the output folder
"//%s/absolute_import:copy_to_bin" % package_name(),
# Intentinally include this before static_linked_pkg as order matters for the linker.
# The order here exercises a different code path in the linker conflict resolution logic
# than `example_with_conflicts_alt`.
Expand Down Expand Up @@ -108,8 +107,6 @@ linked(
program = ":run_program",
# do not sort
deps = [
# NB: reference the copy of index.js in the output folder
"//%s/absolute_import:copy_to_bin" % package_name(),
# NB: static_linked maps to both
# ["runfiles", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_pkg"] and
# ["bin", "build_bazel_rules_nodejs/internal/linker/test/integration/static_linked_pkg"]
Expand Down
7 changes: 1 addition & 6 deletions internal/linker/test/integration/absolute_import/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
load("//:index.bzl", "copy_to_bin")

package(default_visibility = ["//internal/linker/test:__subpackages__"])

copy_to_bin(
name = "copy_to_bin",
srcs = ["index.js"],
)
exports_files(["index.js"])
16 changes: 14 additions & 2 deletions internal/linker/test/integration/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ const t = require('transitive_static_linked');
// they should get resolved from the execroot
const b = require('dynamic_linked');
const d = require('@linker_scoped/dynamic_linked');
// We've always supported `require('my_workspace')` for absolute imports like Google does it
const c = require('build_bazel_rules_nodejs/internal/linker/test/integration/absolute_import');

let c;
try {
// As of 2.0, we no longer support `require('my_workspace/path/to/output/file.js')` for absolute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to link to this spot in the BREAKING CHANGE

// imports
c = require('build_bazel_rules_nodejs/internal/linker/test/integration/absolute_import');
console.error('should have failed');
process.exit(1);
} catch (_) {
// You now need to use the runfiles helper library to resolve absolute workspace imports
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
c = require(runfiles.resolve(
'build_bazel_rules_nodejs/internal/linker/test/integration/absolute_import'));
}

// Third-party package installed in the root node_modules
const semver = require('semver');
Expand Down
6 changes: 6 additions & 0 deletions internal/linker/test/integration/run_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export VERBOSE_LOGS=1
# Too spammy for CI logs
# export NODE_DEBUG=module

# Export the location of the runfiles helpers script
export BAZEL_NODE_RUNFILES_HELPER=$(rlocation "build_bazel_rules_nodejs/internal/linker/runfiles_helper.js")
if [[ "${BAZEL_NODE_RUNFILES_HELPER}" != /* ]] && [[ ! "${BAZEL_NODE_RUNFILES_HELPER}" =~ ^[A-Z]:[\\/] ]]; then
export BAZEL_NODE_RUNFILES_HELPER=$(pwd)/${BAZEL_NODE_RUNFILES_HELPER}
fi

for ARG in "$@"; do
case "$ARG" in
--bazel_node_modules_manifest=*) MODULES_MANIFEST="${ARG#--bazel_node_modules_manifest=}" ;;
Expand Down
30 changes: 0 additions & 30 deletions internal/linker/test/issue_1823/BUILD.bazel

This file was deleted.

3 changes: 0 additions & 3 deletions internal/linker/test/issue_1823/jest.config.js

This file was deleted.

35 changes: 0 additions & 35 deletions internal/linker/test/issue_1823/ts_jest_test.bzl

This file was deleted.

18 changes: 0 additions & 18 deletions internal/linker/test/issue_1823_use_ts_library_esm/jest.config.js

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions internal/linker/test/issue_1823_use_ts_library_esm/lib.ts

This file was deleted.

Loading