privatenumber / pkgroll

📦 Zero-config package bundler for Node.js + TypeScript
MIT License
1k stars 23 forks source link

Ignore unresolvable entry paths #60

Open muratgozel opened 2 months ago

muratgozel commented 2 months ago

Problem

for the following exports:

  "exports": {
    "./modules/dayjs.js": {
      "import": {
        "types": "./dist/modules/dayjs.d.ts",
        "default": "./dist/modules/dayjs.js"
      }
    },
    "./svelte/store/device.js": {
      "import": {
        "types": "./dist/svelte/store/device.d.ts",
        "default": "./dist/svelte/store/device.js"
      }
    },
    "./Banner.svelte": {
      "types": "./dist/svelte/components/elements/LoadingBar.svelte.d.ts",
      "svelte": "./dist/svelte/components/elements/LoadingBar.svelte"
    },
  },

the lib is trying to read .svelte files too which is not recognized in node env:

Error: Could not find matching source file for export path "./dist/svelte/components/elements/Banner.svelte"

Expected behavior

i package svelte files with a different bundler (@sveltejs/package) therefore i would expect an option to ignore some files in exports.

Minimal reproduction URL

https://stackblitz.com/edit/vitejs-vite-kw52rd?file=package.json

Version

v2.0.2

Node.js version

v20.9

Package manager

npm

Operating system

macOS

Contributions

privatenumber commented 2 months ago

This is currently behaving expectedly so it's not a bug.

In regards to this feature request, it's hard to draw the line as to when an unresolvable path should be ignored because what if none of the paths are resolvable? Surely, that should error?

Or what if there's an export path (amongst a few) that should be resolved and built, but is missing (e.g. maybe forgot to add file to git), and the build unexpectedly passes because it gets ignored?

muratgozel commented 2 months ago

i meant ignore natively not by configuring, node for example isnt able to resolve .svelte files so pkgroll should ignore them instead of raising an error.

pkgroll have a complete control on exports property, which is good but also bad for other kind of pkgroll-like libraries that is willing to use exports just like pkgroll in the same project.