8000 feat(js-api): add spanInBytesToSpanInCodeUnits in subpath exports by regseb · Pull Request #9940 · biomejs/biome · GitHub
[go: up one dir, main page]

Skip to content

feat(js-api): add spanInBytesToSpanInCodeUnits in subpath exports - #9940

Merged
dyc3 merged 2 commits into
biomejs:nextfrom
regseb:spanInBytesToSpanInCodeUnits
Jun 13, 2026
Merged

dyc3 merged 2 commits into
biomejs:nextfrom
regseb:spanInBytesToSpanInCodeUnits

Conversation

@regseb
@regseb regseb commented Apr 12, 2026 •
Copy link
Copy Markdown
Contributor

Summary

Export the new spanInBytesToSpanInCodeUnits function (issue #4035 / PR #8944 / release v6.0.0) to the subpath exports of the @biomejs/js-api package.

The goal is to have the same exports in both the main and the subpaths.

Test Plan

n/a

Docs

n/a

@changeset-bot
changeset-bot Bot commented Apr 12, 2026 •
Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e01e9ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@biomejs/js-api Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
coderabbitai Bot commented Apr 12, 2026 •
Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76d31cb6-7310-4bdf-80a3-9fa90f1aecda

📥 Commits

Reviewing files that changed from the base of the PR and between 11ea2f7 and e01e9ef.

📒 Files selected for processing (1)
  • packages/@biomejs/js-api/README.md

Walkthrough

A new helper function, spanInBytesToSpanInCodeUnits, has been exported from @biomejs/js-api across its subpath entry points (nodejs, bundler, and web). The helper converts diagnostic spans expressed in bytes to JavaScript UTF-16 code-unit offsets for correct slicing, and the README was updated with usage examples. A Changesets entry documents this addition as a minor release.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding spanInBytesToSpanInCodeUnits to subpath exports in the js-api package.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (consistency between main and subpath exports), referencing prior work, and providing context about TypeScript import issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@regseb
regseb commented Jun 12, 2026
Copy link
Copy Markdown
Contributor Author

@dyc3 The spanInBytesToSpanInCodeUnits function is exported in JavaScript APIs v6.0.0. Can you merge this PR so that the function is also available in subpaths?

import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api/nodejs";

@ematipico
Copy link
Copy Markdown
Member

@regseb can you explain what's the problem? Why do we need the same function exported by the sub paths too?

@regseb
regseb commented Jun 12, 2026 •
Copy link
Copy Markdown
Contributor Author

#6465 The main export imports the types for the three dependencies: "@biomejs/wasm-bundler", "@biomejs/wasm-nodejs", and "@biomejs/wasm-web".

In my project, I only have the dependencies "@biomejs/js-api" and "@biomejs/wasm-nodejs". And I'm using the subpath "@biomejs/js-api/nodejs". So if I use the main export to get the spanInBytesToSpanInCodeUnits function, TypeScript will throw an error: Cannot find module '@biomejs/wasm-web'

I would like to:

import { Biome, spanInBytesToSpanInCodeUnits } from "@biomejs/js-api/nodejs";

To reproduce the problem:

  • package.json

    {
      "name": "testcase",
      "version": "1.0.0",
      "type": "module",
      "dependencies": {
        "@biomejs/js-api": "6.0.0",
        "@biomejs/wasm-nodejs": "2.5.0",
        "typescript": "6.0.3"
      }
    }
  • index.ts

    import { Biome } from "@biomejs/js-api/nodejs";
    import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api";
  1. npm install

  2. npx tsc -lib esnext index.ts

    node_modules/@biomejs/js-api/dist/index.d.ts:1:93 - error TS2307: Cannot find module '@biomejs/wasm-bundler' or its corresponding type declarations.
    
    1 import type { Configuration as ConfigurationBundler, Diagnostic as DiagnosticBundler } from "@biomejs/wasm-bundler";
                                                                                                  ~~~~~~~~~~~~~~~~~~~~~~~
    
    node_modules/@biomejs/js-api/dist/index.d.ts:3:85 - error TS2307: Cannot find module '@biomejs/wasm-web' or its corresponding type declarations.
    
    3 import type { Configuration as ConfigurationWeb, Diagnostic as DiagnosticWeb } from "@biomejs/wasm-web";
                                                                                          ~~~~~~~~~~~~~~~~~~~
    
    
    Found 2 errors in the same file, starting at: node_modules/@biomejs/js-api/dist/index.d.ts:1
    

@ematipico ematipico left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please update the readme? I suppose it's something we should at least mention in the docs

@regseb
regseb commented Jun 13, 2026
Copy link
Copy Markdown
Contributor Author

I've added an example to the README.

@dyc3
dyc3 merged commit 1aefcb1 into biomejs:next Jun 13, 2026
6 checks passed
@regseb
regseb deleted the spanInBytesToSpanInCodeUnits branch June 13, 2026 15:30
@ematipico ematipico added this to the Biome v2.6 milestone Aug 24, 2026
@github-actions github-actions Bot mentioned this pull request Oct 6, 2026
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.

3 participants

0