I have asked same question on Stackoverflow. I have given one working solution there which I can’t use in normal applications (requires editing inside node_modules
folder).
And I can’t use solution mentioned by me or Leonardo Oliveira
because Ionic application doesn’t contains angular-cli.json
or webpack.config.js
outside of node_modules
folder.
The jquery.shorten is an old plugin which I want to import in Ionic using import
(if possible).
This is how I am importing jQuery
and jquery.shorten
-
import * as jQuery from 'jquery';
import 'jquery.shorten/src/jquery.shorten';
I have also tried following way -
import 'jquery';
declare let $: any;
declare let jQuery: any;
import 'jquery.shorten/src/jquery.shorten';
Both give error (on main page) -
Runtime Error
jQuery is not defined
And in console -
Uncaught ReferenceError: jQuery is not defined. (points to line 151 of “jquery.shorten.js” which is “})(jQuery)”)
If I include CDN of jQuery
in index.html
, then things work perfectly. But this is the last solution I want.
I have also tried this solution. But generates random errors.
Does anybody know how to import old jQuery plugins using import
in Ionic? Or someway to use angular-cli.json
in this case?
My project is running on Ionic 3.9.2. And I can use jQuery in my project as it can be used.