Why can you directly import? after npm install jquery in vue

jquery is not a modular class library, but why can import $from "jquery" be used directly after npm install?

Mar.18,2022

jq makes exports easy to do


if methods are exposed through module.exports , they can be called through import , which is not difficult. As soon as I read the 1.10.0 version, I am compatible with


.

webpack/babel will compile your ES6 module import method.

jquery export
module.exports = xxx

corresponding can be introduced as follows:
import $from 'jquery'

after compilation, it is actually introduced like this:
var $= require ('jquery')


npm install after Jquery is in your project node_modules . When you import , it will go to node_modules to find Jquery , module.exports derived from Jquery , so you can get

when you import .
Menu