Skip to content

feat: support named import from json - #20

Merged
Brooooooklyn merged 1 commit into
mainfrom
07-17-chore_add_wasm_pacakge_test_case_split
Jul 18, 2024
Merged

Brooooooklyn merged 1 commit into
mainfrom
07-17-chore_add_wasm_pacakge_test_case_split

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Jul 17, 2024 •

Copy link
Copy Markdown
Member

Brooooooklyn commented Jul 17, 2024 •

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Brooooooklyn and the rest of your teammates on Graphite Graphite

@Brooooooklyn
Brooooooklyn force-pushed the 07-17-chore_add_wasm_pacakge_test_case branch from c79d1de to 2efeb26 Compare July 17, 2024 15:46
@Brooooooklyn
Brooooooklyn force-pushed the 07-17-chore_add_wasm_pacakge_test_case_split branch 3 times, most recently from e56f3b8 to b0bb629 Compare July 18, 2024 02:24

Brooooooklyn commented Jul 18, 2024 •

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 17, 10:45 PM EDT: @Brooooooklyn started a stack merge that includes this pull request via Graphite.
  • Jul 17, 10:46 PM EDT: Graphite rebased this pull request as part of a merge.
  • Jul 17, 10:55 PM EDT: @Brooooooklyn merged this pull request with Graphite.

@Brooooooklyn
Brooooooklyn changed the base branch from 07-17-chore_add_wasm_pacakge_test_case to graphite-base/20 July 18, 2024 02:45
@Brooooooklyn
Brooooooklyn changed the base branch from graphite-base/20 to main July 18, 2024 02:45
@Brooooooklyn
Brooooooklyn force-pushed the 07-17-chore_add_wasm_pacakge_test_case_split branch from b0bb629 to ab11168 Compare July 18, 2024 02:46
@Brooooooklyn
Brooooooklyn merged commit 622f1fa into main Jul 18, 2024
@Brooooooklyn
Brooooooklyn deleted the 07-17-chore_add_wasm_pacakge_test_case_split branch July 18, 2024 02:55
Brooooooklyn added a commit that referenced this pull request Oct 26, 2026
<!-- claude-projects-attribution: {"github_login":"Brooooooklyn"} -->
_Requested by **Brooklyn** · [project
thread](https://claude.ai/code/project/chan_018s9RxRdtH424j2EhXdzV3N?thread=cmsg_018s9RxRdtH424j2EhXdzV3NQxbeR8Pt7qaqSQwoq9rEFo)_

<!-- routine:prune-tests:duplicate-smoke-tests -->

Before: two smoke tests could not fail for a reason no other test
catches. `integrate-vitest`'s `index.spec.ts > transform` repeats
integrate-module's `should resolve native addon`, and integrate-module's
`named import from json` asserts on a JSON import that Node loads
natively, so it passes even when oxc-node's JSON loader is broken.

After: both are gone. The two stdin TTY tests that alone catch a TTY
regression now say so in a comment, and a comment that pointed at the
deleted spec points at the surviving test. Only test files change.

How: each removal was defended by mutating `src/lib.rs` with the most
realistic regression it could catch, rebuilding the addon, running all
three JS suites, and reverting.

### Totals

- Files touched: 4, all tests (1 deleted, 1 case removed, 2
comment-only).
- Cases deleted: **2 of 643** JS cases (Vitest 600, integrate-module 21,
integrate-module-bundler 22); after: 641. The Rust `#[test]`s are
untouched.
- Cases merged: 0.
- Net lines: **−7** (+6 / −13).
- Runtime saved: 9.8 ms, the summed duration of the removed cases
(`transform` 9.72 ms, `named import from json` 0.09 ms).

### Removals

1. **`packages/integrate-vitest/__tests__/index.spec.ts > transform`**
(whole file)
- Class: duplicate. It calls `new
OxcTransformer(process.cwd()).transformAsync("foo.ts", …)` and checks
the CommonJS output; `packages/integrate-module/src/index.ts > should
resolve native addon` does the same with `"index.ts"`.
- Mutation M4: `src/lib.rs` `TransformTask::compute` emits `Module::Esm`
instead of `Module::CommonJS`. Fails both this test and `should resolve
native addon`.
   - Still covered by `should resolve native addon`.
2. **`packages/integrate-module/src/index.ts > named import from json`**
- Class: cannot fail when the product breaks. `import pkgJson from
"../package.json" with { type: "json" }` is loaded by Node itself, not
by oxc-node's JSON loader, and the test only reads `pkgJson.version`, a
default-export property.
- Mutation M5: `src/lib.rs` JSON loader emits `export default {}`. 9
`json-modules` / percent-encoded Vitest cases fail; all of
integrate-module, including this test, passes.
- Mutation M3: the JSON loader drops the synthesised named exports.
`json-modules.spec.ts > a named import` and `> a paths alias keeps the
synthesised named exports` fail; this test passes.
- The original feature (#20, named JSON imports) stays covered by those
two `json-modules.spec.ts` cases; `resolve package.json` keeps the
import itself exercised.

### Kept after defense

- `stdin-tty.spec.ts > CLI preserves TTY properties when stdin is a TTY`
and `> CLI with node directly preserves TTY (baseline comparison)`.
Mutation M6, `process.stdin.isTTY = false;` at the top of
`packages/core/register.mjs`, fails only these two across all three
suites (re-run on this branch). Each now carries a comment saying so.

### Case counts

| suite | before | after | delta |
|---|---|---|---|
| integrate-vitest (Vitest) | 600 (581 passed, 19 skipped) | 599 (580
passed, 19 skipped) | −1 |
| integrate-module | 21 | 20 | −1 |
| integrate-module-bundler | 22 | 22 | 0 |

0 failures before and after.

### What ran and what did not

- Ran: all three JS suites at `6d5376d` and on this branch; mutations
M3, M4, M5 (with an addon rebuild each) and M6, each reverted
afterwards; `vp check --no-fmt` (lint and type-check, clean on 99
files); `vp fmt --check` on the touched files (clean).
- `vp check` reports a formatting issue in `lerna.json`; it reports the
same at `6d5376d`, and this PR does not touch that file.
- Not run: the Rust tests, the bench, the WASI build, and other
platforms.

Ages: `transform` dates from before #663 (2026-07-04); `named import
from json` from #20 (2024-07-18). Neither is in a permission or security
suite.

To revert: `git revert 80ceedd`.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01PxVsmvB9xfZKfVnUonY8kf)_

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.

Support named import from json file

1 participant