我有这个带有 index.ts 文件的包。
安装在下面的相应index.d.ts
文件node_modules/@fireflysemantics/slice
如下所示:
export { EStore } from './EStore';
export { Slice } from './Slice';
export { OStore } from './OStore';
export * from './types';
对应的index.js
看起来像这样:
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var EStore_1 = require("./EStore");
exports.EStore = EStore_1.EStore;
var Slice_1 = require("./Slice");
exports.Slice = Slice_1.Slice;
var OStore_1 = require("./OStore");
exports.OStore = OStore_1.OStore;
__export(require("./types"));
//# sourceMappingURL=index.js.map
当我尝试OStore
使用 Stackblitz 导入时,它不会解析为根导入。例如这项工作:
import {OStore} from '@fireflysemantics/slice/OStore';
但这不会:
import {OStore} from '@fireflysemantics/slice/';
如果有帮助,这里有一个 stackblitz 链接:
https://stackblitz.com/edit/typescript-vj1vpa
stackblitz 错误是:
找不到模块:@fireflysemantics/slice/index.ts (@6.4.2) 检查您的导入语句并确保您正在导入正确的模块名称。
安装到 NPM 之前应该index.ts
复制到分发文件夹吗?