0

So basically the problem is this. I need to use some FCM cordova plugins in my ionic v3 project, this project as been modify so it is based in javascript.

I need to be able to import modules as I usually do in typescript files, I mean do something like this:

import { FCM } from '@ionic-native/fcm';

But in js, so I can use methods and functions of these plugins and components in js

Currently, I'm trying by using require.js since guys bellow gave me the idea:

var FCM = '@ionic-native/fcm';
require([FCM], function(fcmodule){
    // use module
})

but it is not working so far, I'm getting these errors

enter image description here

neomat
  • 103
  • 1
  • 1
  • 6
  • this should also work in `JavaScript` but not in every browser. You could use `require()` instead – messerbill Mar 05 '18 at 12:14
  • 1
    Possible duplicate of [Typescript import/as vs import/require?](https://stackoverflow.com/questions/35706164/typescript-import-as-vs-import-require) – XCS Mar 05 '18 at 12:19
  • But how do you bundle your modules in Typescript? I don't think it matters if you use Typescript or Javascript - it's the bundler that decides if you have to use `import` or `require`. – Kokodoko Mar 05 '18 at 14:14

1 Answers1

0

There are various AMD libraries, some of them are systemjs, requireJS.

If you are using requireJS, you can use var FCM=require('@ionmic-native/fcm');.

If you are using es6+ then you will get support of import keyword.

Laxmikant Dange
  • 7,606
  • 6
  • 40
  • 65
  • so using this lib I should be able to import and use the fcm's method withouth problem right? – neomat Mar 05 '18 at 12:35