-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Closed
Labels
SWCRelated to minification/transpilation in Next.js.Related to minification/transpilation in Next.js.
Description
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:
- 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. - 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.
Metadata
Metadata
Assignees
Labels
SWCRelated to minification/transpilation in Next.js.Related to minification/transpilation in Next.js.