What is the build process? How do you bundle your app? (Parcel|Webpack|Rollup|Browserify)
Bonus Prettier for the lulz
import prettier from 'prettier' import * as Terser from 'terser' const main = () => { const input = document.getElementById('theinput') const output = document.getElementById('theoutput') const makeTerser = () => { const minified = Terser.minify( input.value, /* remove this options object to mangle names */ { mangle: false, }, ) if (minified.code) output.value = minified.code } const makePrettier = () => { try { const pretty = prettier.format(output.value, { parser: 'babylon', }) input.value = pretty } catch (err) {} } input.addEventListener('input', makeTerser, { passive: true }) output.addEventListener('input', makePrettier, { passive: true }) input.value = `function fibonacci(num, memo = {}) { if (memo[num]) return memo[num] if (num <= 1) return 1 return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo) } ` makeTerser() } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', main, { once: true, passive: true, }) } else { main() }
click it just click it do not be afraid just click it
I was not really planning to use a bundler. Wanted to go vanilla and with no build/npm. But it looks like I have to, which is not a big deal at all.
Thank you for the example! Extremely helpful!!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What is the build process? How do you bundle your app? (Parcel|Webpack|Rollup|Browserify)
Bonus Prettier for the lulz
click it just click it do not be afraid just click it
I was not really planning to use a bundler. Wanted to go vanilla and with no build/npm. But it looks like I have to, which is not a big deal at all.
Thank you for the example! Extremely helpful!!