thiagobustamante / typescript-ioc

A Lightweight annotation-based dependency injection container for typescript.
MIT License
526 stars 64 forks source link

Not working on React native #50

Closed shatodj closed 4 years ago

shatodj commented 5 years ago

I'm not able to build my react-native app using this awesome module. I have this error inside metro bundler:

error: bundling failed: Error: Unable to resolve module `fs` from `/Users/ XXX /node_modules/typescript-ioc/index.js`: Module `fs` does not exist in the Haste module map

my packages:

    "tslint": "^5.14.0",
    "react": "16.8.3",
    "react-native": "0.59.8",
    "react-native-router-flux": "^4.0.6",
    "react-native-vector-icons": "^4.6.0",
    "typescript-ioc": "^1.2.5"

    "typescript": "^3.4.5"
Bielik20 commented 5 years ago

I got the same with simple js app. It decided whether to use es5 or es6 by checking if this === window, then check if it is es6 with process.env.ES6 === 'true'. Both those checks fail so it assumes it is a node app and does that:

var fs_1 = require('fs');
var path_1 = require('path');

This breaks the app. I feel like the way it is exported should be changed, maybe using package.json fields like module etc.

Bielik20 commented 4 years ago

As we had this (and other) issues with that library at Wikia, so we created our own, it is heavily inspired by this one but assumes different paradigm, and is built with web in mind: https://github.com/Wikia/dependency-injection-js

thiagobustamante commented 4 years ago

Fixed in version 3