documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Lazy loading causes documentation crash.

Open koofka opened this issue 7 years ago • 1 comments

Working with a project with MapBox embedded that has been implemented via lazy loading in order to defer the file size impact. Using either smooth-code/loadable-components or React.lazy methods for importing the component causes a stack crash on documentation 9.1.1 that seems related to the dependency crawling. Removing the lazy loader allows the module to process normally.

Documentation is being run via the CLI:

documentation serve -c ./jsdoc.conf ./src/** --watch index.js

The two lazy loading methods attempted:

const MapBoxGL = loadable(() => import('components/molecules/MapBoxGL/index_ld.js'))

and

const MapBoxGL = React.lazy(() => import('components/molecules/MapBoxGL/index_ld.js'))

Both of which return the stack trace of:

Error: Parsing file /Users/{username}/Development/{client}/{project}/client/src/containers/MapBoxGLContainer.js: Unexpected token (25:9)
    at Deps.parseDeps (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:515:28)
    at fromSource (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:450:44)
    at /usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:444:17
    at ConcatStream.<anonymous> (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/node_modules/concat-stream/index.js:36:43)
    at ConcatStream.emit (events.js:187:15)
    at finishMaybe (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)
    at endWritable (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:485:3)
    at ConcatStream.Writable.end (/usr/local/lib/node_modules/documentation/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:455:41)
    at DuplexWrapper.onend (/usr/local/lib/node_modules/documentation/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:273:13)
documentation.js serving on port 4001
events.js:167
      throw er; // Unhandled 'error' event

Was planning to experiment this morning with a babel plugin that loadable-components offers added to the src/input/dependency.js file for documentation. But figured to offer this up if it was an unknown issue, as I couldn't find any existing reports in for the various packages involved.

koofka avatar Jan 04 '19 14:01 koofka

Duplicate of #1149

tmcw avatar Jan 04 '19 16:01 tmcw