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

3rd party lib and declaration files #21

Closed
danbucholtz opened this issue Sep 24, 2016 · 3 comments
Closed

3rd party lib and declaration files #21

danbucholtz opened this issue Sep 24, 2016 · 3 comments

Comments

@danbucholtz
Copy link
Contributor

danbucholtz commented Sep 24, 2016

If I add a 3rd party module to my project and create a ./src/declarations.d.ts file definition for that module, I am able to run my app (if the definitions are correct) however the app-scripts output indicates error.

The error from the output that is meaningful is this:
[01:41:57] src/pages/home/home.ts(5,18): error TS2307: Cannot find module 'node-uuid'.

$ ionic serve

Running 'serve:before' npm script before serve
> ionic-hello-world@ watch /Users/dan/Dev/lib-test
> ionic-app-scripts watch
[01:41:55]  watch started ...
[01:41:55]  build dev started ...
[01:41:55]  clean started ...
[01:41:55]  clean finished in 1 ms
[01:41:55]  copy started ...
[01:41:55]  typescript compiler started ...
[01:41:55]  lint started ...
[01:41:55]  copy finished in 38 ms
[01:41:56]  lint finished in 440 ms
[01:41:57]  src/pages/home/home.ts(5,18): error TS2307: Cannot find module 'node-uuid'.
[01:41:57]  typescript compiler ready in 1.92 s
[01:41:57]  bundle dev started ...
[01:42:00]  rollup: Treating 'crypto' as external dependency

[01:42:01]  rollup: No name was provided for external module 'crypto' in options.globals – guessing 'crypto'

[01:42:02]  bundle dev finished in 5.11 s
[01:42:02]  sass started ...
[01:42:03]  sass finished in 912 ms
[01:42:03]  build dev finished in 7.94 s
[01:42:03]  watch ready in 8.00 s

Steps to reproduce:

1.  git clone [email protected]:danbucholtz/lib-test.git
2.  git checkout declaration-file
3.  npm install
4.  ionic serve

The output indicates error, but the app still runs which indicates the error was not legitimate. The 3rd party module works as expected in the Ionic app within the browser. To verify, open the console and view a guid being logged.

Thanks,
Dan

@danbucholtz
Copy link
Contributor Author

It is worth noting that the behavior gets worse after saving a file during an ionic serve session when a rebuild occurs.

After recreating the scenario above, make a change to ./src/pages/home.ts to trigger a rebuild.

You will see output that looks like this:

[01:46:29]  src/pages/home/home.ts(5,18): error TS2307: Cannot find module 'node-uuid'.
[01:46:29]  typescript compilation finished in 1.10 s
[01:46:29]  bundle dev update started ...
[01:46:30]  bundle dev update failed:  Error: Could not load crypto (imported by /Users/dan/Dev/lib-test/node_modules/node-uuid/uuid.js): ENOENT: no such file or directory, open 'crypto'
[01:46:30]  sass started ...
[01:46:30]  sass finished in 5 ms

The output indicates correctly that the bundle fails to build, and the page does not refresh.

[01:46:30] bundle dev update failed: Error: Could not load crypto (imported by /Users/dan/Dev/lib-test/node_modules/node-uuid/uuid.js): ENOENT: no such file or directory, open 'crypto'

@ramonornela
Copy link

Not was resolved this in #29 😉 ?

@danbucholtz
Copy link
Contributor Author

This is resolved, thanks @ramonornela!

Thanks,
Dan

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

No branches or pull requests

2 participants