Skip to content

fix(package): correct subpath export resolution for all module types#129

Merged
hristoterezov merged 1 commit into
masterfrom
fix-exports
May 11, 2026
Merged

fix(package): correct subpath export resolution for all module types#129
hristoterezov merged 1 commit into
masterfrom
fix-exports

Conversation

@hristoterezov

@hristoterezov hristoterezov commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix the subpath exports in package.json so all documented import paths resolve correctly. The previous wildcard mapped ./* to ./dist/* without extensions, which prevented Node's ESM resolver and bundlers from locating the actual built files.
  • The package contains modules with three different layouts, so a single wildcard can't cover them all:
    • Directory modules (avatar, browser-detection, jitsi-local-storage, random, transport) expose an index file. The wildcard ./* now maps to ./dist/*/index.js and ./dist/*/index.d.ts.
    • Single-file json module lives at the package root, so add an explicit ./json export pointing at ./dist/json.js / ./dist/json.d.ts.
    • polyfills/ exposes individual files rather than a barrel, so add a dedicated ./polyfills/* wildcard that maps each name to ./dist/polyfills/*.js / ./dist/polyfills/*.d.ts.

Test plan

  • npm run build succeeds.
  • Import a directory-module subpath (e.g. import { randomHexString } from '@jitsi/js-utils/random') and verify it resolves to dist/random/index.js with matching .d.ts types.
  • import { safeJsonParse } from '@jitsi/js-utils/json' resolves to dist/json.js.
  • Importing an individual polyfill (e.g. @jitsi/js-utils/polyfills/<name>) resolves to the matching file under dist/polyfills/.
  • Main entry import (@jitsi/js-utils) still works unchanged.

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (777aa21) to head (77b80ce).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #129   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         1870      1870           
  Branches        47        47           
=========================================
  Hits          1870      1870           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 777aa21...77b80ce. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The previous wildcard subpath export mapped `./*` to `./dist/*` without
extensions, so bundlers and Node's ESM resolver could not locate the
actual files for imports like `@jitsi/js-utils/random`.

The modules in this package use different layouts, so a single wildcard
cannot cover all of them:
- Directory modules (avatar, browser-detection, jitsi-local-storage,
  random, transport) expose an `index` file, so map `./*` to
  `./dist/*/index.{js,d.ts}`.
- `json` is a single file at the package root, so add an explicit
  `./json` export pointing at `./dist/json.{js,d.ts}`.
- `polyfills/` exposes individual files rather than a barrel, so add a
  dedicated `./polyfills/*` wildcard that maps each name to
  `./dist/polyfills/*.{js,d.ts}`.
@hristoterezov hristoterezov changed the title fix(package): resolve subpath exports to correct file extensions fix(package): correct subpath export resolution for all module types May 11, 2026
@hristoterezov hristoterezov merged commit 202fe88 into master May 11, 2026
6 checks passed
@hristoterezov hristoterezov deleted the fix-exports branch May 11, 2026 23:36
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