Skip to content

Commit

Permalink
Add an ng_package rule
Browse files Browse the repository at this point in the history
This should build the npm distribution for @ngrx/store.

Requires a bunch of fixes:
- angular/compiler-cli later than 6.0.0-beta.4 - it's unreleased, plus there's a problem with the snapshot published (missing stuff) so this points to my fork
  alexeagle/compiler-cli-builds
- angular/bazel-builds doesn't have ng_package yet because it hasn't landed. I crafted a distributable version on
  alexeagle/bazel-builds
  but this includes some fixes that need to be upstreamed
- rules_typescript needs minor fixes to pick up fix for mozilla/source-map#273
  • Loading branch information
alexeagle committed Feb 18, 2018
1 parent 3e25543 commit 9f0ad3b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
16 changes: 12 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ node_repositories(package_json = ["//:package.json"])

####################################
# Fetch and install the TypeScript rules
http_archive(
git_repository(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.10.1.zip",
strip_prefix = "rules_typescript-0.10.1",
sha256 = "a2c81776a4a492ff9f878f9705639f5647bef345f7f3e1da09c9eeb8dec80485",
remote = "git@github.com:alexeagle/rules_typescript.git",
commit = "623565514d6bad77d9310f2658bf8457eb4979bb",
)

load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
Expand Down Expand Up @@ -68,11 +67,20 @@ local_repository(
path = "node_modules/@angular/bazel",
)

git_repository(
name = "angular_devkit",
remote = "git@github.com:alexeagle/devkit.git",
commit = "2a2bcb7650394fd4d6c5c999e744b9fbf78e5719",
)

local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)

load("@angular//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()

####################################
# Bazel will fetch its own dependencies from npm.
Expand Down
10 changes: 8 additions & 2 deletions modules/store/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ng_package")

ts_library(
ng_module(
name = "store",
srcs = glob([
"*.ts",
Expand All @@ -10,3 +10,9 @@ ts_library(
visibility = ["//visibility:public"],
deps = ["@rxjs"],
)

ng_package(
name = "npm_package",
deps = [":store"],
entry_point = "modules/store/index.js",
)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
"devDependencies": {
"@angular/animations": "^5.0.0",
"@angular/bazel": "alexeagle/bazel-builds#510158e7992f91276f2c147552c9492b32fc85ce",
"@angular/cli": "^1.5.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
Expand Down
17 changes: 16 additions & 1 deletion tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
"""Re-export of some bazel rules with repository-wide defaults."""
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library")
load("@angular//:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")

DEFAULT_NODE_MODULES = "@ngrx_compiletime_deps//:node_modules"

def ts_library(tsconfig = None, node_modules = None, **kwargs):
if not tsconfig:
tsconfig = "//:tsconfig.json"
if not node_modules:
node_modules = "@ngrx_compiletime_deps//:node_modules"
node_modules = DEFAULT_NODE_MODULES
_ts_library(tsconfig = tsconfig, node_modules = node_modules, **kwargs)

def ng_module(tsconfig = None, node_modules = None, **kwargs):
if not tsconfig:
tsconfig = "//:tsconfig.json"
if not node_modules:
node_modules = DEFAULT_NODE_MODULES
_ng_module(tsconfig = tsconfig, node_modules = node_modules, **kwargs)

def ng_package(node_modules = None, **kwargs):
if not node_modules:
node_modules = DEFAULT_NODE_MODULES
_ng_package(node_modules = node_modules, **kwargs)
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
dependencies:
tslib "^1.7.1"

"@angular/bazel@alexeagle/bazel-builds#a208b5a8b555ecae0a4b5496a00b45aa181d12de":
version "6.0.0-beta.4-f693be3"
resolved "https://codeload.github.com/alexeagle/bazel-builds/tar.gz/a208b5a8b555ecae0a4b5496a00b45aa181d12de"
dependencies:
"@types/node" "6.0.84"

"@angular/cdk@^2.0.0-beta.12":
version "2.0.0-beta.12"
resolved "https://registry.yarnpkg.com/@angular/cdk/-/cdk-2.0.0-beta.12.tgz#3a243cb62b93f4e039120ba70f900dc9e235622e"
Expand Down Expand Up @@ -237,6 +243,10 @@
version "7.0.34"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.34.tgz#eed5c95291a9dddff6b9f5a72ca342b1e72f0ba2"

"@types/node@6.0.84":
version "6.0.84"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.84.tgz#193ffe5a9f42864d425ffd9739d95b753c6a1eab"

"@types/node@^6.0.46":
version "6.0.68"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.68.tgz#0c43b6b8b9445feb86a0fbd3457e3f4bc591e66d"
Expand Down

0 comments on commit 9f0ad3b

Please sign in to comment.