question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

publish es6 modules to npm

See original GitHub issue

I was looking to use pdf.js today via something like import {pdfjs} from pdfjs-dist/pdf.js and learned that all that is available is a require module.

Would it be possible to add es6 modules somewhere on npm?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:63
  • Comments:12

github_iconTop GitHub Comments

12reactions
Snuffleupaguscommented, Apr 28, 2022

Any plan to publish ES Modules to catch up with the ecosystem?

Please keep in mind that the primary focus of development for this library is the Firefox PDF Viewer.

For the general PDF.js library, we’ve been doing various work (over the years) to clean-up and simplify things in order to reduce the number of builds that we have to maintain/support. Hence why we provide both browser and Node.js support in the same builds in e.g. pdfjs-dist, and thus it’s not currently planned to add any “new” builds.

This project is developed with ES modules, but the src/ dir just isn’t published in the package on NPM.

And neither should it be, since the only thing that we officially support is the functionality accessed via https://github.com/mozilla/pdf.js/blob/master/src/pdf.js respectively https://github.com/mozilla/pdf.js/blob/master/web/pdf_viewer.component.js (once those files are built and and published in pdfjs-dist).

Please keep in mind that using the “raw” src/-files directly has never be officially recommended nor supported. (Hence the only thing that may, some day in the future, become supported are ESM-versions of the files in e.g. the https://github.com/mozilla/pdfjs-dist/tree/master/build and https://github.com/mozilla/pdfjs-dist/tree/master/web folders.)

Seems like this would be an easy fix, no?

Not really, since as mentioned above we don’t want to add even more builds and we also want to support both browsers and Node.js environments with the same builds.

12reactions
robrezcommented, Dec 12, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Publish An ES6 Module To NPM - Medium
So you want to publish your own NPM module, and you want to write that code in ES6 syntax? Here are the challenges...
Read more >
How to publish a module written in ES6 to NPM?
The pattern I have seen so far is to keep the es6 files in a src directory and build your stuff in npm's...
Read more >
articles/how-to-build-and-publish-es6-npm-modules-today ...
The fundamental idea behind publishing transpiled ES6 modules is that, you create two folders: a source folder, and a distribution folder: The source...
Read more >
es6-modules - npm search
My template for node modules with lint, tests, code coverage, type checking, CI, semantic release and interoperability between ES6 modules and CommonJs.
Read more >
How to build, test and publish an npm package in ES6 [Twitch ...
I this video I show you how to create, build, test and release a node module package that's hosted on npm.The most important...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found