Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Not able to add third libraries #321

Closed
salimchemes opened this issue Nov 7, 2016 · 18 comments
Closed

Not able to add third libraries #321

salimchemes opened this issue Nov 7, 2016 · 18 comments

Comments

@salimchemes
Copy link

salimchemes commented Nov 7, 2016

I am having issues with the latest release (rc2). I have a third library defined in a separated typescript file that works as a wrapper for a library that is available in js (it's a plugin). Since typings are deprecated and @type for this library is not available (https://github.com/DefinitelyTyped/DefinitelyTyped) I added the implementation in declarations.d.ts file. But the library is not available when I build de code (prod or dev mode) and i get that my code was not found. Any ideas?
It was working with rc1

error:
[14:27:08] uglifyjs failed: ENOENT: no such file or directory, open 'C:\Projects\infotycoon-inspections\www\build\main.js' [14:27:08] ionic-app-script task: "build" [14:27:08] Error: ENOENT: no such file or directory, open 'C:\Projects\infotycoon-inspections\www\build\main.js'

plugin: https://github.com/Azure/azure-mobile-engagement-cordova

could this issue be related to the latest update (RC2)?

@salimchemes
Copy link
Author

I have updated all dependencies except ionic-app-scritps pointing it to "0.0.36" instead "0.0.39" and its working.

@danbucholtz
Copy link
Contributor

@salimchemes,

Can you provide a sample repo where we can recreate the issue?

Thanks,
Dan

@salimchemes
Copy link
Author

salimchemes commented Nov 8, 2016

@danbucholtz i created a blank project and implemented my code and its working. So, i am checking the config files (package.json, tsconfig.json) to detect where is the difference. I think we can close the issue until i identify where the problem is.
Thanks

@xx0r
Copy link

xx0r commented Nov 9, 2016

I just ran into the same issue. The cause was probably different, but:

0.0.39

  • ngc finished
  • webpack finished
  • uglifyjs started
  • uglifyjs failed: ENOENT: no such file or directory, open "......main.js"

0.0.36

  • ngc finished
  • bundle started
  • bundle failed: Could not resolve ... (barrel declaration)

0.0.39 basically swallowed the exception and left me clueless

@salimchemes
Copy link
Author

@xx0r did you try 0.0.41? check tsconfig,json this line also
"include": [ "src/**/*.ts" ],
https://github.com/driftyco/ionic2-app-base/blob/master/tsconfig.json

I tried with blank project and works fine.

@xx0r
Copy link

xx0r commented Nov 9, 2016

Thank you for the advice, I updated the scripts to 0.0.41, + checked the tsconfig.json, but the error message is swallowed nonetheless.

however, i was able to replicate the minimal issue :)

  1. ionic start sidemenu.clean --ts --v2
  2. add declarations.ts to pages/page1
export * from "./page1";
export * from "./nonexistent.page";

3.. change app.component.ts to import page1 from the barrel declaration

import { Page1 } from '../pages/page1/declarations';

4... ionic build
5... uglifyjs failed: ENOENT: no such file or directory, open '....\sidemenu.clean\www\build\main.js'

@salimchemes
Copy link
Author

just add the code into declarations.ts, you dont need any import.

@biesbjerg
Copy link

I'm seeing the same issue where ionic serve seemed to build successfully, but no main.js was generated.

I downgraded to 0.0.36, ran ionic serve again and got the following error message:

[05:14:54]  bundle failed: Could not resolve './services/auth.service' from /Users/kim/ionic/mindly-app/rc-wip/src/account/index.ts

Seems useful error messages are being swallowed somewhere, like @xx0r mentions

@salimchemes
Copy link
Author

salimchemes commented Nov 16, 2016

Hi @danbucholtz i have updated the latest ionic-app-scripts version (0.0.44) and I am still having the same issue.
Latest version working for me was 0.0.36 but the implementation was little bit different because the Engagement code was in separated typescript file, not in declarations.d.ts. I think this is a problem related to engagement and custom DT. Since DT for azure engagement plugin is not available I implemented the code into declarations.d.ts file to get it available.
I created this repo to repro the issue
https://github.com/salimchemes/engagement-issue

a couple of things
1 if i run ionic run browser compilation works fine and there are no runtime errors.
2 if i run ionic run android compilation works fine but i got runtime errors ("Engagement not defined")

In declarations.d.ts file you will see the definiton of the engagement interface and the variable Engagement.

Same issue if I just define the variable as (there is a branch in the repo called engagement-type-any)

declare var Engagement : any;

My concern is if the implementation on declarations.d.ts is correct or I am missing something else.

In the real project that I am working on the compilation fails as I described in the issue when i run ionic run browser, ionic run android or ionic serve.

[16:41:14] uglifyjs failed: ENOENT: no such file or directory, open
'C:\Projects\infotycoon-inspections\www\build\main.js'
[16:41:14] ionic-app-script task: "build"
[16:41:14] Error: ENOENT: no such file or directory, open 'C:\Projects\infotycoon-inspections\www\build\main.js

Could you please take a look and let me know your thoughts? Thanks

@salimchemes salimchemes reopened this Nov 16, 2016
@danbucholtz
Copy link
Contributor

@salimchemes,

Can you summarize the issue that you're seeing? Sorry, I'm not really following.

Thanks,
Dan

@salimchemes
Copy link
Author

@danbucholtz sorry if I was not clear
That I am trying to do is define Engagement variable into declarations.d.ts to be able to use azure-engagement plugin since is not defined as DT.
I tried with
declare var Engagement : any;
but no luck

Any idea what is missing? Thanks!

@danbucholtz
Copy link
Contributor

You shouldn't need to define the type since we provide src/declarations.d.ts file with a wildcard in it.

declare module "*"

That should be sufficient to allow the lib to be imported.

Thanks,
Dan

@salimchemes
Copy link
Author

salimchemes commented Nov 21, 2016

@danbucholtz if i do that i got (using 0.0.45 version)

[10:18:07]  Cannot find name 'Engagement'.
[10:18:07]  ngc failed

DT for engagement plugin does not exist. Is there any example where a plugin with no DT is implemented?
Thanks

@danbucholtz
Copy link
Contributor

Yes. If you look in your src/declarations.d.t.s file, we have declare module '*'. This wildcard operator means importing engagement will likely just work. How are you importing the library? Do you have the src/declarations.d.ts file?

Thanks,
Dan

@salimchemes
Copy link
Author

yes, I have both

src/declarations.d.ts

and

declare module '*';

about how is the library imported not sure if should i do something else. I installed the plugin via npm.
How should I import the library?

@danbucholtz
Copy link
Contributor

What does your import statement look like?

@salimchemes
Copy link
Author

i dont have any imports for engagement, its necessary?

@danbucholtz
Copy link
Contributor

Yes, definitely. I am not familiar with that library but please review our documentation on importing libraries.

http://ionicframework.com/docs/v2/resources/third-party-libs/

I'm going to close this for now since this is not an issue app-scripts, it's more of a question.

Thanks,
Dan

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

No branches or pull requests

4 participants