Skip to content

Commit f790660

Browse files
committed
feat(swc-output-gen): add transform-imports plugin
1 parent 0466460 commit f790660

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

internal-packages/swc-output-gen/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@swc/plugin-emotion": "^14.8.0",
1414
"@swc/plugin-react-remove-properties": "^12.8.0",
1515
"@swc/plugin-styled-jsx": "^13.8.0",
16+
"@swc/plugin-transform-imports": "^12.8.0",
1617
"rolldown": "^1.0.0-rc.13",
1718
"tinyglobby": "^0.2.15"
1819
}

internal-packages/swc-output-gen/src/plugin-registry.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ export const pluginRegistry: Record<string, PluginConfig> = {
4646
return [['@swc/plugin-styled-jsx', swcConfig]]
4747
},
4848
},
49+
'transform-imports': {
50+
packages: ['@swc/plugin-transform-imports'],
51+
mapOptions: (config) => [['@swc/plugin-transform-imports', config]],
52+
shouldSkip: (config) => {
53+
// SWC plugin only supports camelCase and kebabCase helpers
54+
// Our ported plugin also supports snakeCase, lowerCase, upperCase
55+
const unsupportedHelpers = ['snakeCase', 'lowerCase', 'upperCase']
56+
const configStr = JSON.stringify(config)
57+
return unsupportedHelpers.some((helper) => configStr.includes(helper))
58+
},
59+
},
4960
}
5061

5162
/** Get list of all supported plugin names */

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)