mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Add support for the import map in the type generator
The typescript compiler is now configured to know about the import map to be able to resolve those imports and find the associated types. As tsc outputs declaration files using the original module identifiers and not the resolved ones, tsc-alias is used to post-process the declaration files by resolving those paths.
This commit is contained in:
parent
bbf11a5783
commit
d0f14b1ce3
4 changed files with 273 additions and 2 deletions
|
@ -266,6 +266,9 @@ function createWebpackConfig(
|
|||
viewerAlias["web-com"] = "web/chromecom.js";
|
||||
viewerAlias["web-print_service"] = "web/pdf_print_service.js";
|
||||
} else if (bundleDefines.GENERIC) {
|
||||
// Aliases defined here must also be replicated in the paths section of
|
||||
// the tsconfig.json file for the type generation to work.
|
||||
// In the tsconfig.json files, the .js extension must be omitted.
|
||||
libraryAlias["display-fetch_stream"] = "src/display/fetch_stream.js";
|
||||
libraryAlias["display-l10n_utils"] = "web/l10n_utils.js";
|
||||
libraryAlias["display-network"] = "src/display/network.js";
|
||||
|
@ -1551,7 +1554,9 @@ gulp.task("types", function (done) {
|
|||
console.log("### Generating TypeScript definitions using `tsc`");
|
||||
exec(
|
||||
`"node_modules/.bin/tsc" --outDir ${TYPES_DIR} --project .`,
|
||||
done
|
||||
function () {
|
||||
exec(`"node_modules/.bin/tsc-alias" --outDir ${TYPES_DIR}`, done);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue