Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Don't mangle i18n #93

Merged
merged 3 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .circleci/config.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,33 @@ jobs:
run: yarn install
- name: typecheck
run: yarn flow
test:
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
kevinbarabash marked this conversation as resolved.
Show resolved Hide resolved
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node_modules-
- name: yarn install
run: yarn install
- name: jest tests
run: yarn test
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"react-dom": "16.5",
"react-router-dom": "^4.2.2",
"react-transition-group": "^4.4.1",
"terser-webpack-plugin": "^4.2.3",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.4.1"
Expand Down
49 changes: 49 additions & 0 deletions terser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Configuration for Terser optimisation that's shared.
*
* To use, import as `terserOptions` and spread into the `optimize` section
* in the webpack config.
*/
const TerserPlugin = require("terser-webpack-plugin");

const PRESERVED_IDENTIFIERS = [
"i18n",
];

module.exports = {
minimize: true,
minimizer: [
new TerserPlugin({
// Enable caching to reduce time of subseqeuent builds
cache: true,
// Don't touch .css or .less files or any of the files
// that we explicitly want to avoid compressing.
// NOTE(jeresig): Changing this list may result in bundles
// not being updated properly until their underlying
// contents change (disabling minimization doesn't change
// the hash). See: WEB-629.
exclude: [/\.(css|less)$/],
// Use ALL the cores (seriously)
parallel: true,
// Make it possible to generate source maps
sourceMap: true,
// Don't extract the comments/licenses
extractComments: false,
// Additional options passed to terser itself
terserOptions: {
// Make it use a modern ECMAScript release
// NOTE(jeresig): If/when we change this there should be a
// full QE pass to confirm that our supported browsers still
// work as expected.
ecma: 2018,
// We want to compress as it reduces the gzipped filesize by
// about 5%, which is not trivial!
compress: true,
mangle: {
// Retain some identifiers (see above)
reserved: PRESERVED_IDENTIFIERS,
},
},
}),
],
};
4 changes: 3 additions & 1 deletion webpack.config.externals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const terserOptions = require("./terser.js");

module.exports = {
entry: "./src/index.js",
mode: "production",
Expand All @@ -12,7 +14,7 @@ module.exports = {
libraryTarget: "umd",
},
optimization: {
minimize: true,
...terserOptions,
},
module: {
rules: [
Expand Down
Loading