Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken package.json main/module/exports configuration and types #5

Open
smellyshovel opened this issue Jan 7, 2025 · 1 comment
Open

Comments

@smellyshovel
Copy link

smellyshovel commented Jan 7, 2025

New Vite 6 with (TS 5+) setups give the following error:

There are types at '//node_modules/@placemarkio/polyline/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@placemarkio/polyline' library may need to update its package.json or typings.

Here's what Vite's docs say:

Recommended package.json for your lib:

{
  "name": "my-lib",
  "type": "module",
  "files": ["dist"],
  "main": "./dist/my-lib.umd.cjs",
  "module": "./dist/my-lib.js",
  "exports": {
    ".": {
      "import": "./dist/my-lib.js",
      "require": "./dist/my-lib.umd.cjs"
    }
  }
}

Also, the package incorrectly specifies types, so that consumer projects must manually do the following:

	"compilerOptions": {
		"paths": {
			"@placemarkio/polyline": ["/node_modules/@placemarkio/polyline/dist/index.d.ts"]
		}
	}

Expected behavior: importing the plugin should work out of the box with newer environments. Type declarations should also be imported automatically.

@tmcw
Copy link
Contributor

tmcw commented Jan 7, 2025

I'd be more than happy to accept a PR with a fix. Package.json entry points have been a moving target.

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

No branches or pull requests

2 participants