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

adds a font example to demonstrate why commonjs is needed #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

the-simian
Copy link

I was getting an error that vite could not understand 'require':
image

ReferenceError: require is not defined
    at FontLoader (http://localhost:6006/FontLoader.tsx:27:19)
    at renderWithHooks (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:11548:26)
    at mountIndeterminateComponent (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:14926:21)
    at beginWork (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:15914:22)
    at beginWork$1 (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:19753:22)
    at performUnitOfWork (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:19198:20)
    at workLoopSync (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:19137:13)
    at renderRootSync (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:19116:15)
    at recoverFromConcurrentError (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:18736:28)
    at performConcurrentWorkOnRoot (http://localhost:6006/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-7263HWE7.js?v=7c0def07:18684:30)

However when you add the commonjs plugin it works:

import { defineConfig } from 'vite';
import commonjs from 'vite-plugin-commonjs';
export default defineConfig({
  plugins: [commonjs()],
});

image

I added this because this is the recommended way to handle fonts for the web with expo-font you can include fonts in the bundle for mobile, but it won't work on the web since there's really no equivalent.

@the-simian
Copy link
Author

this is resolved by storybookjs/storybook#30305, and when that's merged this PR isn't needed

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

Successfully merging this pull request may close these issues.

1 participant