【发布时间】:2020-12-19 18:21:44
【问题描述】:
我的输入文件如下所示:
import * as chalk from 'chalk'
const chalkInstance = new chalk.Instance({
level: 1
})
我的输出文件如下所示:
import { Instance } from 'chalk';
const chalkInstance = new Instance({
level: 1
});
问题是 chalk 是一个 commonjs 模块,我希望我的输出是一个 es 模块,所以当我执行文件时,我收到以下错误:The requested module 'chalk' is expected to be of type CommonJS, which does not support named exports 等。有没有办法防止汇总更改import * as something 进口?即使我禁用 treeshaking,问题也不会消失。
提前谢谢!
【问题讨论】:
标签: javascript import es6-modules commonjs rollupjs