Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: Cannot find module 'jsdoc/src/filter' #7

Open
stepancar opened this issue Apr 20, 2021 · 1 comment

Comments

@stepancar
Copy link
Contributor

Hello, I'm trying to migrate to webdoc from pixi-jsdoc-template

I my webdoc config I have

"templates": {
    "default": {
          "staticFiles": {
              "include": [
                  "."
              ],
              "exclude": [
                  "./docs",
                  "./node_modules",
                  "./public",
                  "./results",
                  "./scripts",
                  "./test"
              ],
              "includePattern": ".\\.png$"
          }
      },
}

It was working with pixi-jsdoc-template, but with pixi-webdoc-template it fails with
stacktrace

(node:26703) UnhandledPromiseRejectionWarning: Error: Cannot find module 'jsdoc/src/filter'
Require stack:
- /project/node_modules/@pixi/webdoc-template/publish.js
- /project/node_modules/@webdoc/cli/lib/index.js
- /project/node_modules/@webdoc/cli/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)

I tried to debug and don't understand how it works jsdoc doesn't have public src folder

@bigtimebuddy
Copy link
Member

Here's the offending bit:

webdoc-template/publish.js

Lines 638 to 662 in 9c21d04

// copy user-specified static files to outdir
if (conf.default.staticFiles) {
// The canonical property name is `include`. We accept `paths` for backwards compatibility
// with a bug in JSDoc 3.2.x.
staticFilePaths = conf.default.staticFiles.include ||
conf.default.staticFiles.paths ||
[];
staticFileFilter = new (require("jsdoc/src/filter").Filter)(conf.default.staticFiles);
staticFileScanner = new (require("jsdoc/src/scanner").Scanner)();
cwd = process.cwd();
staticFilePaths.forEach((filePath) => {
let extraStaticFiles;
filePath = path.resolve(cwd, filePath);
extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
extraStaticFiles.forEach((fileName) => {
const toPath = sourceToDestination(fromDir, fileName, outdir);
mkdirpSync(path.dirname(toPath));
fs.copyFileSync(fileName, toPath);
});
});
}

I should probably remove this from the template because it doesn't work (as you've pointed out). This is likely a feature request and question for webdoc, since I'm not sure if there's a Filter/Scanner like APIs for webdoc. @SukantPal thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants