Angular of-packagr Rollup Build Error

问题描述 投票:0回答:1

我已经查看了我能找到的每个问题,它引用了我在尝试打包Angular组件库时遇到的错误。错误是:

BUILD ERROR
Cannot call a namespace ('moment')
Error: Cannot call a namespace ('moment')
... //Rest of stack trace

我尝试将"allowSyntheticDefaultImports": true,属性添加到我的tsconfig.json文件中,而"target"是es6。我尝试添加一个rollup.config.js文件,并尝试了以下导入时刻的方法:

import * as moment from 'moment';

import moment from 'moment';

import * as momentLib from 'moment';
const moment = momentLib;

import moment from 'moment-es6';

这些都没有奏效。但我仍然得到上述错误,或者暂时没有默认导出。

有没有人有任何关于如何使这个工作的提示?

angular rollup
1个回答
0
投票

我也尝试了你也尝试过的所有解决方案,但对我有用的是

import moment from 'moment-with-locales-es6';

我加入了dependenciespackage.json

"moment-with-locales-es6": "latest"
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.