‘jquery’ is imported by node_modules\bootstrap\js\src\alert.js, but could not be resolved – treating it as an external dependency

rollup.js打包错误

'jquery' is imported by node_modules\bootstrap\js\src\alert.js, but could not be resolved – treating it as an external dependency

由于js依赖有jquery,是commonjs(cjs)形式,所以需要加载进入,要安装@rollup/plugin-commonjs依赖。

Install
Using npm:

npm install @rollup/plugin-commonjs --save-dev

Usage
Create a rollup.config.js configuration file and import the plugin:

import commonjs from '@rollup/plugin-commonjs';
 
export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [commonjs()]
};

参考文档:https://www.npmjs.com/package/@rollup/plugin-commonjs

本条目发布于。属于科技分类。作者是

关于有个狸

2005年开始的一名站长,从事网站策划、运营,早期一批扎根阿里妈妈、Google Adsense的一员,目前司职前端与产品设计。

发表回复