Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Remove dependency on local node_modules for @rxjs repository #217

Merged
merged 1 commit into from
Oct 5, 2018
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
26 changes: 15 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
steps:
- checkout:
<<: *post_checkout

# Enforce that BUILD files are formatted. Note that this uses the version of buildifier
# from the docker image above - take care that you use the same version when you run
# buildifier locally on your change.
Expand All @@ -50,26 +51,15 @@ jobs:
- checkout:
<<: *post_checkout

- restore_cache:
key: *cache_key

- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc

# Helpful for debugging, so you can check you have the same bazel version when you need
# to reproduce a failure.
- run: bazel info release

# Install the dependencies from NPM
# TODO(gmagolan): Use `bazel run :install` once bootstrap issue resolved.
# See https://github.com/bazelbuild/rules_nodejs/issues/275.
- run: yarn

# Build and Test
- run: bazel test //...

# Run the benchmark
- run: node_modules/.bin/ibazel-benchmark-runner //src:devserver src/hello-world/hello-world.component.ts --url=http://localhost:5432

- store_artifacts:
path: dist/bin/src/bundle.min.js
destination: bundle.min.js
Expand All @@ -78,6 +68,19 @@ jobs:
path: dist/bin/src/bundle.cs.min
destination: bundle.cs.min

benchmark:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout

- restore_cache:
key: *cache_key

# Run the benchmark
- run: yarn
- run: node_modules/.bin/ibazel-benchmark-runner //src:devserver src/hello-world/hello-world.component.ts --url=http://localhost:5432

# If we get this far, save the node_modules directory for use next time.
- save_cache:
key: *cache_key
Expand All @@ -90,3 +93,4 @@ workflows:
jobs:
- lint
- build
- benchmark
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,6 @@ or
npm install -g @bazel/ibazel
```

## Setup

Before building the app, we install packages, just as with any npm-based development workflow.

```bash
$ yarn install
```

or

```bash
$ npm install
```

For the time being, you need to run your locally installed `yarn` or `npm` to install dependencies
as shown above. This is because we pull down the `@bazel/typescript` bazel dependency from npm and
that dependency needs to be in place before we can build the project. We're working to
resolve this bootstrapping issue. Soon you will be able to skip this step and just do your first
Bazel build without needing any install step first.

## Development

Next we'll run the development server:
Expand Down Expand Up @@ -129,3 +109,14 @@ the entry points and modules is how routes are loaded, with production
lazy loading routes and development using a custom `NgModuleFactoryLoader`
loader to disable lazy loading. `enableProdMode()` is
also called in the production entry point.

## Npm dependencies

Having a local `node_modules` folder setup by `yarn` or `npm` is not
necessary when building this example with Bazel. This example makes use
of Bazel managed npm dependencies (https://github.com/bazelbuild/rules_nodejs#using-bazel-managed-dependencies)
which means Bazel will setup the npm dependencies in your `package.json` for you
outside of your local workspace for use in the build.

However, you may still want to run `yarn` or `npm` to manually
setup a local `node_modules` folder for editor and tooling support.
7 changes: 4 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ http_archive(
)

# The @rxjs repo contains targets for building rxjs with bazel
local_repository(
http_archive(
name = "rxjs",
path = "node_modules/rxjs/src",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
strip_prefix = "package/src",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
)

####################################
Expand All @@ -44,7 +46,6 @@ rules_angular_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")

node_repositories(
preserve_symlinks = True,
node_version = "10.9.0",
yarn_version = "1.9.2",
)
Expand Down