A custom transformer that can be used with ttypescript to transform ts imports to browser style imports
Home > config > PluginConfigs > bareModuleRewrite
Warning: This API is now obsolete.
Renamed to “rules”, will be removed in 3.0
The transformation rule. Specify how this transformer will handle your imports.
Signature:
bareModuleRewrite?: PluginConfigs['rules']
This is the most powerful part of this transformer. You can specify the transform rule of bare imports (like import 'React'
) to the form that browser can recognize. See RewriteRulesObject
When it is a Record<string, RewriteRulesObject>
, you can use two kinds of matching rule to matching your import paths.
Full match: use normal string to do a full match. ("react"
will only match “react”)
RegExp match: use JavaScript RegExp to match dependencies. ("/^@material-ui\/(.+)/g"
will match all packages started with @material-ui
)