diff --git a/packages/docgen/lib/get-export-entries.js b/packages/docgen/lib/get-export-entries.js index dc4046b72fcc77..9785f40808b94d 100644 --- a/packages/docgen/lib/get-export-entries.js +++ b/packages/docgen/lib/get-export-entries.js @@ -54,10 +54,10 @@ module.exports = ( token ) => { } const name = []; - if ( token.declaration === null ) { + if ( ! token.declaration ) { token.specifiers.forEach( ( specifier ) => name.push( { - localName: specifier.local.name, + localName: specifier.local?.name, exportName: specifier.exported.name, module: token.source?.value ?? null, lineStart: specifier.loc.start.line, diff --git a/packages/docgen/test/get-export-entries.js b/packages/docgen/test/get-export-entries.js index 4d4346007b3aa5..4957e74a61dd6c 100644 --- a/packages/docgen/test/get-export-entries.js +++ b/packages/docgen/test/get-export-entries.js @@ -502,4 +502,30 @@ describe( 'Export entries', () => { } ), ] ); } ); + + it( 're-exporting node module for external use', () => { + expect( + firstExport( + ` + export * as Y from 'yjs'; + `, + ` + /** + * Exports the entire API of Yjs. + * + * @module yjs + */ + export { Doc, Transaction, YArray as Array, YMap as Map, YText as Text, YXmlText as XmlText, YXmlHook as XmlHook, YXmlElement as XmlElement, YXmlFragment as XmlFragment, YXmlEvent, YMapEvent, YArrayEvent, YTextEvent, YEvent, Item, AbstractStruct, GC, Skip, ContentBinary, ContentDeleted, ContentDoc, ContentEmbed, ContentFormat, ContentJSON, ContentAny, ContentString, ContentType, AbstractType, getTypeChildren, createRelativePositionFromTypeIndex, createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, AbsolutePosition, RelativePosition, ID, createID, compareIDs, getState, Snapshot, createSnapshot, createDeleteSet, createDeleteSetFromStructStore, cleanupYTextFormatting, snapshot, emptySnapshot, findRootTypeKey, findIndexSS, getItem, getItemCleanStart, getItemCleanEnd, typeListToArraySnapshot, typeMapGetSnapshot, typeMapGetAllSnapshot, createDocFromSnapshot, iterateDeletedStructs, applyUpdate, applyUpdateV2, readUpdate, readUpdateV2, encodeStateAsUpdate, encodeStateAsUpdateV2, encodeStateVector, UndoManager, decodeSnapshot, encodeSnapshot, decodeSnapshotV2, encodeSnapshotV2, decodeStateVector, logUpdate, logUpdateV2, decodeUpdate, decodeUpdateV2, relativePositionToJSON, isDeleted, isParentOf, equalSnapshots, PermanentUserData, tryGc, transact, AbstractConnector, logType, mergeUpdates, mergeUpdatesV2, parseUpdateMeta, parseUpdateMetaV2, encodeStateVectorFromUpdate, encodeStateVectorFromUpdateV2, encodeRelativePosition, decodeRelativePosition, diffUpdate, diffUpdateV2, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, obfuscateUpdate, obfuscateUpdateV2, UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, equalDeleteSets, mergeDeleteSets, snapshotContainsUpdate } from "./internals.js"; + ` + ) + ).toEqual( [ + expect.objectContaining( { + lineStart: 1, + lineEnd: 1, + localName: undefined, + exportName: 'Y', + module: 'yjs', + } ), + ] ); + } ); } );