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

Support Sveltekit 2 which requires an exports condition in package.json #49

Closed
fredguest opened this issue Dec 15, 2023 · 2 comments
Closed

Comments

@fredguest
Copy link

fredguest commented Dec 15, 2023

To recreate the issue, add svelte-easy-crop to a Sveltekit 2 project and npm install.

You will see the following warning:

[vite-plugin-svelte] WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.

Sveltekit 2 adds a dependency on vite-plugin-svelte, which requires an exports condition in package.json as described here under the "missing exports condition" header:

https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition

Currently, vite-plugin-svelte still resolves svelte-easy-crop as a fallback, but in a future release this will be removed and without the exports condition it will fail.

It may also be worth upgrading svelte-easy-crop to use Sveltekit 2 itself.

@Davidonium
Copy link
Contributor

Davidonium commented Dec 22, 2023

I am also running into this, I checked out the project and running yarn package outputs a package.json file that should fix the warnings, see an example:

(the snippet I had before was incorrect)

And this is the package.json under node_modules when installed as a dependency (which is the same as the one generated by svelte-package):

{
  "name": "svelte-easy-crop",
  "version": "2.0.1",
  "description": "A Svelte component to crop images with easy interactions",
  "homepage": "https://github.com/ValentinH/svelte-easy-crop",
  "repository": {
    "type": "git",
    "url": "https://github.com/ValentinH/svelte-easy-crop"
  },
  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },
  "author": "Valentin Hervieu <[email protected]>",
  "license": "MIT",
  "keywords": [
    "svelte",
    "image crop",
    "cropper"
  ],
  "devDependencies": {
    "@sveltejs/adapter-auto": "^1.0.2",
    "@sveltejs/kit": "^1.0.0",
    "@sveltejs/package": "^1.0.0",
    "@typescript-eslint/eslint-plugin": "^5.45.0",
    "@typescript-eslint/parser": "^5.45.0",
    "cypress": "^12.4.1",
    "eslint": "^8.28.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-cypress": "^2.12.1",
    "eslint-plugin-svelte3": "^4.0.0",
    "prettier": "^2.8.0",
    "prettier-plugin-svelte": "^2.8.1",
    "query-string": "^8.1.0",
    "start-server-and-test": "^1.15.3",
    "svelte": "^3.54.0",
    "svelte-check": "^3.0.1",
    "tslib": "^2.4.1",
    "typescript": "^4.9.3",
    "vite": "^4.0.0",
    "vitest": "^0.28.3"
  },
  "type": "module",
  "exports": { // there's no "svelte" entry
    "./package.json": "./package.json",
    "./Cropper.svelte": "./Cropper.svelte",
    "./helpers.test": "./helpers.test.js",
    "./helpers": "./helpers.js",
    ".": "./index.js",
    "./types": "./types.js"
  },
  "svelte": "./index.js"
}

@fredguest
Copy link
Author

Fixed by #50

Cheers @Davidonium and @ValentinH

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