Skip to content
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

Upgrade to Webpack v5 to allow proper Tree Shaking. #463

Merged
merged 1 commit into from
Nov 10, 2020

Commits on Nov 10, 2020

  1. Upgrade to Webpach v5 to allow proper Tree Shaking.

    Our goal is to allow tree shaking by removing formatters from formatters.js.
    Webpack v4 did not support this. Therefore, this PR upgrades the Theme to use
    v5. Note that this is a new major version of Webpack, meaning there were some
    breaking changes. To support v5, I had to make these changes to the
    webpack-config:
    - The keyword 'query' is no longer supported. It is called 'options' now.
    - Query params, such as 'name=[name].[contenthash]...', can no longer be
      used with loaders. Those params must be specified in 'options'.
    - v5 introduced 'publicPath: "auto"', but not all plugins can handle this
      yet. In the interim, we should set 'output.publicPath: ""'.
    
    I also upgraded grunt-webpack and the mini-css-extract-plugin to versions that
    better support Webpack v5.
    
    After the upgrade, I made sure that removing formatters from formatters.js
    tree shakes all their 3rd party dependencies.
    
    J=SLAP-827
    TEST=manual
    
    Tested the following:
    
    - libPhoneNumber was not included in the bundle when nationalizedPhoneDisplay
      was removed from formatters.js.
    - Asset urls were resolved properly for a non-ML site regardless of whether or
      not bundle.js and bundle.css were inlined.
    - Asset urls were resolved properly for a ML site without inlining.
    - I selected a random sample of the HitchhikerJS.Formatters to ensure they
      worked as expected.
    - isMobile and isStaging from bundle.js still worked as expected.
    - The iFrame integration worked as expected.
    tmeyer2115 committed Nov 10, 2020
    Configuration menu
    Copy the full SHA
    a5dbc39 View commit details
    Browse the repository at this point in the history