Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use npm & bundle js for browser #1

Open
TheDiscordian opened this issue Oct 19, 2022 · 4 comments
Open

Use npm & bundle js for browser #1

TheDiscordian opened this issue Oct 19, 2022 · 4 comments
Labels
difficulty-5 Difficulty, 0 is the easiest, higher numbers are probably harder. help wanted Extra attention is needed

Comments

@TheDiscordian
Copy link
Owner

Right now we just use vanilla JS, but in order to be more friendly to new developers an npm & webpack system would likely simplify things.

@TheDiscordian TheDiscordian added good first issue Good for newcomers difficulty-2 Difficulty, 0 is the easiest, higher numbers are probably harder. labels Oct 19, 2022
@TheDiscordian TheDiscordian added difficulty-5 Difficulty, 0 is the easiest, higher numbers are probably harder. help wanted Extra attention is needed and removed difficulty-2 Difficulty, 0 is the easiest, higher numbers are probably harder. good first issue Good for newcomers labels Oct 27, 2022
@TheDiscordian
Copy link
Owner Author

TheDiscordian commented Oct 27, 2022

I've given up on this issue. JS tooling simply doesn't make this easy. It's like writing code in the 90s, no compass, no map.

If someone wants to attempt it we need the following libraries bundled:

  • ipfs-http-client
  • bootstrap v4.6
  • jquery v3.6
  • localforage

We'll also need the emoji library bundled.

For scaffolding, we only need ipfs-http-client. If I attempt this again, it will be focused only on that. For DiscoChat itself, it's unlikely we'll ever use webpack (unless someone wants to put in the non-trivial effort into making that happen).

This would be a great start, but unfortunately I'm either wrestling with the tools or I'm getting useless errors (Maximum call stack size exceeded.).

Alternatively building our own tooling seems fine, it would likely take less time...

@TheDiscordian
Copy link
Owner Author

TheDiscordian commented Oct 27, 2022

I ran into the exact same bug after removing every single module except ipfs-http-client, I also tried Browserify and documented the experience here.

Custom tool sounds like the easiest option, just crawl the dependencies, download the desired version from jsdelivr (let's just grab what we need from node_modules). This way we can still use NPM for versioning, warnings, etc, and we don't need to rely on the janky JS ecosystem tools to bundle the JS.

@TheDiscordian TheDiscordian changed the title Use webpack & npm Use npm & bundle js for browser Oct 27, 2022
@TheDiscordian
Copy link
Owner Author

Custom tool minimal example:

import json, shutil

package = json.load(open("package.json"))
for i in package["dependencies"]:
	shutil.copyfile("node_modules/%s/dist/index.min.js" % i, "ui/%s.min.js" % i)

@TheDiscordian TheDiscordian transferred this issue from TheDiscordian/disco-chat Nov 23, 2022
@TheDiscordian
Copy link
Owner Author

Updating this issue to note: If a package manager other than npm is better, totally not "locked-in" to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty-5 Difficulty, 0 is the easiest, higher numbers are probably harder. help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant