Open rkusa opened 6 years ago
Anyone aware of a tool to automatically convert a library to es6 modules?
While I did an initial conversion, I am not yet sure how to handle the fact that pdfjs should work for both server and client. Since Node.js requires the file extension of .mjs
Hello have a look here https://github.com/nolanlawson/cjs-to-es6
Other ideas on stackoverflow https://stackoverflow.com/questions/43106130/convert-existing-legacy-library-to-es6-module
Hi @jpbourgeon, thanks for the links. I have already converted the library in a local branch, but was not able to find a good es6 modules solution for libraries that target both server (Node.js) and client π
Would it help to split the library into two components and take advantage of npmjs namespaces?
Something like @pdfjs/server
and @pdfjs/browser
I guess there are the following options.
1) Write client-side ES modules (.js)
import {Document} from "pdfjs"
require
2) Write server-side ES modules (.mjs)
import {Document} from "pdfjs"
require
require
to work3) Keep CJS modules
import {Document} from "pdfjs"
)require
import * as pdf from "pdfjs"
when loading pdfjs
from ES modules (instead of being able to import named exports import {Document} from "pdfjs"
)In Summary, either transpile the code for Node.js usage or live with import {Document} from "pdfjs"
. TBH, I really dislike both options π
The conversion happens here https://github.com/rkusa/pdfjs/tree/es6-modules Though, the branch is unfortunately not green yet
Would it be of interest to move to TS instead of ES6?
Would it be of interest to move to TS instead of ES6?
I've recently had the pleasure to work on a TypeScript codebase [1] using WebStorm [2]Β and I want to report that the overall experience is absolutely amazing and totally washed away any hesitations I had regarding TypeScript. Finally, I feel like I can get similar productive with JavaScript as I am with Python. ES6 did not give me that feeling yet.
[1] https://github.com/hiveeyes/grafana-worldmap-panel [2] https://www.jetbrains.com/webstorm/
@rkusa: Amazing project, greetings from Berlin and keep up the spirit!
My pet project is https://github.com/AllNamesRTaken/GoodCore outside workhours and i could help out is needed.
@AllNamesRTaken: Sounds interesting, thanks for letting us know. Star-given ;].
Would it be of interest to move to TS instead of ES6?
I am, generally speaking, not opposed to TS.
I've recently had the pleasure to work on a TypeScript codebase [1] using WebStorm [2] and I want to report that the overall experience is absolutely amazing and totally washed away any hesitations I had regarding TypeScript.
I can confirm that. In my day job, I also work more with TS than JS and the whole TS dev experience (editor integration, less errors when refactoring, ...) is superior than JS ...
What currently holds me off from converting the codebase to TS:
Before leaving alpha, the library should be converted to using es6 modules.