janosh / svelte-multiselect

Keyboard-friendly, accessible and highly customizable multi-select component
https://multiselect.janosh.dev
MIT License
279 stars 34 forks source link

Can't resolve './types' #258

Open Hmerman6006 opened 1 year ago

Hmerman6006 commented 1 year ago

When importing the component I get below output from npm:

ERROR in ./node_modules/svelte-multiselect/dist/index.js 5:0-24
.Module not found: Error: Can't resolve './types' in '/var/www/html/orodata-website/node_modules/svelte-multiselect/dist'
Did you mean 'types.js'?
BREAKING CHANGE: The request './types' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

I am not using TypeScript and I see the types.js file exports an empty object. How do I resolve this?

janosh commented 1 year ago

Could you post a StackBlitz repro? Would be good to know what package versions you're using.

Hmerman6006 commented 1 year ago

Was a fresh install in a Laravel 8 environment with following package.json dependencies:

"scripts": {
      "dev": "mix",
      "development": "mix",
      "watch": "mix watch",
      "watch-poll": "mix watch -- --watch-options-poll=1000",
      "hot": "mix watch --hot",
      "prod": "mix --production",
      "production": "mix --production"
  },
  "devDependencies": {
      "@babel/core": "^7.16.0",
      "@babel/plugin-syntax-dynamic-import": "^7.8.3",
      "@babel/preset-env": "^7.16.0",
      "babel-loader": "^8.2.3",
      "laravel-mix": "^6.0.49",
      "laravel-mix-svelte": "^0.5.0",
      "lodash": "^4.17.19",
      "resolve-url-loader": "^3.1.0",
      "sass": "^1.32.13",
      "sass-loader": "^11.1.1",
      "svelte": "^3.1.0",
      "svelte-loader": "^2.13.4",
  },
  "dependencies": {
      "laravel-svelte-direct-mix": "0.0.1",
      "svelte-multiselect": "^10.1.0"
  }

Tried downgrading to v9, but did not work. Have not used StackBlitz yet: will try this weekend and send you feedback.

janosh commented 1 year ago

Are you setting

"type": "module",

in your package.json?

rocinante42 commented 1 year ago

+1 to this, I'm facing exactly the same issue

rocinante42 commented 1 year ago

A fresh npm install solved it 🤔 weird, will look further into this to see what was triggering it

627426p commented 10 months ago

Ill add to this, I'm facing the same issue. Changing export * from './types'; to export * from './types.js'; in both the dist/index.js and dist/index.d.ts fixes it. Fresh install did not change anything for me.

hotmeteor commented 6 months ago

I'm also hitting this error on an old project, same package.json as @Hmerman6006's example

janosh commented 6 months ago

same question

Are you setting

"type": "module",

in your package.json?

hotmeteor commented 6 months ago

@janosh No I'm not

Thanks for the quick reply

janosh commented 6 months ago

i'm not firm on the details but i think Svelte is ESM-only at this point

hotmeteor commented 6 months ago

Yeah but we're on Svelte 3, and this plugin used to work. I've even locked it back to version ^8.0 and no luck. Ah well, maybe someone finds something.

Edit:

OK "svelte": "^3.0.0" + "svelte-multiselect": "^7.0.0" seems to do the trick, so not sure what happened starting with v8