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

Ndef not exported by NFC plugin #713

Closed
HendrikGrobler opened this issue Oct 17, 2016 · 4 comments
Closed

Ndef not exported by NFC plugin #713

HendrikGrobler opened this issue Oct 17, 2016 · 4 comments
Labels
Milestone

Comments

@HendrikGrobler
Copy link

The Ndef class is not exported the nfc.ts plugin. It has an annotation for private and is not included in the index.ts file. However, the examples in both the ionic docs and code comments suggest importing it alongside NFC.

I get the following error when I run Ionic Serve:
bundle failed: 'Ndef' is not exported by node_modules/ionic-native/dist/esm/plugins/nfc.js (imported by node_modules/ionic-native/dist/esm/index.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

I would like to create a PR to fix this and a few other things related to Ndef, however I am struggling to get the build to reflect the exported class. I have removed the private annotation, added Ndef to the imports in index.ts and also added it to the window['IonicNative'] object. When I run npm run build everything runs fine but there is no export for Ndef in either es5/plugins/nfc.js or esm/plugins/nfc.js.

Would appreciate some guidance in getting this built so I can test it and create the PR.

@ihadeed
Copy link
Collaborator

ihadeed commented Oct 17, 2016

Yeah that's because we're using export declare class Ndef { ... I had similar issues with other plugins earlier. I think the new build process for Ionic Framework doesn't like these kind of exports.

We would have to do something else like here: b95f88c#diff-a740ceecb06436e4f3c45e162549de31R111

@ihadeed ihadeed added the bug label Oct 17, 2016
@HendrikGrobler
Copy link
Author

Will try converting it to a proper class with empty functions. Should I do the same for Nfc while I'm at it or is it fine as is?

@HendrikGrobler
Copy link
Author

It seems like that Ndef class is mapping to this NPM library: https://www.npmjs.com/package/ndef
I don't see any dependencies in the package.json file other than RxJS, is it up to the user to install the correct dependencies? Or do none of the other plugins have dependencies other than the cordova plugin?

@ihadeed
Copy link
Collaborator

ihadeed commented Oct 17, 2016

No the Ndef class comes with the NFC plugin. It is the only thing that needs to be modified. It needs to be converted to a regular class instead of declare class, then add plugin and pluginRef private properties that match the NFC class. Then add @Cordova({ sync: true }) decorators to each function.

Just like what I did there with the mixpanel plugin

@ihadeed ihadeed added this to the v2.2.5 milestone Oct 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants