wwwalkerrun / nativescript-ngx-magic

Magically drop a NativeScript app into your Angular web app and reuse all your code.
MIT License
48 stars 8 forks source link

Fixing install.js #3

Closed rhanb closed 7 years ago

rhanb commented 7 years ago

fix issue( only path issue) : #2

NathanWalker commented 7 years ago

The current released version works and these paths I believe are incorrect in this PR - Usage of this plugin is:

ng new cli-project  // create a new angular cli project
cd cli-project
npm i @wwwalkerrun/nativescript-ngx-magic --save  // install magic
// then follow usage guide to change @Component imports to use from plugin
// and add .tns.html and .tns.css files for your components
npm run start.ios

Works just fine, so confused what you are attempting to solve here?

rhanb commented 7 years ago

You are right, sorry for the waste of time #2

NathanWalker commented 7 years ago

N/p, thanks again for the effort and contribution @rhanbIT 👍 Please let me know if you encounter any issues, just released 2.0.4 which fixes one remaining issue with component path resolution. Cheers!

rhanb commented 7 years ago

Great work @NathanWalker ,it works perfectly, I did another workaroundt to avoid using moduleId: module.id here.

But your solution is much more efficient and light! Maybe implementing both could be good to let the developper choose its way of using paths in components?

I have other ideas for this module, I'm developping an app for a project in wich I'm the CTO and I want to developp a webapp/mobileapp that's why this module is so interesting to me.

Since I develop in the src/app folder in the angular-cli project part, when I include modules in *.components.ts from NativeScript the webapp doesn't recognize them.. I thought about using the MagicService.IS_NATIVESCRIPT() to import right modules, example:

import {MagicService} from 'nativescript-ngx-magic';
if (MagicService.IS_NATIVESCRIPT()) {
    import {Page} from 'ui/page';
} else {

}

but i'm getting this error:

An import declaration can only be used in a namespace or module.)

Implementing the support of custom component.tns.ts for NativeScript is, of course, not what we want since the goal is to reuse code.

Maybe add specific file like imports.ts and imports.tns.ts and fix the path with the module? (Just a simple idea)

What is your thoughts?

Cheers from France :)