Skip to content

dist/ contents don't match package.json exports map — consumers hit 404 on ESM import #3

Description

@loadfix

Problem

This breaks downstream consumers today. The published package (xlsx-preview@0.0.2) declares in `package.json`:

```json
"types": "dist/xlsx-preview.d.ts",
"exports": {
".": {
"import": "./dist/xlsx-preview.mjs",
"require": "./dist/xlsx-preview.js",
"types": "./dist/xlsx-preview.d.ts"
}
}
```

But `dist/` contains only:

```
xlsx-preview.js (UMD)
xlsx-preview.js.map
```

Missing: `xlsx-preview.mjs`, `xlsx-preview.min.js`, `xlsx-preview.min.mjs`, `xlsx-preview.d.ts`.

Repro

  • Bundler consumer doing `import { parseAsync } from 'xlsx-preview'`: module resolution walks `exports.import` to `./dist/xlsx-preview.mjs` → ENOENT.
  • TypeScript consumer: looks for `./dist/xlsx-preview.d.ts` → ENOENT, types fall back to `any`.
  • Only `require('xlsx-preview')` (CommonJS / UMD) currently works as advertised.

Root cause

`rollup.config.mjs` lines 29-63 only emit `.mjs` / `.d.ts` / `.min.*` under `BUILD=production`. The default `npm run build` emits only UMD. The committed `dist/` reflects a non-production build.

Two fix options

Option 1 (recommended): Update `scripts.build` to invoke `build-prod` equivalent so the committed `dist/` matches the advertised surface. Verify all five artifacts are produced and committed.

Option 2: Narrow `package.json` `exports` to the two files that actually exist, dropping the `.mjs` / `.d.ts` advertisements until build is fixed.

Option 1 is better — ESM + types are what consumers expect from a modern TS library.

Blocker for

  • npm publish (would ship a broken package as-is)
  • any downstream project migrating docxjs → xlsxjs that relies on the same import shape

Surfaced by: 2026-05-05 consistency audit. Previously noted in `TODO.md` § "Audit findings 2026-05-05" item 1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions