mathjax / MathJax-src

MathJax source code for version 3 and beyond

Home Page:https://www.mathjax.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove file extension from imports in TypeScript files?

hubgit opened this issue · comments

For some reason the TypeScript files are importing from relative paths with '.js' file extensions, which don't exist.

For example, HTMLAdaptor.ts contains:

import {OptionList} from '../util/Options.js';

which should(?) be:

import {OptionList} from '../util/Options';

Closing as I was attempting to use an unusual method of importing the MathJax modules.

Just for the record, you are right the no extensions is the usual approach. The reason we use .js is that without them, the Typescript compilation to es5 ends up without the extensions as well (e.g., with just require('../util/Options') in your example), and while that works for NodeJS, it doesn't work with other loaders, like SystemJS. We use SystemJS in our interactive debugging lab, and that wouldn't work without the .js extensions (at least not at the time we began work on v3; perhaps new versions of SystemJS would handle it). Since Typescript handles the compilation fine with the .js extensions, we felt this was the best compromise for our situation.