-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Docs: Add FAQ section for extensionless imports #33202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,39 @@ To fix this, you can wrap the package name inside your Storybook configuration f | |
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
| ## Extensionless imports in Storybook main config | ||
|
|
||
| When upgrading or running Storybook, you may see warnings about extensionless relative imports in `.storybook/main.<js|ts>` (for example: `import sharedMain from '../main'`). | ||
| Storybook requires explicit extensions in config imports to avoid this deprecation warning. | ||
|
|
||
| To fix the issue, just make sure to include the extension of the file (TypeScript or Javascript) you're importing: | ||
|
|
||
| ```ts title=".storybook/main.<js|ts>" | ||
| // Change from this 👇 | ||
| import sharedMain from '../main'; | ||
|
|
||
| // To this 👇 | ||
| import sharedMain from '../main.js'; // or .ts | ||
| ``` | ||
|
|
||
| ### For TypeScript users (`.storybook/main.ts`) | ||
| You will also need to configure TypeScript so these imports type-check without emitting JavaScript: | ||
|
|
||
| ```json title=".storybook/tsconfig.json" | ||
| { | ||
| "extends": "<path-to-your-main-tsconfig>", | ||
| "compilerOptions": { | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "noEmit": true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| <Callout variant="info"> | ||
| It is advisable to add a `.storybook/tsconfig.json` file so that you apply changes only to Storybook config files, and not your entire project. | ||
| </Callout> | ||
|
Comment on lines
+104
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid Callout markup (double The new FAQ section is very helpful, but the Callout at the end is currently invalid MDX:
This will break MDX/JSX parsing for the docs page. Suggested fix (and small style tweaks): -### For TypeScript users (`.storybook/main.ts`)
-You will also need to configure TypeScript so these imports type-check without emitting JavaScript:
+### For TypeScript users (`.storybook/main.ts`)
+You will also need to configure TypeScript so these imports type-check without emitting JavaScript:
```json title=".storybook/tsconfig.json"
{
"extends": "<path-to-your-main-tsconfig>",
"compilerOptions": {
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"noEmit": true
}
}-
In docs/faq.mdx around lines 104 to 135, the Callout markup is closed twice (a |
||
|
|
||
| ## How do I setup the new React Context Root API with Storybook? | ||
|
|
||
| If your installed React Version equals or is higher than 18.0.0, the new React Root API is automatically used and the newest React [concurrent features](https://reactjs.org/docs/concurrent-mode-intro.html) can be used. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor formatting issue: trailing space on line 42.
The deprecation message update looks good—shortening it to reference external documentation is a solid practice. However, line 42 has a trailing space after the colon.
Apply this diff to remove the trailing space:
deprecate(dedent` One or more extensionless imports detected: "${importPath}" in file "${currentFilePath}". - For more information on how to resolve the issue: + For more information on how to resolve the issue: https://storybook.js.org/docs/faq#extensionless-imports-in-storybookmaints-and-required-ts-extensions `);📝 Committable suggestion
🤖 Prompt for AI Agents