histoire-dev / histoire-dev/histoire

Web Worker breaks the build

Open
#600 2 comments 0 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

In my code I use the heic2any package, this package executes my code in Web Worker. When I try to run the Histoire build, I get an error:

```
Error while collecting story /home/mm/lib/docs/Components/**.story.vue:
ReferenceError: Worker is not defined
at /home/mm/lib/node_modules/heic2any/dist/heic2any.js:23:33
at /home/mm/lib/node_modules/heic2any/dist/heic2any.js:11:26
at /home/mm/lib/node_modules/heic2any/dist/heic2any.js:20:2
at ViteNodeRunner.runModule (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:342:11)
at ViteNodeRunner.directRequest (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:326:16)
at async ViteNodeRunner.cachedRequest (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:189:14)
at async ViteNodeRunner.dependencyRequest (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:223:12)
at async /home/mm/lib/source/hooks/useAssetManager/index.ts:2:31
at async ViteNodeRunner.runModule (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:342:5)
at async ViteNodeRunner.directRequest (file:///home/mm/lib/node_modules/vite-node/dist/client.mjs:326:5)
```

### Reproduction

1. Create a new histoire project
2. Install the heic2any package
3. Create a story in which the heic2any package will be executed

### System Info

```shell
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
npm: 9.8.1 - ~/lib/node_modules/.bin/npm
npmPackages:
@histoire/plugin-vue: ^0.17.1 => 0.17.1
@vitejs/plugin-vue: ^4.2.3 => 4.3.3
histoire: ^0.17.2 => 0.17.2
vite: ^4.4.5 => 4.4.9
```

### Used Package Manager

npm

### 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 at source/hooks/useAssetManager/index.ts and reproduce the Histoire build using the heic2any-based story described in the report. Trace the story-collection failure around the Web Worker error and confirm the build completes without `ReferenceError: Worker is not defined`.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.