flekschas / svelte-simple-modal

A simple, small, and content-agnostic modal for Svelte v3 and v4
https://svelte.dev/repl/b95ce66b0ef34064a34afc5c0249f313
MIT License
422 stars 30 forks source link

Internal server error: Failed to resolve entry for package "svelte-simple-modal". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "svelte-simple-modal" package #107

Closed FluffyDiscord closed 7 months ago

FluffyDiscord commented 12 months ago

I had to update the plugin today, since I have been using fork, which got removed.

The following line of code throws exception an no longer works.

<script lang="ts">
    import {bind} from "svelte-simple-modal"
</script

vite: 4.0.4 svelte: 3.55.1 svelte-simple-modal: 1.6.1 @sveltejs/vite-plugin-svelte: 1.0.0-next.42 svelte-preprocess: 4.10.6

vite.config.js

import {defineConfig} from "vite"
import { svelte } from "@sveltejs/vite-plugin-svelte"
import sveltePreprocess from "svelte-preprocess"

export default defineConfig({
    plugins: [
        svelte({
            preprocess: [
                sveltePreprocess({ typescript: true }),
            ],
            hot: {
                preserveLocalState: true,
                optimistic: true
            },
        }),
    ],
    server: {
        port: 3000,
    },
    build: {
        rollupOptions: {
            input: {
                app: "./assets/app.ts",
            },
        },
    },
    resolve: {
        dedupe: ["svelte",  "svelte/transition", "svelte/internal"],
        alias: [
            {
                find: /^~.+/,
                replacement: (val) => {
                    return val.replace(/^~/, "");
                },
            },
        ],
    },
});

version 1.5.1 works fine

sirinsidiator commented 7 months ago

I just hit the same problem after updating a project of mine and it looks like the latest version limits the exported files in package.json via the exports field, but does not include the file specified in types. After changing it to the following, it works for my case:

  "exports": {
    ".": {
      "svelte": "./src/index.js",
      "types": "./types/index.d.ts"
    }
  },
flekschas commented 7 months ago

@sirinsidiator thanks for taking a stab at it! Do you want to create a PR with your change? Happy to get it merged asap

sirinsidiator commented 7 months ago

I don't have the project checked out (only stabbed around in the node_modules folder), so it would be faster if you could just add the line yourself.

flekschas commented 7 months ago

Addressed in v1.6.2 as suggested by @sirinsidiator. Closing this but please reopen if it's still an issue.