rollup.js打包错误在安装@rollup/plugin-commonjs之后出现:
'jquery' is imported by jquery?commonjs-external, but could not be resolved – treating it as an external dependency
还需要@rollup/plugin-node-resolve
解决node_modules引入问题:
Install
Using npm:
npm install @rollup/plugin-node-resolve --save-dev
Usage
Create a rollup.config.js configuration file and import the plugin:
import { nodeResolve } from '@rollup/plugin-node-resolve';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [nodeResolve()]
};
参考文档:https://www.npmjs.com/package/@rollup/plugin-node-resolve