Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ESM in Node.js code generation scripts #2739

Merged
merged 13 commits into from
Aug 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "//:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
pnpm-lock.yaml=172204574
package.json=-1427231250
package.json=794269200
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bazel-bin
bazel-out
bazel-testlogs
node_modules
4 changes: 4 additions & 0 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ jobs:
${{ runner.os }}-bazel-
path: ~/.cache/bazel

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Start server
run: |
npm install
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.10
20.14.0
10 changes: 5 additions & 5 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,30 @@ js_binary(
":style-code",
":style-spec",
],
entry_point = "scripts/generate-style-code.js",
entry_point = "scripts/generate-style-code.mjs",
)

js_binary(
name = "generate-shader-code-script",
data = [
":node_modules/argparse",
],
entry_point = "shaders/generate_shader_code.js",
entry_point = "shaders/generate_shader_code.mjs",
)

js_library(
name = "style-spec",
srcs = ["scripts/style-spec.js"],
srcs = ["scripts/style-spec.mjs"],
data = glob([
"scripts/style-spec-reference/*.js",
"scripts/style-spec-reference/*.mjs",
"scripts/style-spec-reference/*.json",
]),
visibility = ["//visibility:public"],
)

js_library(
name = "style-code",
srcs = ["scripts/style-code.js"],
srcs = ["scripts/style-code.mjs"],
visibility = ["//visibility:public"],
deps = [
":node_modules/ejs",
Expand Down
13 changes: 10 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
module(name = "maplibre")

bazel_dep(name = "apple_support", version = "1.16.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "aspect_rules_js", version = "1.42.3")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_apple", version = "3.7.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "2.1.1", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_xcodeproj", version = "2.5.2")
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
bazel_dep(name = "rules_nodejs", version = "6.2.0")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "20.14.0")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
data = ["package.json"],
pnpm_lock = "//:pnpm-lock.yaml",
update_pnpm_lock = True,
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")

# Allows developers to use the matching pnpm version, for example:
# bazel run -- @pnpm --dir /home/runner/work/rules_js/rules_js install
use_repo(pnpm, "pnpm")

provisioning_profile_repository = use_extension("@build_bazel_rules_apple//apple:apple.bzl", "provisioning_profile_repository_extension")
Expand Down
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"@mapbox/mvt-fixtures": "3.10.0",
"@octokit/plugin-retry": "^7.1.0",
"@octokit/rest": "^20.1.0",
"@types/node": "^20.12.7",
"@types/argparse": "^2.0.16",
"@types/ejs": "^3.1.5",
"@types/node": "^20.16.1",
"argparse": "^2.0.1",
"csscolorparser": "~1.0.3",
"csscolorparser": "^1.0.3",
"d3-queue": "3.0.7",
"diff": "5.2.0",
"ejs": "^3.1.10",
Expand All @@ -42,5 +44,6 @@
"typescript": "^5.4.5",
"xcode": "^3.0.1"
},
"scripts": {}
"scripts": {},
"type": "module"
}
Loading
Loading