Skip to content

Commit

Permalink
chore: update bazel/create package
Browse files Browse the repository at this point in the history
- put deps in a separate file
- don't name WORKSPACE.bazel due to bug
  • Loading branch information
alexeagle committed May 10, 2021
1 parent 768d352 commit c47d85f
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions packages/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ npm_install(
package_lock_json = "//:package-lock.json",
)`;

let bazelDepsContent = `# Third-party dependencies fetched by Bazel
# Unlike WORKSPACE, the content of this file is unordered.
# We keep them separate to make the WORKSPACE file more maintainable.
# Install the nodejs "bootstrap" package
# This provides the basic tools for running and packaging nodejs programs in Bazel
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def fetch_dependencies():
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "65067dcad93a61deb593be7d3d9a32a4577d09665536d8da536d731da5cd15e2",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.4.2/rules_nodejs-3.4.2.tar.gz"],
)
`
let workspaceContent = `# Bazel workspace created by @bazel/create 0.0.0-PLACEHOLDER
# Declares that this directory is the root of a Bazel workspace.
Expand All @@ -152,19 +166,21 @@ workspace(
managed_directories = {"@npm": ["node_modules"]},
)
# Install the nodejs "bootstrap" package
# This provides the basic tools for running and packaging nodejs programs in Bazel
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "65067dcad93a61deb593be7d3d9a32a4577d09665536d8da536d731da5cd15e2",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.4.2/rules_nodejs-3.4.2.tar.gz"],
)
load("//tools:bazel_deps.bzl", "fetch_dependencies")
fetch_dependencies()
${pkgMgr === 'yarn' ? yarnInstallCmd : npmInstallCmd}`;

write('WORKSPACE.bazel', workspaceContent);
write('.bazelignore', `node_modules
write('tools/BUILD.bazel', '# No targets in this Bazel package\n')
write('tools/bazel_deps.bzl', bazelDepsContent);
// Don't name it WORKSPACE.bazel since there's a bug with managed_directories
write('WORKSPACE', workspaceContent);
write('.bazelignore', `\
# NB: sematics here are not the same as .gitignore
# see https://github.com/bazelbuild/bazel/issues/8106
# For example, every nested node_modules directory needs to be listed here.
node_modules
dist
bazel-out
`);
Expand All @@ -182,7 +198,8 @@ bazel-out
}
},
null, 4));
write('.gitignore', `
write('.gitignore', `\
.bazelrc.user
dist
bazel-out
node_modules`);
Expand Down

0 comments on commit c47d85f

Please sign in to comment.