trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
187.75k stars 30.18k forks source link

Suggestion: ship production ready build to npm #196

Open jmike opened 6 years ago

jmike commented 6 years ago

Hey,

I noticed that the current version deployed on npm (i.e. https://www.npmjs.com/package/javascript-algorithms-and-data-structures) is more or less a mirror of the source code here. javascript-algorithms is really awesome and someone might want to use it as an external library on production (e.g. a web app or node app). Unfortunately, the use of ES modules, complicates things a bit.

May I suggest:

  1. Transpiling code to ES2015, using CommonJS instead of ES modules;
  2. Removing redundant source code (e.g. comments, README, etc) to reduce package size.

I'd be more that willing to provide a PR using rollup + babel.

trekhleb commented 6 years ago

Hi @jmike Thank you for suggestion.

Please go ahead and create a PR for that if you want to.

One important thing that should probably be mentioned here is that this repo is not meant to be used on production. It is for learning and researching purposes only. The only reason for having this repo on npm is probably to make it possible to re-use its functions by other non-production research projects.

jasonwilliams commented 6 years ago

I agree with @trekhleb i'm not sure its a good idea to signal this project is for production use, it might set a precedent of users then wanting to optimise certain functions, which then defeats the learning aspect of it. Maybe its worth saying in the README these shouldn't be used in production instead?

trekhleb commented 6 years ago

@jasonwilliams this notification it is already in README here.

jasonwilliams commented 6 years ago

ahh i should have RTFM!

trekhleb commented 6 years ago

No problem :D

ozzyogkush commented 5 years ago

Perhaps a forked repository with production-ready code that does have such optimizations would be useful.

JXWJS commented 5 years ago

J

mik-laj commented 5 years ago

@jmike Have you made any progress in this issues? Recently, I worked on a college project and the lack of a proper package in npm made my work very difficult.

moodmosaic commented 4 years ago

Edit: Resolved via https://babeljs.io/en/setup#installation.


What would be the easiest way to reference this project from another project? Cloning the repo and running npm install didn't help much:

require(
  "../node_modules/javascript-algorithms-and-data-structures/src/algorithms/graph/bellman-ford/bellmanFord.js")
export default function bellmanFord(graph, startVertex) {
^^^^^^

SyntaxError: Unexpected token 'export'