导入 ES6 模块导致脚本不执行 - Fullcalendar

时间:2021-03-31 00:05:50

标签: javascript npm webpack fullcalendar es6-modules

我无意中更新了 package.json 文件中列出的大量 npm 包,现在我在导入 FullCalendar 包时遇到问题。

以下是我所知道的: 当我从包中导入 Fullcalendar 模块或任何插件(例如 import dayGridPlugin from '@fullcalendar/daygrid)时,导出的脚本不会执行。我在其他 js 文件中导入其他 npm 包时没有遇到问题。我所有的其他脚本都没有遇到过这个问题。

JS 文件:

import * as utils from './utils.js';
import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';

console.log("show me something");

console: .... 什么也没发生。

但是,如果我从@fullcalendar 导入,脚本会按预期运行。

JS 文件:

import * as utils from './utils.js';
// import { Calendar } from '@fullcalendar/core';
// import dayGridPlugin from '@fullcalendar/daygrid';

console.log("show me something");

console: show me something

问题排查:

  • Webpack 通过 npm run watch 更改后成功更新文件
  • 我已确认浏览器中正在加载更新的文件
  • 我尝试将软件包恢复到以前的版本(例如@fullcalendar@4.4.2 - 以前的版本可以正常工作)......结果相同
  • 从 webpack 5 降级 -> webpack@4.46.0 ...相同的结果
  • 检查文档以确保从 v4 升级后我正确使用了 fullcalendar v5 - https://fullcalendar.io/docs/initialize-es6

相关版本号

  • @fullcalendar/core@5.6.0
  • @fullcalendar/daygrid@5.6.0
  • @fullcalendar/list@5.6.0
  • @fullcalendar/timegrid@5.6.0
  • webpack@4.46.0

我真的被这个难住了。我确定这是由于我对 ES6 模块的了解有限。我感谢您提供的任何见解。谢谢!

0 个答案:

没有答案
相关问题