Skip to content

Conversation

walkerburgin
Copy link
Contributor

Small quality of life improvement to stop logging a warning on null subpath exports in package.json:

{
  "exports": {
    "./features/*.js": "./src/features/*.js",
    "./features/private-internal/*": null
  }
}

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: no

Test plan

  • Covered by existing test cases
  • Manual testing; please provide instructions so we can reproduce:

Copy link

aspect-workflows bot commented Feb 6, 2025

Test

1 test target passed

Targets
//gazelle/js:npm_package_deps_test [k8-fastbuild] 125ms

Total test execution time was 125ms. 218 tests (99.5%) were fully cached saving 7m 1s.


Buildifier      Format

@jbedard
Copy link
Member

jbedard commented Feb 6, 2025

Was there stdout spam previously? Can we edit a package.json exports in one of the tests to test that? The gazelle tests record stdout and assert it doesn't change so I think this can be reprod in a test npm...

@walkerburgin
Copy link
Contributor Author

Yeah, here's what prompted this:

➜   bazel configure
Updating BUILD files for go, javascript, aspect-configure
2025/02/05 16:53:45 unknown exports../internal/* type: <nil>
653 BUILD files visited
0 BUILD files updated

With a package.json that has this in its exports:

"exports": {
    // ...
    "./*": {
        "types": "./dist/*.d.ts",
        "default": "./dist/*.js"
    },
    "./internal/*": null
}

I'm still trying to figure out how to repro this behavior in a test

@jbedard
Copy link
Member

jbedard commented Feb 6, 2025

If you search for "exports": in a test and add the null entry does it cause that test to fail? The stdout is part of the test assertions, I think by default with no opt-in. See some expectedStdout.txt files in there.

@@ -3,6 +3,7 @@
"private": true,
"exports": {
".": "./src/main.js",
"./stars/*": "./other/*.js"
"./stars/*": "./other/*.js",
"./stars/internal/*": null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do this on main and then change this from BazelLog.Warnf("unknown exports.%s type: %T", exportKey, export) to BazelLog.Fatalf("unknown exports.%s type: %T", exportKey, export) I can get bazel test --test_output=all //gazelle/js:npm_package_deps_test to fail.

But I think this is interfering with expectedStdout.txt / expectedStderr.txt 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, was it only logging and not spamming stdout? Then with tests the logging wasn't even visible...?

If so then just adding this line to this test is enough 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm seeing in our codebase is that bazel configure logs a message like this for each null in "exports":

2025/02/06 07:51:30 unknown exports../internal/* type: <nil>

I'm not sure where the line is between logging and spamming -- I was mostly just trying to pre-empt questions from devs in our repo since having a null in "exports" in this case is intentional.

I didn't dig in to how the epectedStdout.txt/expectedStderr.txt is implemented, but I confirmed that on main adding "./stars/internal/*": null here causes us to hit the BazelLog.Warnf("unknown exports.%s type: %T", exportKey, export) statement. During tests it looks like the logger writes to a file so it never makes it to stdout/stderr. If I comment out this I can get a failing test:

image

@jbedard jbedard closed this Feb 10, 2025
jbedard added a commit that referenced this pull request Feb 21, 2025
Synced from #810 by
walkerburgin:

---

Small quality of life improvement to stop logging a warning on `null`
subpath exports in `package.json`:

```json
{
  "exports": {
    "./features/*.js": "./src/features/*.js",
    "./features/private-internal/*": null
  }
}
```

---

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

Do not output `aspect configure` warning for package.json 'null exports'

### Test plan

- Covered by existing test cases
- Manual testing; please provide instructions so we can reproduce:

Closes #810

Co-authored-by: Walker Burgin <wburgin@anduril.com>
GitOrigin-RevId: e4d41609ed4bf14f13d6b975a9df023558a0d9be
jbedard added a commit that referenced this pull request Feb 21, 2025
Synced from #810 by
walkerburgin:

---

Small quality of life improvement to stop logging a warning on `null`
subpath exports in `package.json`:

```json
{
  "exports": {
    "./features/*.js": "./src/features/*.js",
    "./features/private-internal/*": null
  }
}
```

---

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

Do not output `aspect configure` warning for package.json 'null exports'

### Test plan

- Covered by existing test cases
- Manual testing; please provide instructions so we can reproduce:

Closes #810

Co-authored-by: Walker Burgin <wburgin@anduril.com>
GitOrigin-RevId: e4d41609ed4bf14f13d6b975a9df023558a0d9be
jbedard added a commit that referenced this pull request Feb 25, 2025
Synced from #810 by
walkerburgin:

---

Small quality of life improvement to stop logging a warning on `null`
subpath exports in `package.json`:

```json
{
  "exports": {
    "./features/*.js": "./src/features/*.js",
    "./features/private-internal/*": null
  }
}
```

---

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

Do not output `aspect configure` warning for package.json 'null exports'

### Test plan

- Covered by existing test cases
- Manual testing; please provide instructions so we can reproduce:

Closes #810

Co-authored-by: Walker Burgin <wburgin@anduril.com>
GitOrigin-RevId: e4d41609ed4bf14f13d6b975a9df023558a0d9be
jbedard added a commit that referenced this pull request Feb 25, 2025
Synced from #810 by
walkerburgin:

---

Small quality of life improvement to stop logging a warning on `null`
subpath exports in `package.json`:

```json
{
  "exports": {
    "./features/*.js": "./src/features/*.js",
    "./features/private-internal/*": null
  }
}
```

---

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

Do not output `aspect configure` warning for package.json 'null exports'

### Test plan

- Covered by existing test cases
- Manual testing; please provide instructions so we can reproduce:

Closes #810

Co-authored-by: Walker Burgin <wburgin@anduril.com>
GitOrigin-RevId: e4d41609ed4bf14f13d6b975a9df023558a0d9be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants