arj03 / ssb-browser-demo

A secure scuttlebutt client interface running in the browser
Other
58 stars 11 forks source link

Patch out Highlight.js #236

Closed KyleMaas closed 3 years ago

KyleMaas commented 3 years ago

More work on #219. Patches out Highlight.js. Takes release bundle down to 3558556 bytes - savings of 799711 bytes.

arj03 commented 3 years ago

Sweet.

KyleMaas commented 3 years ago

I got thinking about this - since this is patching a source file and removing specifically 9 lines, we might want to lock ssb-markdown's version in place and only upgrade when we've tested it, rather than doing a hat dependency where the file might change out from under us.

arj03 commented 3 years ago

Yeah but we do have the shrinkmap file. This postinstall is pnpm specific, right?

KyleMaas commented 3 years ago

npm-specific, yes.

arj03 commented 3 years ago

Wierd, its not working here. Are you using bash shell?

KyleMaas commented 3 years ago

Yes. Is it giving you an error?

arj03 commented 3 years ago

Yeah:

> pushd node_modules/pull-async-filter; sed -i 's/2.26.0/3.6.14/' package.json; rm -rf node_modules/pull-stream; popd; pushd node_modules/pull-goodbye; sed -i 's/3.5.0/3.6.14/' package.json; rm -rf node_modules/pull-stream; popd; pushd node_modules/ssb-markdown; sed -i -e '/highlight: function/,+8 d' -e '/highlight/d' lib/block.js; sed -i '/highlight.js/d' package.json; popd; rm -rf node_modules/highlight.js

sh: 1: pushd: not found
sh: 1: popd: not found
sh: 1: pushd: not found
sh: 1: popd: not found
sh: 1: pushd: not found
sed: can't read lib/block.js: No such file or directory
sh: 1: popd: not found
KyleMaas commented 3 years ago

Oh, you're using sh, not bash.

arj03 commented 3 years ago

npm must be. I should be running bash.

arj03 commented 3 years ago

npm config set script-shell bashworked, but I would rather not have to instruct users to do that.

KyleMaas commented 3 years ago

Well, I suppose if you need to, those can be changed to cd nodule_modules/pull-async-filter (etc.) and cd ../.. I just prefer pushd and popd because I feel they're a little more robust in case of failures.

arj03 commented 3 years ago

For browser-core I have used the patches folder. That always works. Good old patch :-)

KyleMaas commented 3 years ago

How are patches in that folder applied? I don't see anything in ssb-browser-core that actually does that.

arj03 commented 3 years ago

It's manually applied as it's optional. Because it just decreases the bundle size. Like these ones.