Skip to content

fix: add exports field to package.json for CSS subpath resolution#5795

Open
renevanpelt wants to merge 1 commit intoxtermjs:masterfrom
renevanpelt:master
Open

fix: add exports field to package.json for CSS subpath resolution#5795
renevanpelt wants to merge 1 commit intoxtermjs:masterfrom
renevanpelt:master

Conversation

@renevanpelt
Copy link
Copy Markdown

Problem

The published @xterm/xterm package has no exports field in its package.json. In strict module resolution environments — such as pnpm workspaces with moduleResolution: bundler or node16 — subpath imports like:

import '@xterm/xterm/css/xterm.css'

fail with an error along the lines of "Package subpath './css/xterm.css' is not defined by 'exports'".

Fix

Add an exports map that exposes:

  • "." — the existing main entry (./lib/xterm.js) for both require and import
  • "./css/xterm.css" — the stylesheet, so CSS subpath imports resolve correctly
"exports": {
  ".": {
    "require": "./lib/xterm.js",
    "import": "./lib/xterm.js",
    "default": "./lib/xterm.js"
  },
  "./css/xterm.css": "./css/xterm.css"
}

No source files are changed. All existing unit tests (2242) continue to pass.

Without an exports field, strict module resolution environments (e.g.
pnpm workspaces with moduleResolution: bundler or node16) cannot
resolve subpath imports such as `import '@xterm/xterm/css/xterm.css'`.

Add an exports map exposing the main entry point and the CSS file.
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