-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Light bundle version #14
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thanks!
I don't know how to test if the bundles are smaller.
I don’t think that’s needed to add. This should work.
But just to be sure, you could take a look at the npm script build-mangle
, and use similar code to see if it actually works (I like using https://github.com/sindresorhus/gzip-size-cli to check the sizes of files)
How should at least one language be enforced and which options field to use? I've used the languages field.
For testing? How do you mean?
There should be some docs on this new plugin. Similar to the Browser section in lowlight (https://github.com/wooorm/lowlight#browser) perhaps?
test-light.js
Outdated
'<pre><code class="hljs language-javascript"><span class="hljs-meta">"use strict"</span>;</code></pre>' | ||
].join('\n'), | ||
'should highlight (no class)' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these test can go in the main test file, no need to copy-paste it all!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should at least one language be enforced and which options field to use? I've used the languages field.
For testing? How do you mean?
If a user doesn't provide a language, there won't be any highlighting. Should it be mandatory that the user provides at least one language? Is the field "languages" a good place to put the selected languages to bundle?
There should be some docs on this new plugin. Similar to the Browser section in lowlight (https://github.com/wooorm/lowlight#browser) perhaps?
I'll get to it at the end if it's OK with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these test can go in the main test file, no need to copy-paste it all!
I suppose this is related to my question:
Should I just duplicate the tests? I didn't have time to understand them all. I'll move them to the main test.js once they work. I'd prefer to go one by one from a clean slate in a different file for starters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for the tests, indeed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user doesn't provide a language, there won't be any highlighting. Should it be mandatory that the user provides at least one language? Is the field "languages" a good place to put the selected languages to bundle?
I think that should be clearly documented. I don’t think we need to do extra work to go into the languages
object to see if there’s at least one key or not 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user doesn't provide a language, there won't be any highlighting. Should it be mandatory that the user provides at least one language? Is the field "languages" a good place to put the selected languages to bundle?
I think that should be clearly documented. I don’t think we need to do extra work to go into the
languages
object to see if there’s at least one key or not 🤷♂️
"no extra work " seems fine with me 😁
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
A couple of nits on the docs (especially the example, I placed it in a file locally, formatted it, so that it matches the coding style of this project)
I don’t think you need so many tests! Most of the code is shared with the main plugin, so there’s no need to repeat every test! 3-5 would be fine by me
test.js
Outdated
var light = require('./light') | ||
var js = require('highlight.js/lib/languages/javascript') | ||
var as = require('highlight.js/lib/languages/applescript') | ||
var cp = require('highlight.js/lib/languages/cpp') | ||
var lt = require('highlight.js/lib/languages/latex') | ||
var su = require('highlight.js/lib/languages/subunit') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move these to the top, so when opening this file it’s immediately clear what’s loaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good.
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
Co-authored-by: Titus <[email protected]>
awesome, thanks for your hard work on this @arturcarvalho. Released! |
🎉 Thank you, it was a pleasure working with you. Really liked the process around it all. Practical but efficient and thorough. Even the apostrophes are being checked 😁 |
Hi again @wooorm.
This PR is related to this discussion
First of all, thanks! I've reduced the bundle chunk by about 200kB!
What I did:
var lowlight = require('lowlight/lib/core');
remark-rehype
andrehype-stringify
.remark-highlight
I used my ownremark-highlight
as said on the first point.There's a strange thing going on, if I
import
thelib/languages
instead ofrequire
them, the bundle size stays big. I'm using nextjs, maybe it's related.This is the calling file:
Now to the PR (and its problems):
The issues:
files
field? My require/npm publishing experience is limited.languages
field.In any case, thanks for your help and hope this is helpful!