jsr icon indicating copy to clipboard operation
jsr copied to clipboard

index.js and index.d.ts files are getting ignored when building a tarball

Open teidesu opened this issue 1 year ago • 3 comments

mcve

deno.json

{
  "name": "@foo/bar",
  "version": "1.0.0",
  "exports": {
    ".": "./index.js"
  }
}

index.js

export const foo = 123

index.d.ts

export const foo: number

expected result

the tarball gets built and published correctly

actual result

the --dry-run output doesn't include these files:

Simulating publish of @foo/[email protected] with files:
   file:///path/to/LICENSE (1.04KB)
   file:///path/to/deno.json (88B)
Warning Aborting due to --dry-run

and actual publish errors out due to index.js not being present (linefeed for readability):

Failed to publish @foo/bar at 1.0.0: invalid 'exports' field in config file '/deno.json': 
  export '.' references entrypoint '/index.js' which does not exist

teidesu avatar Apr 09 '24 00:04 teidesu

Do you have a .gitignore?

lucacasonato avatar Apr 09 '24 08:04 lucacasonato

i do.. thanks

though it is pretty unexpected that it's getting in the way, especially considering that

  • i initially had excludes in deno.json, which i would expect to override gitignore instead of adding on top of it (like .npmignore does)
  • i had it somewhere in parent directories, not in the package directly

maybe error could be improved when an entrypoint is ignored by gitignore (or anything else)?

teidesu avatar Apr 09 '24 09:04 teidesu

Thanks for the feedback. The docs mention that exclude is stacked on .gitignore (https://jsr.io/docs/publishing-packages#filtering-files). This is done to reduce the amount of places one has to write the same ignore rules (for things like .env).

We do have docs for the exact scenario you ran into: https://jsr.io/docs/publishing-packages#un-gitignoring-files-when-not-using-include.

We can certainly improve the error messages here - @dsherret I thought we already errored in this case. Do you know why we are not?

lucacasonato avatar Apr 10 '24 10:04 lucacasonato

Duplicate of #289

lucacasonato avatar Nov 08 '24 13:11 lucacasonato