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

[bug]: algoliasearch fails with tsx and ESM ("type": "module") #1565

Open
karlhorky opened this issue Oct 18, 2024 · 1 comment
Open

[bug]: algoliasearch fails with tsx and ESM ("type": "module") #1565

karlhorky opened this issue Oct 18, 2024 · 1 comment
Labels

Comments

@karlhorky
Copy link

karlhorky commented Oct 18, 2024

I originally reported this over here, but the "skipLibCheck": false was a red herring for my particular issue (still leaving it open in case it's interesting on its own): #1564


Description

CodeSandbox: https://codesandbox.io/p/devbox/p6w2mq?file=%2F.codesandbox%2Ftasks.json%3A12%2C15

Running algoliasearch with tsx and ESM ("type": "module") will cause a crash

  1. Create an ESM project with "type": "module" in package.json
  2. Add algoliasearch and tsx
  3. Create a index.ts file with a simple named import of algoliasearch
  4. Run pnpm tsx index.ts
  5. 💥 Observe the crash with the error message below

Screenshot 2024-10-18 at 18 03 22

cc @shortcuts wonder if this is related to algolia/api-clients-automation#3966 (considering that the error is in a .ts file)

Client

Search

Version

5.9.1

Relevant log output

pnpm tsx index.ts
/project/workspace/node_modules/.pnpm/[email protected]/node_modules/algoliasearch/builds/models.ts:19
import { EventType } from '@algolia/client-personalization';
         ^

SyntaxError: The requested module '@algolia/client-personalization' does not provide an export named 'EventType'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.12.0
@nfarina
Copy link

nfarina commented Oct 18, 2024

This is blocking our deploys and reverting to earlier versions doesn't seem to help. Not sure why yet - I didn't even upgrade the algoliasearch package and this just started happening on its own. Doesn't make sense but putting it out there.

Reverting to 5.8.1 did fix it for now. (our deploy script wasn't respecting the package.json resolutions field we use locally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants