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

[Bug]: Cannot rename import #23592

Closed
nhandl3 opened this issue Jul 25, 2023 · 1 comment · Fixed by #24406
Closed

[Bug]: Cannot rename import #23592

nhandl3 opened this issue Jul 25, 2023 · 1 comment · Fixed by #24406

Comments

@nhandl3
Copy link

nhandl3 commented Jul 25, 2023

Describe the bug

I use Next.js 13 Font Module in following code lib/fonts.ts

import { Inter as FontSans } from 'next/font/google'

export const fontSans = FontSans({
  subsets: ['latin'],
  variable: '--font-sans'
})

It works normally with next start but failed in storybook. Workaround is to remove the renaming:

import { Inter } from 'next/font/google'

export const fontSans = Inter({
  subsets: ['latin'],
  variable: '--font-sans'
})

To Reproduce

No response

System

Environment Info:

  System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
  Browsers:
    Chrome: 114.0.5735.248
    Safari: 16.5.2
  npmPackages:
    @storybook/addon-essentials: ^7.1.1 => 7.1.1 
    @storybook/addon-interactions: ^7.1.1 => 7.1.1 
    @storybook/addon-links: ^7.1.1 => 7.1.1 
    @storybook/addon-styling: ^1.3.4 => 1.3.4 
    @storybook/blocks: ^7.1.1 => 7.1.1 
    @storybook/nextjs: ^7.1.1 => 7.1.1 
    @storybook/react: ^7.1.1 => 7.1.1 
    @storybook/testing-library: ^0.2.0 => 0.2.0

Additional context

No response

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Jul 25, 2023

Hi @nhandl3,

That's a known limitation of the implementation. Would you like to contribute to fixing this issue? If you are familiar a bit with AST transformations, you could take a look at https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/font/babel/helpers.ts

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

Successfully merging a pull request may close this issue.

3 participants