@elliemae/pui-cli 6.0.0-beta.3 → 6.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,10 @@
1
+ /* eslint-disable max-lines */
1
2
  const { exit } = require('yargs');
2
3
  const path = require('path');
3
4
  const { writeFile, readFile } = require('fs/promises');
4
5
  const { exec, logInfo, logError, logSuccess } = require('./utils');
5
6
  const { isTypeScriptEnabled } = require('../typescript/util');
7
+ const { esBuild } = require('../transpile/esbuild');
6
8
 
7
9
  const { name } = require('../../package.json');
8
10
 
@@ -37,14 +39,9 @@ async function createPackageJson(file, commonJS, sideEffects) {
37
39
  await writeFile(file, packageJSON);
38
40
  }
39
41
 
40
- async function nodeBuild({ srcPath, commonJS, emitModuleType, target }) {
42
+ async function nodeBuild({ srcPath, commonJS, emitModuleType }) {
41
43
  const outDir = `./dist/${commonJS ? 'cjs' : 'es'}`;
42
- const targetEnv = target === 'node' ? 'TARGET_ENV=node' : '';
43
- const babelEnv = commonJS ? ' ES_MODULES=false' : '';
44
- await exec(
45
- `cross-env NODE_ENV=production MODULE_EXTENSIONS=true ${targetEnv}${babelEnv} babel --extensions ".ts,.tsx,.js,.jsx" ${srcPath} --out-dir ${outDir} --copy-files --no-copy-ignored --ignore **/*.test.js --ignore **/*.test.ts --ignore **/*.spec.js --ignore **/*.spec.ts --ignore **/*.test.jsx --ignore **/*.test.tsx --ignore **/*.spec.jsx --ignore **/*.spec.tsx`,
46
- { shell: true, stdio: 'inherit' },
47
- );
44
+ await esBuild({ srcPath, commonJS });
48
45
  if (emitModuleType) {
49
46
  const sideEffects = await getSideEffects();
50
47
  await createPackageJson(
@@ -79,7 +76,6 @@ async function pack({ production, target, module, srcPath, emitModuleType }) {
79
76
  srcPath,
80
77
  commonJS: false,
81
78
  emitModuleType,
82
- target,
83
79
  });
84
80
  }
85
81
  }
@@ -118,7 +114,6 @@ exports.builder = {
118
114
  },
119
115
  emitModuleType: {
120
116
  type: 'boolean',
121
- // eslint-disable-next-line max-lines
122
117
  default: true,
123
118
  description:
124
119
  'creates type attribute in the package.json and sets its value to commonjs or module based on module cli argument. default: true',
@@ -1,11 +1,12 @@
1
1
  const { exit } = require('yargs');
2
2
  const { exec, logError, logSuccess } = require('./utils');
3
- const { lintCSS, lintJS } = require('./lint');
4
3
 
5
4
  const { CI = false } = process.env;
6
5
 
7
6
  async function test(commandOptions) {
8
- await exec(`cross-env FORCE_COLOR=true NODE_ENV=test jest ${commandOptions}`);
7
+ await exec(
8
+ `cross-env FORCE_COLOR=true NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest ${commandOptions}`,
9
+ );
9
10
  }
10
11
 
11
12
  // eslint-disable-next-line max-statements
@@ -19,17 +20,7 @@ async function handler(argv) {
19
20
  if (argv.r) commandOptions += ' --bail --findRelatedTests';
20
21
  if (argv.s) commandOptions += ' --silent';
21
22
  try {
22
- if (!CI) {
23
- try {
24
- await lintJS();
25
- await lintCSS();
26
- logSuccess('Linting completed');
27
- } catch (err) {
28
- logError('Linting failed');
29
- exit(-1, err);
30
- return -1;
31
- }
32
- } else {
23
+ if (CI) {
33
24
  await exec('rimraf ./reports');
34
25
  }
35
26
 
@@ -9,6 +9,7 @@ exports.baseExtends = [
9
9
  'plugin:jsdoc/recommended',
10
10
  'plugin:wdio/recommended',
11
11
  'plugin:testing-library/dom',
12
+ 'plugin:storybook/recommended',
12
13
  ];
13
14
 
14
15
  const basePlugins = ['testing-library', 'jest', 'jsdoc', 'wdio'];
@@ -36,12 +37,10 @@ const baseRules = {
36
37
  'import/prefer-default-export': 0,
37
38
  'import/extensions': [
38
39
  2,
39
- 'ignorePackages',
40
+ 'never',
40
41
  {
41
- js: 'never',
42
- jsx: 'never',
43
- ts: 'never',
44
- tsx: 'never',
42
+ json: 'ignorePackages',
43
+ js: 'ignorePackages',
45
44
  },
46
45
  ],
47
46
  indent: [
@@ -104,7 +103,7 @@ const reactRules = {
104
103
  'react/react-in-jsx-scope': 0,
105
104
  'react/jsx-filename-extension': [
106
105
  1,
107
- { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
106
+ { extensions: ['.js', '.jsx', '.tsx', '.mdx'] },
108
107
  ],
109
108
  'redux-saga/no-yield-in-race': 2,
110
109
  'redux-saga/yield-effects': 2,
@@ -0,0 +1,18 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const { merge } = require('lodash');
4
+
5
+ const baseConfig = {
6
+ esBuild: {
7
+ target: 'es2020',
8
+ },
9
+ };
10
+
11
+ const getPUIConfig = () => {
12
+ const configPath = path.resolve(process.cwd(), './pui.config.js');
13
+ if (!fs.existsSync(configPath)) return baseConfig;
14
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
15
+ return merge(baseConfig, config);
16
+ };
17
+
18
+ exports.getPUIConfig = getPUIConfig;
@@ -13,8 +13,11 @@ const { loadRoutes } = require('./util');
13
13
  const { getAssetPath } = require('../webpack/helpers');
14
14
 
15
15
  const pino = expressPinoLogger({
16
- prettyPrint: {
17
- levelFirst: true,
16
+ transport: {
17
+ target: 'pino-pretty',
18
+ options: {
19
+ colorize: true,
20
+ },
18
21
  },
19
22
  });
20
23
  pino.logger.level = 'warn';
@@ -57,13 +60,6 @@ const customHost = argv.host || process.env.HOST;
57
60
  const host = customHost || null; // Let http.Server use its default IPv6/4 host
58
61
  const prettyHost = customHost || 'localhost';
59
62
 
60
- // use the gzipped bundle
61
- app.get('*.js', (req, res, next) => {
62
- req.url += '.gz';
63
- res.set('Content-Encoding', 'gzip');
64
- next();
65
- });
66
-
67
63
  // Start your app.
68
64
  app.listen(port, host, async (err) => {
69
65
  if (err) {
@@ -1,5 +1,5 @@
1
1
  const webpack = require('webpack');
2
- const express = require('express');
2
+ const expressStaticGzip = require('express-static-gzip');
3
3
  const webpackDevMiddleware = require('webpack-dev-middleware');
4
4
  const webpackHotMiddleware = require('webpack-hot-middleware');
5
5
  const { sendFileWithCSPNonce } = require('../csp');
@@ -25,7 +25,7 @@ module.exports = function addDevMiddlewares(app, webpackConfig) {
25
25
  heartbeat: 10 * 1000,
26
26
  }),
27
27
  );
28
- app.use(express.static('cdn'));
28
+ app.use(expressStaticGzip('cdn'));
29
29
 
30
30
  const { outputFileSystem } = (middleware || {}).context || {};
31
31
 
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
- const express = require('express');
3
2
  const compression = require('compression');
3
+ const expressStaticGzip = require('express-static-gzip');
4
4
  const { sendFileWithCSPNonce } = require('../csp');
5
5
 
6
6
  module.exports = function addProdMiddlewares(app, options) {
@@ -17,8 +17,15 @@ module.exports = function addProdMiddlewares(app, options) {
17
17
  sendFileWithCSPNonce({ outputPath, res });
18
18
  });
19
19
 
20
- app.use(publicPath, express.static(outputPath, { index: false }));
21
- app.use(express.static('cdn'));
20
+ app.use(
21
+ publicPath,
22
+ expressStaticGzip(outputPath, {
23
+ index: false,
24
+ enableBrotli: true,
25
+ orderPreference: ['br'],
26
+ }),
27
+ );
28
+ app.use(expressStaticGzip('cdn'));
22
29
 
23
30
  app.get('*', (req, res) => sendFileWithCSPNonce({ outputPath, res }));
24
31
  };
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const { getAppConfig, getAssetPath } = require('../webpack/helpers');
3
+ const swcrcConfig = require('../transpile/swcrc.config.js');
3
4
 
4
5
  const name = '@elliemae/pui-cli';
5
6
  const rootDir = path.join('<rootDir>', 'node_modules', name);
@@ -42,8 +43,8 @@ const jestConfig = {
42
43
  '!app/*/RbGenerated*/*.{js, ts, jsx, tsx}',
43
44
  '!app/index.{js, ts, jsx, tsx}',
44
45
  '!app/global-styles.{js, ts, jsx, tsx}',
45
- '!app/*/*/loadable.{js, ts, jsx, tsx}',
46
- '!lib/*/*/loadable.{js, ts, jsx, tsx}',
46
+ '!app/**/loadable.{js, ts, jsx, tsx}',
47
+ '!lib/**/loadable.{js, ts, jsx, tsx}',
47
48
  ],
48
49
  coverageThreshold: {
49
50
  // Todo: enable the coverage threshold later
@@ -66,17 +67,35 @@ const jestConfig = {
66
67
  '@elliemae/pui-user-monitoring': `${getRootDir()}/lib/testing/mocks/pui-user-monitoring.js`,
67
68
  '@elliemae/pui-app-loader': `${getRootDir()}/lib/testing/mocks/pui-app-loader.js`,
68
69
  '@elliemae/pui-diagnostics': `${getRootDir()}/lib/testing/mocks/pui-diagnostics.js`,
70
+ 'react-spring/web': '<rootDir>/node_modules/react-spring/web.cjs.js',
71
+ 'react-spring/renderprops':
72
+ '<rootDir>/node_modules/react-spring/renderprops.cjs.js',
69
73
  'styled-components':
70
74
  '<rootDir>/node_modules/styled-components/dist/styled-components.cjs.js',
71
75
  },
76
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
72
77
  setupFilesAfterEnv: [`${getRootDir()}/lib/testing/setup-tests.js`],
73
78
  setupFiles: ['raf/polyfill', 'whatwg-fetch'],
74
- testRegex: '(app|lib).*/tests/.*\\.test\\.(js|ts)$',
79
+ testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
75
80
  snapshotSerializers: [],
76
81
  testResultsProcessor: 'jest-sonar-reporter',
82
+ resolver: path.resolve(__dirname, './resolver.js'),
83
+ transform: {
84
+ '^.+\\.[jt]sx?$': ['@swc/jest', swcrcConfig],
85
+ },
86
+ // transform: {
87
+ // '^.+\\.[jt]sx?$': [
88
+ // 'esbuild-jest',
89
+ // {
90
+ // target: 'es2020',
91
+ // loaders: {
92
+ // '.js': 'jsx',
93
+ // },
94
+ // },
95
+ // ],
96
+ // },
77
97
  transformIgnorePatterns: [
78
- 'node_modules/(?!(@elliemae/*|lodash-es/*)/)',
79
- 'node_modules/@elliemae/em-platform-document-viewer',
98
+ 'node_modules/(?!(@elliemae/pui-cli|lodash-es|react-select|react-dates)/)',
80
99
  ],
81
100
  globals: {
82
101
  APP_CONFIG: getAppConfig(),
@@ -86,8 +105,8 @@ const jestConfig = {
86
105
  testEnvironment: 'jsdom',
87
106
  };
88
107
 
89
- if (isReactModule)
108
+ if (isReactModule && jestConfig.setupFilesAfterEnv)
90
109
  jestConfig.setupFilesAfterEnv.push(
91
- `${getRootDir()}/lib/testing/setup-styled-components-tests.js`,
110
+ `${getRootDir()}/lib/testing/setup-react-env.js`,
92
111
  );
93
112
  module.exports = jestConfig;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
3
  */
4
- export default function () {
4
+ export default () => {
5
5
  Object.defineProperty(window, 'matchMedia', {
6
6
  value: () => ({
7
7
  matches: false,
@@ -15,4 +15,4 @@ export default function () {
15
15
  getPropertyValue: () => {},
16
16
  }),
17
17
  });
18
- }
18
+ };
@@ -1,3 +1 @@
1
- module.exports = {
2
- load: () => {},
3
- };
1
+ export const load = () => {};
@@ -1,36 +1,28 @@
1
- module.exports = {
2
- logger() {
3
- return {
4
- setLogLevel() {},
5
- setOptions() {},
6
- info() {},
7
- warn() {},
8
- error() {},
9
- trace() {},
10
- debug() {},
11
- audit() {},
12
- fatal() {},
13
- };
14
- },
15
- LogLevel: {
16
- info: 'info',
17
- debug: 'debug',
18
- trace: 'trace',
19
- warn: 'warn',
20
- error: 'error',
21
- audit: 'audit',
22
- fatal: 'fatal',
23
- },
24
- Console() {
25
- return {
26
- log() {},
27
- };
28
- },
29
- http() {
30
- return {
31
- log() {},
32
- };
33
- },
34
- webvitals() {},
35
- logUnhandledErrors() {},
1
+ export const logger = () => ({
2
+ setLogLevel() {},
3
+ setOptions() {},
4
+ info() {},
5
+ warn() {},
6
+ error() {},
7
+ trace() {},
8
+ debug() {},
9
+ audit() {},
10
+ fatal() {},
11
+ });
12
+ export const LogLevel = {
13
+ info: 'info',
14
+ debug: 'debug',
15
+ trace: 'trace',
16
+ warn: 'warn',
17
+ error: 'error',
18
+ audit: 'audit',
19
+ fatal: 'fatal',
36
20
  };
21
+ export const Console = () => ({
22
+ log: () => {},
23
+ });
24
+ export const http = () => ({
25
+ log() {},
26
+ });
27
+ export const webvitals = () => {};
28
+ export const logUnhandledErrors = () => {};
@@ -1,5 +1,3 @@
1
- module.exports = {
2
- setCustomUserData: () => {},
3
- setCustomVirtualPageName: () => {},
4
- startVirtualPageMonitoringWithAutoEnd: () => {},
5
- };
1
+ export const setCustomUserData = () => {};
2
+ export const setCustomVirtualPageName = () => {};
3
+ export const startVirtualPageMonitoringWithAutoEnd = () => {};
@@ -1,5 +1,3 @@
1
- module.exports = {
2
- attach: jest.fn(),
3
- detach: jest.fn(),
4
- getConfig: jest.fn(),
5
- };
1
+ export const attach = jest.fn();
2
+ export const detach = jest.fn();
3
+ export const getConfig = jest.fn();
@@ -1,3 +1,5 @@
1
- module.exports = {
2
- ReactComponent: 'IMAGE_MOCK',
3
- };
1
+ // eslint-disable-next-line no-unused-vars
2
+ import * as React from 'react';
3
+
4
+ export default 'SvgrURL';
5
+ export const ReactComponent = 'div';
@@ -0,0 +1,47 @@
1
+ const resolutions = [
2
+ {
3
+ matcher: /\.jsx?$/i,
4
+ extensions: ['.tsx', '.ts'],
5
+ },
6
+ {
7
+ matcher: /\.mjs$/i,
8
+ extensions: ['.mts'],
9
+ },
10
+ {
11
+ matcher: /\.cjs$/i,
12
+ extensions: ['.cts'],
13
+ },
14
+ ];
15
+
16
+ const resolveConfig = {
17
+ conditionNames: ['import', 'node', 'default'],
18
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.node'],
19
+ modules: ['node_modules', 'app', 'lib'],
20
+ };
21
+
22
+ const importResolver = require('enhanced-resolve').create.sync(resolveConfig);
23
+ const requireResolver = require('enhanced-resolve').create.sync({
24
+ ...resolveConfig,
25
+ conditionNames: ['require', 'node', 'default'],
26
+ });
27
+
28
+ module.exports = (request, options) => {
29
+ let resolver = requireResolver;
30
+ if (options.conditions?.includes('import')) {
31
+ resolver = importResolver;
32
+ }
33
+ const resolution = resolutions.find(({ matcher }) => matcher.test(request));
34
+ if (resolution) {
35
+ // eslint-disable-next-line no-restricted-syntax
36
+ for (const extension of resolution.extensions) {
37
+ try {
38
+ return resolver(
39
+ options.basedir,
40
+ request.replace(resolution.matcher, extension),
41
+ );
42
+ // eslint-disable-next-line no-empty
43
+ } catch {}
44
+ }
45
+ }
46
+ return resolver(options.basedir, request);
47
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import 'jest-styled-components';
3
+ global.React = React;
@@ -3,12 +3,35 @@
3
3
  import 'core-js/stable';
4
4
  import 'regenerator-runtime/runtime';
5
5
  import '@testing-library/jest-dom/extend-expect';
6
- import { toHaveNoViolations } from 'jest-axe';
6
+ import jestAxe from 'jest-axe';
7
7
  import ResizeObserver from 'resize-observer-polyfill';
8
- import addMatchMedia from './mocks/matchMedia';
9
- import { logger } from './mocks/pui-diagnostics';
8
+ import addMatchMedia from './mocks/matchMedia.js';
9
+ import { logger } from './mocks/pui-diagnostics.js';
10
10
 
11
- if (expect) expect.extend(toHaveNoViolations);
11
+ // eslint-disable-next-line no-console
12
+ const originalError = console.error;
13
+ // eslint-disable-next-line no-console
14
+ console.error = (...args) => {
15
+ const ignoreList = [
16
+ `Warning: Can't perform a React state update on an unmounted component`,
17
+ `Warning: Function components cannot be given refs`,
18
+ `Warning: Failed %s type:`,
19
+ `Warning: Invalid DOM property`,
20
+ `Warning: Each child in a list should have a unique`,
21
+ 'Warning: Received `%s` for a non-boolean attribute',
22
+ 'Warning: <%s /> is using incorrect casing.',
23
+ 'Warning: The tag <%s> is unrecognized in this browser',
24
+ ];
25
+ if (
26
+ ignoreList.find(
27
+ (ignoreMsg) => !!args.find((arg) => arg.includes?.(ignoreMsg)),
28
+ )
29
+ )
30
+ return false;
31
+ return originalError(...args);
32
+ };
33
+
34
+ if (expect) expect.extend(jestAxe.toHaveNoViolations);
12
35
  jest.setTimeout(60000);
13
36
 
14
37
  const addElementToBody = (element) => {
@@ -0,0 +1,11 @@
1
+ {
2
+ "jsc": {
3
+ "parser": {
4
+ "syntax": "typescript",
5
+ "jsx": true,
6
+ "tsx": true,
7
+ "dynamicImport": true
8
+ },
9
+ "target": "es2020"
10
+ }
11
+ }
@@ -0,0 +1,62 @@
1
+ const esbuild = require('esbuild');
2
+ const fg = require('fast-glob');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { getPUIConfig } = require('../pui-config');
6
+
7
+ const { esBuild } = getPUIConfig();
8
+
9
+ const commonConfig = {
10
+ bundle: false,
11
+ target: esBuild.target,
12
+ loader: { '.js': 'jsx' },
13
+ mainFields: ['module', 'browser', 'main'],
14
+ inject: [path.resolve(__dirname, './react-shim.js')],
15
+ };
16
+
17
+ const distFolder = 'dist';
18
+
19
+ const copyFiles = async ({ srcdir, outdir }) => {
20
+ const files = await fg([
21
+ `${srcdir}/**/*.*`,
22
+ `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
23
+ ]);
24
+ files.forEach((srcFilePath) => {
25
+ const destFilePath = srcFilePath.replace(srcdir, outdir);
26
+ fs.copyFileSync(srcFilePath, destFilePath);
27
+ });
28
+ };
29
+
30
+ const build = async ({ srcPath, commonJS }) => {
31
+ const inputFiles = [
32
+ `${srcPath}/**/*.{js,jsx,ts,tsx}`,
33
+ `!${srcPath}/**/*.test.{js,jsx,ts,tsx}`,
34
+ `!${srcPath}/**/*.stories.{js,jsx,ts,tsx}`,
35
+ `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
36
+ ];
37
+ if (commonJS) {
38
+ const outdir = `${distFolder}/cjs`;
39
+ const commonJSEntryPoints = await fg(inputFiles);
40
+ await esbuild.build({
41
+ entryPoints: commonJSEntryPoints,
42
+ ...commonConfig,
43
+ outdir,
44
+ format: 'cjs',
45
+ });
46
+ await copyFiles({ srcdir: srcPath, outdir });
47
+ } else {
48
+ const outdir = `${distFolder}/es`;
49
+ const entryPoints = await fg(
50
+ inputFiles.concat([`!${srcPath}/**/cjs/**/*.{js,jsx,ts,tsx}`]),
51
+ );
52
+ await esbuild.build({
53
+ entryPoints,
54
+ ...commonConfig,
55
+ outdir,
56
+ format: 'esm',
57
+ });
58
+ await copyFiles({ srcdir: srcPath, outdir });
59
+ }
60
+ };
61
+
62
+ exports.esBuild = build;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export { React };
@@ -0,0 +1,13 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { merge } = require('lodash');
4
+
5
+ let projectConfig = {};
6
+ const projectPath = path.join(process.cwd(), '.swcrc');
7
+ if (fs.existsSync(projectPath)) {
8
+ projectConfig = JSON.parse(fs.readFileSync(projectPath, 'utf-8'));
9
+ }
10
+ const localConfig = JSON.parse(
11
+ fs.readFileSync(path.join(__dirname, '.swcrc'), 'utf-8'),
12
+ );
13
+ module.exports = merge(localConfig, projectConfig);
@@ -1,6 +1,9 @@
1
+ /* eslint-disable max-lines */
1
2
  const path = require('path');
2
3
  const fs = require('fs');
3
4
  const _ = require('lodash');
5
+ const CompressionPlugin = require('compression-webpack-plugin');
6
+ const zlib = require('zlib');
4
7
 
5
8
  let pathSep = path.sep;
6
9
  if (pathSep === '\\')
@@ -69,13 +72,11 @@ const getAlias = () =>
69
72
  '@babel/runtime',
70
73
  'react',
71
74
  'react-dom',
72
- 'react-router-dom',
73
75
  'react-redux',
74
76
  'redux',
75
77
  'redux-saga',
76
78
  'moment',
77
79
  'lodash',
78
- 'connected-react-router',
79
80
  'styled-components',
80
81
  'immer',
81
82
  'react-dates',
@@ -122,7 +123,6 @@ const getAppLoaderFileName = () => {
122
123
 
123
124
  const getDiagnosticsFileName = () => {
124
125
  const libName = 'emuiDiagnostics';
125
- // eslint-disable-next-line max-lines
126
126
  const libPath = path.join(
127
127
  process.cwd(),
128
128
  'node_modules/@elliemae/pui-diagnostics/dist/public/js',
@@ -185,6 +185,39 @@ const isGoogleTagManagerEnabled = () => {
185
185
  return !!appConfig?.googleTagManager;
186
186
  };
187
187
 
188
+ const getCompressionPlugins = (isLibrary = false) => {
189
+ const excludeList = [
190
+ /\/adrum-ext/,
191
+ /\/emuiUserMonitoring/,
192
+ /\/emuiDiagnostics/,
193
+ /\/emuiAppLoader/,
194
+ /\/encwLoader/,
195
+ ];
196
+ const commonConfig = {
197
+ test: /\.(js|css)$/,
198
+ exclude: !isLibrary ? excludeList : [],
199
+ // we are compressing all files since in aws cloudfront edge lambda, we don't want to whitelist files that are not compressed due to below limits
200
+ minRatio: Number.MAX_SAFE_INTEGER,
201
+ };
202
+ return [
203
+ new CompressionPlugin({
204
+ filename: '[path][base].gz',
205
+ algorithm: 'gzip',
206
+ ...commonConfig,
207
+ }),
208
+ new CompressionPlugin({
209
+ filename: '[path][base].br',
210
+ algorithm: 'brotliCompress',
211
+ ...commonConfig,
212
+ compressionOptions: {
213
+ params: {
214
+ [zlib.constants.BROTLI_PARAM_QUALITY]: 11,
215
+ },
216
+ },
217
+ }),
218
+ ];
219
+ };
220
+
188
221
  exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
189
222
  exports.getLibraryName = getLibraryName;
190
223
  exports.getAppConfig = getAppConfig;
@@ -209,4 +242,4 @@ exports.resolveExtensions = [
209
242
  ];
210
243
  exports.mainFields = ['browser', 'module', 'main'];
211
244
  exports.isGoogleTagManagerEnabled = isGoogleTagManagerEnabled;
212
- exports.ESBUILD_TARGET = 'es2020';
245
+ exports.getCompressionPlugins = getCompressionPlugins;