anoduck / mod-pdfview

Module for [Hinode](https://github.com/gethinode/hinode) to allow embeding of pdf files.
MIT License
0 stars 0 forks source link

Library currently missing means to generate pdf.js from node.js module. #4

Open anoduck opened 5 days ago

anoduck commented 5 days ago

Not a JavaScript programmer, but did not want to include static JavaScript libraries in the module as it would increase the difficulty of performing updates, and did not want to rely on a Content Distribution Service provider as there are situations where that is not preferable. Thus bore the inspiration to use npm to provide the needed library.

The problem is npm manages modules and not common javascript libraries for use with web browsers, so it appears the module files (.mjs) will need to be transpiled(?) into commonjs files. It appears babeljs is the go-to solution to perform this transpilation, but setup of babeljs is an uphill climb as it assumes there is a basic understanding of JavaScript, and there is not.

Another, less favorable option, is to change the attribute type of the JavaScript files, and include the module files without modification. Most modern browsers can handle this, but older browsers that do not follow the current browser standard will not be compatible with this option. Below is an example of this solution.

<!-- Before, with original type description of "text/javascript" -->
<script type="text/javascript" src="/js/pdf.js"></script>
<!-- After, with type description changed to "module" -->
<script type="module" src="/js/pdf.mjs"></script>
anoduck commented 5 days ago

The Babeljs usage guide describes how to do this on the first page, as it should. Babel Usage Guide

anoduck commented 4 days ago

The Babeljs usage guide describes how to do this on the first page, as it should. Babel Usage Guide

Well, that isn't exactly true.