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

directory import is not supported resolving ES modules imported from csv-parse #712

Open
6 tasks done
danawoodman opened this issue Apr 23, 2024 · 0 comments
Open
6 tasks done
Labels
to triage This issue needs to be triaged

Comments

@danawoodman
Copy link

danawoodman commented Apr 23, 2024

Describe the bug

Importing csv-parse's browser sync package in Svelte component breaks Histoire

import { parse } from "csv-parse/browser/esm/sync";

The resulting error:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/path/to/app/packages/components/node_modules/csv-parse/dist/esm' is not supported resolving ES modules imported from /path/to/app/node_modules/histoire/node_modules/vite-node/dist/client.mjs
Did you mean to import /path/to/app/packages/components/node_modules/csv-parse/dist/esm/index.js?
    at finalizeResolution (node:internal/modules/esm/resolve:249:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1121:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:328:34)
    at importModuleDynamically (node:internal/modules/esm/translators:146:35)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:176:14)
    at ViteNodeRunner.importExternalModule (file:///path/to/app/node_modules/histoire/node_modules/vite-node/dist/client.mjs:357:5)

The recomended import path is invalid and irrelevant since they have named export paths, as seen here

Reproduction

Simply import csv-parse/browser/esm/sync into a component then write a story for that component.

https://github.com/danawoodman/histoire-csv-parse-bug

System Info

System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M2
    Memory: 157.14 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/Library/Caches/fnm_multishells/28490_1713902179205/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/28490_1713902179205/bin/yarn
    npm: 10.2.4 - ~/Library/Caches/fnm_multishells/28490_1713902179205/bin/npm
    pnpm: 8.7.1 - ~/Library/Caches/fnm_multishells/28490_1713902179205/bin/pnpm
    bun: 1.1.2 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 123.1.64.116
    Chrome: 124.0.6367.62
    Safari: 17.4.1

Deps:
    "@histoire/plugin-svelte": "^0.17.17",
    "histoire": "^0.17.17",
    "csv-parse": "^5.5.5",
    "svelte": "^4.2.15",
    "vite": "^5.2.10",

Used Package Manager

npm

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant