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

source .js files cannot be used as entry points #2037

Closed
boneskull opened this issue Aug 17, 2022 · 3 comments
Closed

source .js files cannot be used as entry points #2037

boneskull opened this issue Aug 17, 2022 · 3 comments
Labels
bug Functionality does not match expectation

Comments

@boneskull
Copy link
Contributor

Search terms

javascript sourcemap source map

Expected Behavior

I expected to be able to define my project entry point as a .js file. I am using TS-style docstrings to document JS sources.

Actual Behavior

It complains the .js file must have a sourceMappingUrl and exits with a non-zero error code

Steps to reproduce the bug

  1. Create a .js file. module.exports = true or smth
  2. Use it as an entry point

Environment

  • Typedoc version: TypeDoc 0.23.10
  • TypeScript version: Using TypeScript 4.7.4 from ./node_modules/typescript/lib
  • Node.js version: v18.4.0
  • OS: macOS

I realize why this happens: TypeDoc expects a .js entry point to be a file compiled by tsc; that's the most common use-case.

To work around this, I use a Babel-compiled .js entry point. That entry point references an external source map which references the original source .js file. TypeDoc seemingly has no problems otherwise generating docs from my JS sources.

I note that inline source maps are apparently not supported; an inline source map causes TypeDoc to attempts to open a file using the source map as a filepath, which throws ENAMETOOLONG 😄

I have no idea what the practical impact would be of just allowing a .js source file as the entry point other than making TypeDoc easier to use for those ornery "types-in-JS" people like myself.

@boneskull boneskull added the bug Functionality does not match expectation label Aug 17, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 17, 2022

Are you using packages mode?

@boneskull
Copy link
Contributor Author

Are you using packages mode?

yes

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 26, 2022

I note that inline source maps are apparently not supported;

Just took a look at the code, and they appear to be supported, do you have an example you could toss my way (in a new issue)? Looks like you could break it if the source map URL doesn't start with data:application/json;base64 and is inline, but the maps generated by tsc at least seem to match this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants