leonardfactory / babel-plugin-transform-typescript-metadata

Babel plugin to emit decorator metadata like typescript compiler
MIT License
215 stars 17 forks source link

Add info about resolving bundler warnings to README #46

Closed gshokanov closed 3 years ago

gshokanov commented 3 years ago

Hey! When using this plugin I found that webpack complains about missing exports due to types not being removed by babel when used in inversify decorators. Although everything works fine these warnings can be resolved by using type imports:

import { injectable, inject } from 'inversify';
import type { Service } from './Service';
import { ServiceIdentifier } from './ServiceIdentifier';

@injectable
export class OtherService {
  constructor(
    @inject(ServiceIdentifier) service: Service
  ) {}
}

Just a small suggestion to add this to README if you think it fits there as some people might want to get rid of the warnings but don't know how.

gshokanov commented 3 years ago

BTW I don't have any experience writing Babel plugins but maybe it's possible to automatically rewrite imports this way through the plugin?

anilpixel commented 3 years ago

Hey! When using this plugin I found that webpack complains about missing exports due to types not being removed by babel when used in inversify decorators. Although everything works fine these warnings can be resolved by using type imports:

import { injectable, inject } from 'inversify';
import type { Service } from './Service';
import { ServiceIdentifier } from './ServiceIdentifier';

@injectable
export class OtherService {
  constructor(
    @inject(ServiceIdentifier) service: Service
  ) {}
}

Just a small suggestion to add this to README if you think it fits there as some people might want to get rid of the warnings but don't know how.

thx you for this solution. if README have this tip, I think it's very useful.

leonardfactory commented 3 years ago

I'll add it to README in the pitfalls section. Thank you 😄