Skip to content

json-pack: sharedCachedUtf8Decoder_1.default is undefined because tslib exportStar skips export named default #925

@char101

Description

@char101

Hi,

Since updating to @json-joy/json-pack 1.9.0 I got this.keyDecoder is undefined error when unpacking CBOR Using CborDecoder.

this.keyDecoder is defined below but since sharedCachedUtf8Decoder_1.default is reexported using tslib.__exportStar, it is skipped and thus become undefined.

I'm not sure if this default property is the default export or an attribute named default since I can't find the original ts file.

const sharedCachedUtf8Decoder_1 = tslib_1.__importDefault(require("@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder"));
class CborDecoderBase {
    constructor(reader = new Reader_1.Reader(), keyDecoder = sharedCachedUtf8Decoder_1.default) {
        this.reader = reader;
        this.keyDecoder = keyDecoder;

The default attribute is reexported here: @[email protected][email protected]/node_modules/@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js

tslib_1.__exportStar(require("@jsonjoy.com/buffers/lib/utf8/sharedCachedUtf8Decoder"), exports);

The default attribute is defined here: @[email protected][email protected]/node_modules/@jsonjoy.com/buffers/lib/utf8/sharedCachedUtf8Decoder.js

const CachedUtf8Decoder_1 = require("./CachedUtf8Decoder");
exports.default = new CachedUtf8Decoder_1.CachedUtf8Decoder();

The definition of __exportStar skips property named default: [email protected]/node_modules/tslib/tslib.js

    __exportStar = function(m, o) {
        for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
    };

Environment:
vite-rolldown 7.0.12
pnpm 10.12.1
@json-joy/json-pack 1.9.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions