使用ES6导入语法时,lodash-es
无法摇晃。例如,以下内容似乎包括lodash的所有内容:
import { isArray} from 'lodash-es';
我正在使用以下lodash配置:
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import pkg from './package.json';
const extensions = [
'.js', '.jsx', '.ts', '.tsx',
];
const name = 'RollupTypeScriptBabel';
export default {
input: './src/index.ts',
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
// https://rollupjs.org/guide/en#external-e-external
external: [],
plugins: [
// Allows node_modules resolution
resolve({ extensions }),
// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs(),
// Compile TypeScript/JavaScript files
babel({ extensions, include: ['src/**/*'] }),
],
output: [{
file: pkg.main,
format: 'cjs',
}, {
file: pkg.module,
format: 'es',
}]
};
如果有人想试用,我会设置一个测试仓库:https://github.com/jclangst/rollup-typescript-babel。
我已经尝试了一切,包括lodash-es
以外的其他ES6兼容库,没有任何效果。我做错了什么,阻止了树木的摇晃?