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 plugin adds a leading slash to these paths (e.g. /imports/bar
).
The plugin automatically parses tsconfig.json
and resolve paths mapping.
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.
Install the package:
npm i babel-plugin-meteor-typescript-import-transform
Then include the plugin in your .babelrc
:
{
"plugins": ["meteor-typescript-import-transform"]
}