algolia / algolia/autocomplete

@algolia_autocomplete-js: Error on import

Open
#1,247 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
341
Avg merge
3d 1h
Merged PRs (30d)
5

Description

## Description
I have a new Svelte app and am getting an error with the module above.
`The requested module '/[node_modules/.vite/deps/@algolia_autocomplete-js.js](https://github.com/algolia/autocomplete/issues/node_modules/.vite/deps/@algolia_autocomplete-js.js)?t=1714511055987&v=b1e5f853' does not provide an export named 'default' (at +page.svelte:2:10)`

I don't have any code yet; i can't even import the package without the error being thrown.

### page.svelte
```

  import pkg from "@algolia/autocomplete-js";
  import algoliasearch from "algoliasearch/lite";
  import { onMount } from "svelte";
  import "@algolia/autocomplete-theme-classic";
  import { goto } from "$app/navigation";

  const { autocomplete, getAlgoliaResults } = pkg;


```

### package.json
```
{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "preview": "vite preview",
    "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
  },
  "devDependencies": {
    "@sveltejs/adapter-auto": "^3.2.0",
    "@sveltejs/kit": "^2.5.7",
    "@sveltejs/vite-plugin-svelte": "^3.1.0",
    "autoprefixer": "^10.4.19",
    "postcss": "^8.4.32",
    "postcss-load-config": "^5.0.3",
    "svelte": "^4.2.15",
    "svelte-check": "^3.7.0",
    "tailwindcss": "^3.4.3",
    "tslib": "^2.6.2",
    "typescript": "^5.4.5",
    "vite": "^5.2.10"
  },
  "type": "module",
  "dependencies": {
    "@algolia/autocomplete-js": "^1.17.0",
    "@algolia/autocomplete-theme-classic": "^1.17.0",
    "algoliasearch": "^4.23.3"
  }
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the import shown in page.svelte with the package versions listed in package.json, using the project's dev or build command. Compare the package's export behavior with the import in the example; done means the Svelte app imports the package without the reported default-export error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.