meteor-typescript-import-transform
Intro
This plugin addresses TypeScript import issues in Meteor projects when switching from legacy (barbatus:typescript
based) packages to the official typescript
package.
The plugin is inspired by an implementation from Ben Newman.
The addressed issues
imports/bar
) is not recognized as valid import paths
Paths without leading slash (e.g. The plugin adds a leading slash to these paths (e.g. /imports/bar
).
tsconfig.json
is not recognized
Paths mapping in The plugin automatically parses tsconfig.json
and resolve paths mapping.
import 'imports/module/main'
may not work as expected
When an import path doesn't specify file extension, the wrong file might be picked if there're other files having the same name in the directory. For example:
imports/module/main.ts
imports/module/main.html
The plugin generates a list of all .ts
and .tsx
files and attempts to load them
when a matching import path without extension is detected.
Usage
Install the package:
npm i babel-plugin-meteor-typescript-import-transform
Then include the plugin in your .babelrc
:
{
"plugins": ["meteor-typescript-import-transform"]
}