-
Notifications
You must be signed in to change notification settings - Fork 4
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
Integrate Rollup into JavaScript workflow #7
Conversation
- Babel to convert to phone-compatible code - Terser to minify - Rollup for tree shaking - Convert all script inclusions to import statements
- Handle non-zero exit codes from rollup with exceptions - Use destructuring syntax where possible in templates
- Should fix helq#1 in a more elegant way
- Add simple print statements to generation process
Question: does I am not quite sure the added complexity is needed. I am not an expert at all in javascript. The standard seems to change a lot every couple of years adding more and more stuff. So, for me, reading modern javascript is similar to reading modern C++. It looks pretty and simple, but carries tremendous complexities behind and many, many gotchas. What I'm trying to say is that I have no idea whether updating the syntax of the javascript code is a good idea. What is wrong with staying with the old approach. Also, each HTML file gets bigger in the end when copying all the Anyway, I want to thank you for taking the time, but mostly for your patience. Please, take care. Kindest, |
If you have node installed, it just installs stuff to
That's fair, it does change fairly often. However, nothing will spontaneously break within the project unless a developer decides to manually update the JavaScript packages. The code itself is stable.
It's been weeks since I looked at it, but as I stated in the OP, rollup prunes functions that are not used within a given HTML document. So you can have everything in There is some boilerplate that babel inserts in order to ensure compatibility with older devices, and there is more boilerplate the newer a feature is, but it's generally not that much. I'd have to do a more thorough comparison to give specifics, though. I should mention that I don't think this PR is necessary unless further changes to the codebase are planned. It is mostly just a future-proofing PR. I personally had some plans to add to the codebase, particularly to expand the IPA stuff, but I've also become very busy lately. |
In that case @ribbanya, I would argue to wait until this PR is necessary. I am all for simplicity and adding yet another dependency, a huge one, doesn't seem like the simplest thing to me. Also, if we are thinking about future proving code, we should think of writing autocontained scripts with no dependencies outside of the official libraries. That would create, almost certainly, future-proof code. That's assuming that in 20 years, Anki will be the same, if it still exists. I hope Anki or something similar, but more modular, still exists in 20 years. After all, the reason for this project to exist in the first place is because of the difficulty to create complex Anki cards and decks. It would be awesome if all of this was handled directly by Anki, either at creation time of each card type and note, or by standarizing the interaction between javascript, the front of the card, the back of the card and the html available to the user. Let's not add more complexity to the system yet, unless the payoff is substantial. Thanks for your effort nonetheless. I wish you luck with all your projects :) |
(Note: Merging #5 will collapse the first 12 commits in this request. The actual request starts at 06d6b55.)
Overview
This pull request integrates rollup directly into
generate-deck.py
. This requires Node.js to be installed on the generating machine but it has many advantages:import
statements instead of using<script src="...">
tags or worse, copy-pasting code.let
andconst
, while ensuring compatibility with devices using@babel/preset-env
./*EOL {{template}} EOL*/
comments are preserved through terser options.Status
Example transformation
Linked is a gist showing the source HTML, how it looks in Anki, and how the Anki version looks when reformatted.