"exports" in package.json in combination with type exports #1726
ehrencrona
started this conversation in
General
Replies: 1 comment
-
Why not file this as an issue? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If a module uses
exports
in thepackage.json
to restrict access to only certain packages public, but also definestypes
, then you will not be able to access those types when importing the module with Snowpack (unless there is also a main module).I.e. a module might have the following in its
package.json
:in which case an import of a type defined in
index.d.ts
e.g.import { SomeType } from "module";
will not work with Snowpack.It will work with
tsc
because it currently ignoresexports
entirely. You might nevertheless want to defineexports
to make packages private to importing projects that are not using TypeScript.Repro: https://github.com/ehrencrona/snowpack-exports-with-types-repro
Go to
depender
and runnpm run dev
; you'll getPackage "dependee" not found
Removing the type import in
src/index.ts
will make it work (once you've done this, it will work even if you put it back in unless you nuke the Snowpack cache).Note that adding
index.d.ts
to theexports
will not help; requiring this might be a fairly easy way of supporting this usecase.Beta Was this translation helpful? Give feedback.
All reactions