I've read a few related questions but I don't understand very well why this wouldn't work:
//common.js
import {$} from "jquery";
const mytoggler = element => $(element).toggle();
export {$,mytoggler}
Whenever I import {$,mytoggler} from './common.js';
I get an error from webpack (but probably this has to do with jquery as any other export/import runs fine):
Uncaught TypeError: _common_common_js__WEBPACK_IMPORTED_MODULE_0__.$ is not a function
Any ideas?
CodePudding user response:
In the README description of the jquery module. https://www.npmjs.com/package/jquery
Says that the correct way to include jquery is the following:
import $ from "jquery";
instead of import {$} from "jquery";