Skip to content

Commit

Permalink
fix: fix for issue #447
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Sep 16, 2022
1 parent 5a6c09b commit 68b2b43
Show file tree
Hide file tree
Showing 12 changed files with 597 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- 'e2e/pnpm_workspace_rerooted'
- 'e2e/npm_translate_package_lock'
- 'e2e/npm_translate_yarn_lock'
- 'e2e/package_json_module'
- 'e2e/rules_foo'
- 'e2e/js_image'

Expand Down
1 change: 1 addition & 0 deletions e2e/package_json_module/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 2 additions & 0 deletions e2e/package_json_module/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# import common bazelrc shared with e2e workspaces
import %workspace%/../../.bazelrc.common
1 change: 1 addition & 0 deletions e2e/package_json_module/.bazelversion
14 changes: 14 additions & 0 deletions e2e/package_json_module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:mocha/package_json.bzl", mocha_bin = "bin")

npm_link_all_packages(name = "node_modules")

mocha_bin.mocha_test(
name = "test",
args = ["test.js"],
data = [
# package.json is required for node to pickup the "type": "module" field
"package.json",
":test.js",
],
)
9 changes: 9 additions & 0 deletions e2e/package_json_module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
e2e tests with special case of

```
"type": "module",
```

set in `package.json`.

In particular, this is a regression test for issue https://github.com/aspect-build/rules_js/issues/447
27 changes: 27 additions & 0 deletions e2e/package_json_module/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local_repository(
name = "aspect_rules_js",
path = "../..",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()
7 changes: 7 additions & 0 deletions e2e/package_json_module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": "true",
"type": "module",
"dependencies": {
"mocha": "10.0.0"
}
}
Loading

0 comments on commit 68b2b43

Please sign in to comment.