Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindings not generated with Parcel #8

Open
amanteaux opened this issue Nov 8, 2020 · 1 comment
Open

Bindings not generated with Parcel #8

amanteaux opened this issue Nov 8, 2020 · 1 comment

Comments

@amanteaux
Copy link

Hello,

First I want to say that I am very glad you made this compile time DI library for TS! It does not have many features, it just contains what is necessary, that is perfect :)

I am trying to make the di-compiler work with Parcel (I use Parcel to set up "easily" a React project with di-compiler after that). Almost everything is working (it correctly generates the constructors data), however for some reason the bindings are not generated.
Everything works fine if I write:

container.registerSingleton(undefined, {identifier:'ServiceA', implementation:ServiceA});
container.registerSingleton(undefined, {identifier:'ServiceB', implementation:ServiceB});
const serviceB = container.get<ServiceB>({identifier: 'ServiceB'});

However, if I try to use the standard syntax:

container.registerSingleton<ServiceA>();
container.registerSingleton<ServiceB>();
const serviceB = container.get<ServiceB>();

I get a Uncaught ReferenceError: DIContainer could not get service: No arguments were given! for the registerSingleton calls and a Uncaught ReferenceError: DIContainer could not get service: No options was given! for the get call.

Do you have any idea of what is wrong or what is missing?

To make the integration work, I use parcel-plugin-ttypescript that enables me to specify some TS transformers in the tsconfig.json file. After that, I needed to make a small adapter between this parcel plugin and di-compiler:

import { di } from "@wessberg/di-compiler";
import * as ts from 'typescript';

export default function(program: ts.Program) {
  return di({ program });
}

I created a repository with a minimal project to reproduce the issue: https://github.com/amanteaux/poc-parcel-di-compiler
The two ways of writing the bindings are in src/index.ts.

Thank you for any help/hints to make the integration works!
Cheers

@BinaryShrub
Copy link

I was looking to use parcel as well in my AWS lambda, anyone get this working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants