histoire-dev / histoire-dev/histoire

Build app is not loading stories - "Cannot read properties of undefined (reading 'find')"

Open
#759 1 comment 2 reactions 0 assignees View on GitHub
to triage
Dominant language
TypeScript
Stars
3.6k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

I'm using the latest version of histoire with nuxt.

In histoire dev mode everything works ok, but the build app it does not work. I can load the UI just fine, but when I try to click on a story I get the following error in `bundle-sandbox-BYbFb-tO.js`
> Uncaught TypeError: Cannot read properties of undefined (reading 'find')

When I inspect the file all imported name are undefined
```
import { m as mapFile, f as files, _ as _sfc_main, h as histoireConfig, i as isDark } from "./GenericMountStory.vue2-D3-GW49k.js";
```
I inspected `GenericMountStory.vue2-D3-GW49k.js` and it looks ok. The files are there.

I can see that all exported names are set in a promise `then`. I added a log statement in the `then` function and I can see that the then resolves **after** the import, thus the undefined imports.

### Reproduction

I currently do not have a reproduction

### System Info

```shell
System:
OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 2.46 GB / 15.30 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
Yarn: 1.22.19 - ~/.npm-global/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 9.9.0 - ~/.local/share/pnpm/pnpm
Browsers:
Chrome: 128.0.6613.119
Chromium: 128.0.6613.113
npmPackages:
@histoire/plugin-nuxt: ^0.17.17 => 0.17.17
histoire: ^0.17.17 => 0.17.17
```

### Used Package Manager

pnpm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/histoire-dev/histoire/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/histoire-dev/histoire/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://histoire.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/histoire-dev/histoire/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/histoire-dev/histoire/discussions).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Nuxt build-mode failure and inspect bundle-sandbox-BYbFb-tO.js alongside GenericMountStory.vue2-D3-GW49k.js. Trace when the exported names become available relative to the import, then verify that clicking a story loads successfully without the undefined find error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript, vite
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.