Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Allow using a function in transform for the SWC modularized imports #36055

Closed
makezi opened this issue Apr 11, 2022 · 0 comments
Closed

Allow using a function in transform for the SWC modularized imports #36055

makezi opened this issue Apr 11, 2022 · 0 comments
Labels
SWC Related to minification/transpilation in Next.js.

Comments

@makezi
Copy link
Contributor

makezi commented Apr 11, 2022

Describe the feature you'd like to request

From #34969, it would be great if it were possible to allow the transformer to allow functions (similar to that of function transformer from babel-plugin-transform-imports).

Right now, I'm trying to import a react component library that uses hyphen-case as its naming convention and currently there is no way of doing so - there's only helpers for uppercase, lowercase and camel case. An example import:

// works
import { TextLink } from '@our-design-system/dist/components/text-link'; 

// Will fail as {{member}} will result in '@our-design system/dist/components/TextLink'
import { TextLink } from '@our-design-system/components'; 

Describe the solution you'd like

Either one of two solutions:

  1. Provide a hypenCase helper to the handlebars transform function similar to that of the other provided helpersm i.e. @our-design-system/dist/components/{{ hypenCase member}}. Although this doesn't give us enough power of the transformations compared to option 2.
  2. Allow transform to accept a function similar to that from babel-plugin-transform-imports)
modularizeImports: {
  '@our-design-system/components': {
    transform: (importName, matches) => `@our-design-system/dist/components/${hyphenCase(importName)}`
  }
}

Describe alternatives you've considered

The only other solution is to just defer back to babel.config.js and use babel plugins.

@balazsorban44 balazsorban44 added the SWC Related to minification/transpilation in Next.js. label Apr 12, 2022
@vercel vercel locked and limited conversation to collaborators Apr 12, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #36090 Apr 12, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants