thecodejack / svelte-file-dropzone

Svelte component for fileupload
https://svelte-file-dropzone.netlify.app/
240 stars 43 forks source link

vitest - Failed to resolve entry for package "svelte-file-dropzone" #147

Closed codinkai closed 8 months ago

codinkai commented 11 months ago

Hi, when running vitest, I get the following error after installing "svelte-file-dropzone":

$ npm run test

> my-app@0.0.1 test
> vitest

 DEV  v0.34.6 C:/Workspace/playground/my-app

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Error: Failed to resolve entry for package "svelte-file-dropzone". The package may have incorrect main/module/exports specified in 
its package.json: Missing "." specifier in "svelte-file-dropzone" package
 ❯ packageEntryFailure node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:28730:11
 ❯ resolvePackageEntry node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:28725:9
 ❯ tryNodeResolve node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:28458:20
 ❯ Context.resolveId node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:28217:28
 ❯ Object.resolveId node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:44279:64
 ❯ async file:/C:/Workspace/playground/my-app/node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:65919:21
 ❯ async file:/C:/Workspace/playground/my-app/node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:44924:20
 ❯ addManuallyIncludedOptimizeDeps node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:46107:31
 ❯ optimizeServerSsrDeps node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:45711:5
 ❯ createDevSsrDepsOptimizer node_modules/vite/dist/node/chunks/dep-3bba9c7e.js:45629:22

Steps to recreate:

npm create svelte@latest my-app 
# Select DemoApp, TypeScript, ESLint, Prettier and Vitest

cd my-app
npm install

npx vitest src/*
# works

npm install svelte-file-dropzone
npx vitest src/* 
# FAILS

Do you know what might cause the problem?

codinkai commented 11 months ago

The issue can be fixed by changing the exports parameter to the following code snippet in the package.json and adding the empty files index.d.ts and index.js.

  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "svelte": "./dist/index.js"
    },
    "./Dropzone.svelte": {
      "types": "./dist/components/Dropzone.svelte.d.ts",
      "svelte": "./dist/components/Dropzone.svelte"
    }
  },
temqua commented 11 months ago

Same problem with vitest 0.34.6 and svelte-file-dropzone 2.0.2

codinkai commented 11 months ago

This fork works. https://github.com/northh-kai/svelte-file-dropzone/tree/master

JinIgarashi commented 11 months ago

I believe this bug can be fixed by my PR (https://github.com/thecodejack/svelte-file-dropzone/pull/144). I am not sure when they can merge this to main.

Alternatively, you can downgrade vitest to 0.33.0. the version above 0.33.1 does not work with this component.

JinIgarashi commented 9 months ago

Hello, everyone, we forked to our organisation and fixed this bug. published NPM package.

Also, I upgraded svelte3 to svelte4 in package.

You can use our package if you want.

https://www.npmjs.com/package/@undp-data/svelte-file-dropzone

thecodejack commented 8 months ago

Hi @JinIgarashi

Would you be able to create a new PR? I see you closed older one.

JinIgarashi commented 8 months ago

@thecodejack no, not easy to create a PR to this because there are several different fixes mixed in main branch of our forked repo. But the changes are not a lot, you can fix by following my repo's change.

https://github.com/UNDP-Data/svelte-file-dropzone/pull/1

major changes on PR are

If you are happy with these above changes except the last one (package name), I can create a PR to this repo immediately (I can just change package name to original one only), otherwise I have no time to extract only changes on this issue to make a PR. Thanks.

thecodejack commented 8 months ago

Please create the PR from your repo. I can look into that and merge further.

If possible avoid last 3 steps.

JinIgarashi commented 8 months ago

@thecodejack created new PR #150. you can merge it if you want

andoppomny commented 8 months ago

This ticket was closed, but the fix doesn't appear to be available in the published 2.0.2 package.