Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Moving Pleo’s frontend into the Third Age of Ja...

Moving Pleo’s frontend into the Third Age of JavaScript. From Webpack to Vite.

Learnings from migrating Pleo’s frontend from Webpack to Vite.

Kenneth Skovhus

June 15, 2022
Tweet

More Decks by Kenneth Skovhus

Other Decks in Programming

Transcript

  1. @KENNETH_SKOVHUS MOVING PLEO’S FRONTEND INTO THE THIRD AGE OF JAVASCRIPT

    FROM WEBPACK TO VITE @KENNETH_SKOVHUS REACT MEETUP AT PLEO JUNE 2022
  2. @KENNETH_SKOVHUS HI! I'M KENNETH HAVING FUN WITH REACT SINCE 2015

    🧙 PLEO’S WEB CORE TEAM WORKED AT: ISSUU, LEO INNOVATION LABS, UNITY, TOMORROW (ELECTRICITYMAP.ORG)
  3. @KENNETH_SKOVHUS FIRST AGE OF JS 1997-2007 BUILDING OUT THE LANGUAGE

    LIBRARIES: DOJO, JQUERY, MOOTOOLS LANGUAGE: ES1-ES3, ES4 ABANDONED
  4. @KENNETH_SKOVHUS FIRST AGE OF JS 1997-2007 BUILDING OUT THE LANGUAGE

    LIBRARIES: DOJO, JQUERY, MOOTOOLS LANGUAGE: ES1-ES3, ES4 ABANDONED MACROMEDIA FLASH THRIVING 🎄
  5. @KENNETH_SKOVHUS USERS EXPLORING AND EXPANDING THE LANGUAGE RUNTIMES: CHROME, NODE.JS

    (COMMON JS), ELECTRON, REACT NATIVE TOOLS: NPM, COFFEESCRIPT, BROWSERIFY, WEBPACK, FLOW, TYPESCRIPT, JEST, PRETTIER LIBRARIES: BACKBONE, ANGULAR, METEOR, REACT, VUE, SVELTE LANGUAGE: ES5, ES6 (MODULES), ES201X+ SECOND AGE OF JS 2009-2019
  6. @KENNETH_SKOVHUS CLEARING AWAY LEGACY ASSUMPTIONS 👋 COMMON JS, MODULES NOT

    SUPPORTED 👋 JS TOOLS BUILD IN JS 👋 LANGUAGE VARIATIONS (BABEL, TYPESCRIPT) 👋 CUSTOM FILE LOADERS (E.G. SVG, CSS MODULES) THIRD AGE OF JS 2020-2030?
  7. @KENNETH_SKOVHUS VITE “VIT” DEV SERVER & BUILD TOOL BY THE

    VUE COMMUNITY BASED ON ESBUILD (GO) & ROLLUP
  8. @KENNETH_SKOVHUS SLOW CUSTOM TOOLCHAIN BASED ON WEBPACK 4 2019 MAY:

    DREAMING OF REPLACE THIS WITH A COMMUNITY MAINTAINED ONE (E.G. CREATE REACT APP) 2022 APRIL: WE MIGRATED TO VITE
  9. @KENNETH_SKOVHUS 🚧 HACK SOME DEPENDENCIES FOR ESM COMPATIBILITY import {viteCommonjs}

    from '@originjs/vite-plugin-commonjs' resolve: { alias: { // Workaround as ESM version of react-virtualized is broken. // https://github.com/bvaughn/react-virtualized/issues/1212 'react-virtualized': 'react-virtualized/dist/umd/react-virtualized.js', }, }, plugins: [ // Fix missing ESM support for legacy third parties viteCommonjs({include: ['react- fl exbox-grid']), ]
  10. @KENNETH_SKOVHUS THE OUTCOME: FIRST CONTENTFUL PAINT Webpack Vite % 10s

    ±0.6s 7.2s ±0.6s -28 % Better bundle splitting, less down-levelling, better tree shaking
  11. @KENNETH_SKOVHUS THE OUTCOME: LIGHTHOUSE PERFORMANCE Webpack Vite % 78 89

    14 % Better bundle splitting, less down-levelling, better tree shaking
  12. @KENNETH_SKOVHUS CLEARING AWAY LEGACY ASSUMPTIONS 👋 COMMON JS, MODULES NOT

    SUPPORTED 👋 JS TOOLS BUILD IN JS 👋 LANGUAGE VARIATIONS (BABEL, TYPESCRIPT) 👋 CUSTOM FILE LOADERS (E.G. SVG, CSS MODULES) THIRD AGE OF JS 2020-2030?
  13. @KENNETH_SKOVHUS MOVING PLEO’S FRONTEND INTO THE THIRD AGE OF JAVASCRIPT

    FROM WEBPACK TO VITE @KENNETH_SKOVHUS REACT MEETUP AT PLEO JUNE 2022
  14. @KENNETH_SKOVHUS MOVING PLEO’S FRONTEND INTO THE THIRD AGE OF JAVASCRIPT

    FROM X TO Y @KENNETH_SKOVHUS REACT MEETUP AT PLEO JUNE 2022