我有数据选择模块的角度,其中我导入moment.js.实际上,我导入了NPM软件包矩-ES6,它导入了这样的moment.js:
import * as moment from "moment";
export default moment;如果我像这样在模块中自己导入moment.js的话,我也会遇到同样的问题
import * as moment from "moment";在角度12,它工作没有任何问题。但是在角度13上,当我试图在这个模块中使用moment.js时,由于没有正确导入moment.js,我得到了错误。
moment_es6__WEBPACK_IMPORTED_MODULE___不是一个函数
此问题仅在我将模块构建为PROD时才会发生。
我的吐露:
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../../../out-tsc/lib",
"declarationMap": true,
"target": "es2015",
"module": "es2020",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}我的tsconfig.lib.prod.json
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}知道怎么解决这个问题吗。我尝试了很少的事情但没有成功。
发布于 2022-02-11 09:50:15
经过一些研究发现,使用此导入解决了类似的问题。
import moment from 'moment'我还发现了这个棘手的导入:
import * as temp from 'moment';
const moment = temp["default"];你试过这些进口产品了吗?
https://stackoverflow.com/questions/71077918
复制相似问题