Whats best practice for using libs like lodash in modules bundled by webpack?
1. require it to a global variable
window._ = require('lodash');
2. webpack conf
new webpack.ProvidePlugin({ _: 'lodash' });
3. Require it in a module if I want to use lodash in that module like
let _ = require('lodash');
or
import _ from lodash;
4. import only the functions I want to use in the current module from lodash like
import { find, map } from 'lodash';
import { find, map } from 'lodash';
应该用来支持三个摇晃
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.