@elliemae/pui-cli 6.0.0-beta.11 → 6.0.0-beta.15

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.
package/lib/esbuild.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const esbuild = require('esbuild');
2
2
  const fg = require('fast-glob');
3
+ const fs = require('fs');
3
4
 
4
5
  const ESBUILD_TARGET = 'es2020';
5
6
 
@@ -10,7 +11,18 @@ const commonConfig = {
10
11
  mainFields: ['module', 'browser', 'main'],
11
12
  };
12
13
 
13
- const outDir = 'dist';
14
+ const distFolder = 'dist';
15
+
16
+ const copyFiles = async ({ srcdir, outdir }) => {
17
+ const files = await fg([
18
+ `${srcdir}/**/*.*`,
19
+ `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
20
+ ]);
21
+ files.forEach((srcFilePath) => {
22
+ const destFilePath = srcFilePath.replace(srcdir, outdir);
23
+ fs.copyFileSync(srcFilePath, destFilePath);
24
+ });
25
+ };
14
26
 
15
27
  const build = async ({ srcPath, commonJS }) => {
16
28
  const inputFiles = [
@@ -20,23 +32,27 @@ const build = async ({ srcPath, commonJS }) => {
20
32
  `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
21
33
  ];
22
34
  if (!commonJS) {
35
+ const outdir = `${distFolder}/es`;
23
36
  const entryPoints = await fg(inputFiles);
24
37
  await esbuild.build({
25
38
  entryPoints,
26
39
  ...commonConfig,
27
- outdir: `${outDir}/es`,
40
+ outdir,
28
41
  format: 'esm',
29
42
  });
43
+ await copyFiles({ srcdir: srcPath, outdir });
30
44
  } else {
45
+ const outdir = `${distFolder}/cjs`;
31
46
  const commonJSEntryPoints = await fg(
32
47
  inputFiles.concat([`${srcPath}/**/*.cjs`]),
33
48
  );
34
49
  await esbuild.build({
35
50
  entryPoints: commonJSEntryPoints,
36
51
  ...commonConfig,
37
- outdir: `${outDir}/cjs`,
52
+ outdir,
38
53
  format: 'cjs',
39
54
  });
55
+ await copyFiles({ srcdir: srcPath, outdir });
40
56
  }
41
57
  };
42
58
 
@@ -60,12 +60,20 @@ const customHost = argv.host || process.env.HOST;
60
60
  const host = customHost || null; // Let http.Server use its default IPv6/4 host
61
61
  const prettyHost = customHost || 'localhost';
62
62
 
63
- // use the gzipped bundle
64
- app.get('*.js', (req, res, next) => {
65
- req.url += '.gz';
66
- res.set('Content-Encoding', 'gzip');
63
+ const serveCompressedAssets = (req, res, next) => {
64
+ if (req.header('Accept-Encoding').includes('br')) {
65
+ req.url += '.br';
66
+ res.set('Content-Encoding', 'br');
67
+ } else {
68
+ req.url += '.gz';
69
+ res.set('Content-Encoding', 'gzip');
70
+ }
67
71
  next();
68
- });
72
+ };
73
+
74
+ // use the compressed bundle
75
+ app.get('*.js', serveCompressedAssets);
76
+ app.get('*.css', serveCompressedAssets);
69
77
 
70
78
  // Start your app.
71
79
  app.listen(port, host, async (err) => {
@@ -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,7 +72,6 @@ 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',
@@ -122,7 +124,6 @@ const getAppLoaderFileName = () => {
122
124
 
123
125
  const getDiagnosticsFileName = () => {
124
126
  const libName = 'emuiDiagnostics';
125
- // eslint-disable-next-line max-lines
126
127
  const libPath = path.join(
127
128
  process.cwd(),
128
129
  'node_modules/@elliemae/pui-diagnostics/dist/public/js',
@@ -185,6 +186,38 @@ const isGoogleTagManagerEnabled = () => {
185
186
  return !!appConfig?.googleTagManager;
186
187
  };
187
188
 
189
+ const getCompressionPlugins = () => {
190
+ const commonConfig = {
191
+ test: /\.(js|css|html|svg)$/,
192
+ exclude: [
193
+ /\/adrum-ext/,
194
+ /\/emuiUserMonitoring/,
195
+ /\/emuiDiagnostics/,
196
+ /\/emuiAppLoader/,
197
+ /\/encwLoader/,
198
+ ],
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,3 +242,4 @@ exports.resolveExtensions = [
209
242
  ];
210
243
  exports.mainFields = ['browser', 'module', 'main'];
211
244
  exports.isGoogleTagManagerEnabled = isGoogleTagManagerEnabled;
245
+ exports.getCompressionPlugins = getCompressionPlugins;
@@ -1,10 +1,9 @@
1
1
  const path = require('path');
2
- const CompressionPlugin = require('compression-webpack-plugin');
3
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
5
4
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6
5
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
7
- const { getLibraryName } = require('./helpers');
6
+ const { getLibraryName, getCompressionPlugins } = require('./helpers');
8
7
  const { ESBUILD_TARGET } = require('../esbuild');
9
8
 
10
9
  const libraryName = getLibraryName();
@@ -62,13 +61,7 @@ module.exports = require('./webpack.lib.base.babel')({
62
61
  chunkFilename: `css/${libraryName}.[contenthash].chunk.css`,
63
62
  }),
64
63
 
65
- new CompressionPlugin({
66
- filename: '[path][base].gz',
67
- algorithm: 'gzip',
68
- test: /\.js$|\.css$$/,
69
- // 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
70
- minRatio: Number.MAX_SAFE_INTEGER,
71
- }),
64
+ ...getCompressionPlugins(),
72
65
 
73
66
  new BundleAnalyzerPlugin({
74
67
  analyzerMode: 'static',
@@ -2,7 +2,6 @@
2
2
  const path = require('path');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
4
  const { GenerateSW } = require('workbox-webpack-plugin');
5
- const CompressionPlugin = require('compression-webpack-plugin');
6
5
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
6
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
8
7
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
@@ -15,6 +14,7 @@ const {
15
14
  getPaths,
16
15
  getAppVersion,
17
16
  isGoogleTagManagerEnabled,
17
+ getCompressionPlugins,
18
18
  } = require('./helpers');
19
19
  const { ESBUILD_TARGET } = require('../esbuild');
20
20
 
@@ -68,20 +68,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
68
68
  chunkFilename: 'css/[name].[contenthash].chunk.css',
69
69
  }),
70
70
 
71
- new CompressionPlugin({
72
- filename: '[path][base].gz',
73
- algorithm: 'gzip',
74
- test: /\.js$|\.css$$/,
75
- exclude: [
76
- /\/adrum-ext/,
77
- /\/emuiUserMonitoring/,
78
- /\/emuiDiagnostics/,
79
- /\/emuiAppLoader/,
80
- /\/encwLoader/,
81
- ],
82
- // 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
83
- minRatio: Number.MAX_SAFE_INTEGER,
84
- }),
71
+ ...getCompressionPlugins(),
85
72
 
86
73
  new BundleAnalyzerPlugin({
87
74
  analyzerMode: 'static',
@@ -1,16 +1,12 @@
1
- /* eslint-disable max-lines */
2
1
  const webpack = require('webpack');
3
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
3
  const CopyWebpackPlugin = require('copy-webpack-plugin');
5
- const CompressionPlugin = require('compression-webpack-plugin');
6
4
  const {
7
5
  getAppConfig,
8
6
  isApp,
9
7
  getAlias,
10
- excludeNodeModulesExcept,
11
- modulesToTranspile,
8
+ getCompressionPlugins,
12
9
  } = require('./helpers');
13
- const { ESBUILD_TARGET } = require('../esbuild');
14
10
 
15
11
  const IS_APP = isApp();
16
12
  const CWD = process.cwd();
@@ -47,30 +43,7 @@ const getAdditionalPlugins = () => [
47
43
  }),
48
44
  ];
49
45
 
50
- const compressionPlugin = new CompressionPlugin({
51
- filename: '[path][base].gz',
52
- algorithm: 'gzip',
53
- test: /\.js$|\.css$$/,
54
- // 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
55
- minRatio: Number.MAX_SAFE_INTEGER,
56
- });
57
-
58
46
  const getModulePreRules = () => [
59
- {
60
- test: /\.(jpe?g|png|gif|svg|ico)$/,
61
- use: [
62
- 'file-loader',
63
- {
64
- loader: 'image-webpack-loader',
65
- options: {
66
- gifsicle: {
67
- enabled: false,
68
- },
69
- },
70
- },
71
- ],
72
- enforce: 'pre',
73
- },
74
47
  {
75
48
  test: /\.(js|ts|jsx|tsx)$/,
76
49
  enforce: 'pre',
@@ -90,59 +63,12 @@ const getModulePreRules = () => [
90
63
  },
91
64
  ];
92
65
 
93
- const getModuleRules = () => [
94
- {
95
- test: /\.(js|ts|jsx|tsx)$/,
96
- exclude: excludeNodeModulesExcept(modulesToTranspile),
97
- resolve: {
98
- fullySpecified: false,
99
- },
100
- use: {
101
- loader: 'esbuild-loader',
102
- options: {
103
- loader: 'jsx',
104
- target: ESBUILD_TARGET,
105
- },
106
- },
107
- },
108
- {
109
- test: /\.(woff|woff2)$/,
110
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
111
- type: 'asset/resource',
112
- },
113
- {
114
- type: 'asset',
115
- resourceQuery: /url/, // *.svg?react
116
- },
117
- {
118
- test: /\.svg$/i,
119
- issuer: /\.[jt]sx?$/,
120
- use: ['@svgr/webpack'],
121
- },
122
- {
123
- test: /\.(jpe?g|png|gif|ico)$/i,
124
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
125
- type: 'asset',
126
- },
127
- {
128
- test: /\.(mp4|webm)$/,
129
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
130
- type: 'asset',
131
- },
132
- ];
133
-
134
66
  exports.webpackFinal = async (config, { configType }) => {
135
67
  const isProd = configType === 'PRODUCTION';
136
- // remove asset processing that comes with storybook webpack, we will use ours
137
- config.module.rules = config.module.rules.filter(
138
- ({ type }) => type !== 'asset/resource',
139
- );
140
68
  config.module.rules.push(...getModulePreRules());
141
- config.module.rules.unshift(...getModuleRules(isProd));
142
-
143
69
  config.plugins.push(...getAdditionalPlugins());
144
70
  if (isProd) {
145
- config.plugins.push(compressionPlugin);
71
+ config.plugins = config.plugins.concat(getCompressionPlugins());
146
72
  }
147
73
 
148
74
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
@@ -157,7 +83,7 @@ exports.webpackFinal = async (config, { configType }) => {
157
83
 
158
84
  // storybook manager webpack
159
85
  exports.managerWebpack = async (config) => {
160
- config.plugins.push(compressionPlugin);
86
+ config.plugins = config.plugins.concat(getCompressionPlugins());
161
87
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
162
88
  return config;
163
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.11",
3
+ "version": "6.0.0-beta.15",
4
4
  "private": false,
5
5
  "description": "EllieMae Platform UI CLI",
6
6
  "sideEffects": false,
@@ -70,30 +70,25 @@
70
70
  "@semantic-release/changelog": "~6.0.1",
71
71
  "@semantic-release/exec": "~6.0.2",
72
72
  "@semantic-release/git": "~10.0.1",
73
- "@storybook/addon-a11y": "~6.4.1",
74
- "@storybook/addon-actions": "~6.4.1",
75
- "@storybook/addon-backgrounds": "~6.4.1",
76
- "@storybook/addon-controls": "~6.4.1",
77
- "@storybook/addon-docs": "~6.4.1",
73
+ "@storybook/addon-a11y": "~6.4.4",
74
+ "@storybook/addon-essentials": "~6.4.4",
78
75
  "@storybook/addon-events": "~6.2.9",
79
- "@storybook/addon-links": "~6.4.1",
80
- "@storybook/addon-storysource": "~6.4.1",
81
- "@storybook/addon-toolbars": "~6.4.1",
82
- "@storybook/addon-viewport": "~6.4.1",
83
- "@storybook/addons": "~6.4.1",
84
- "@storybook/builder-webpack5": "~6.4.1",
85
- "@storybook/manager-webpack5": "~6.4.1",
86
- "@storybook/react": "~6.4.1",
87
- "@storybook/theming": "~6.4.1",
76
+ "@storybook/addon-interactions": "~6.4.4",
77
+ "@storybook/addon-links": "~6.4.4",
78
+ "@storybook/addon-storysource": "~6.4.4",
79
+ "@storybook/builder-webpack5": "~6.4.4",
80
+ "@storybook/manager-webpack5": "~6.4.4",
81
+ "@storybook/react": "~6.4.4",
82
+ "@storybook/theming": "~6.4.4",
88
83
  "@stylelint/postcss-css-in-js": "~0.37.2",
89
- "@svgr/webpack": "~6.0.0",
84
+ "@svgr/webpack": "~6.1.0",
90
85
  "@testing-library/jest-dom": "~5.15.1",
91
86
  "@testing-library/react": "~12.1.2",
92
87
  "@testing-library/react-hooks": "~7.0.2",
93
88
  "@types/jest": "~27.0.3",
94
89
  "@types/node": "~16.11.11",
95
90
  "@types/rimraf": "~3.0.2",
96
- "@types/testing-library__jest-dom": "~5.14.1",
91
+ "@types/testing-library__jest-dom": "~5.14.2",
97
92
  "@typescript-eslint/eslint-plugin": "~5.5.0",
98
93
  "@typescript-eslint/parser": "~5.5.0",
99
94
  "autoprefixer": "~10.4.0",
@@ -146,15 +141,15 @@
146
141
  "eslint-plugin-eslint-comments": "~3.2.0",
147
142
  "eslint-plugin-import": "~2.25.3",
148
143
  "eslint-plugin-jest": "~25.3.0",
149
- "eslint-plugin-jsdoc": "~37.0.3",
144
+ "eslint-plugin-jsdoc": "~37.1.0",
150
145
  "eslint-plugin-jsx-a11y": "~6.5.1",
151
146
  "eslint-plugin-mdx": "~1.16.0",
152
147
  "eslint-plugin-prettier": "~4.0.0",
153
148
  "eslint-plugin-react": "~7.27.1",
154
149
  "eslint-plugin-react-hooks": "~4.3.0",
155
150
  "eslint-plugin-redux-saga": "~1.2.1",
156
- "eslint-plugin-storybook": "~0.5.1",
157
- "eslint-plugin-testing-library": "~5.0.0",
151
+ "eslint-plugin-storybook": "~0.5.2",
152
+ "eslint-plugin-testing-library": "~5.0.1",
158
153
  "eslint-plugin-wdio": "~7.4.2",
159
154
  "execa": "~5.1.1",
160
155
  "express": "~4.17.1",
@@ -171,7 +166,7 @@
171
166
  "imports-loader": "~3.1.1",
172
167
  "ip": "~1.1.5",
173
168
  "jest-axe": "~5.0.1",
174
- "jest-cli": "~27.4.2",
169
+ "jest-cli": "~27.4.3",
175
170
  "jest-sonar-reporter": "~2.0.0",
176
171
  "jest-styled-components": "~7.0.8",
177
172
  "jscodeshift": "~0.13.0",
@@ -186,7 +181,7 @@
186
181
  "nodemon": "~2.0.15",
187
182
  "npm-check-updates": "12.0.2",
188
183
  "null-loader": "~4.0.1",
189
- "pino": "~7.5.0",
184
+ "pino": "~7.5.1",
190
185
  "pino-pretty": "~7.2.0",
191
186
  "pinst": "~2.1.6",
192
187
  "plop": "~3.0.1",
@@ -225,11 +220,11 @@
225
220
  "svgo": "~2.8.0",
226
221
  "terser-webpack-plugin": "~5.2.5",
227
222
  "ts-node": "~10.4.0",
228
- "tsc-alias": "~1.4.1",
223
+ "tsc-alias": "~1.4.2",
229
224
  "tsc-files": "~1.1.3",
230
225
  "tsconfig-paths": "~3.12.0",
231
226
  "tsconfig-paths-webpack-plugin": "~3.5.2",
232
- "type-fest": "~2.6.0",
227
+ "type-fest": "~2.8.0",
233
228
  "typescript": "~4.5.2",
234
229
  "update-notifier": "~5.1.0",
235
230
  "url-loader": "~4.1.1",
@@ -246,7 +241,7 @@
246
241
  "webpack-strip-block": "~0.3.0",
247
242
  "whatwg-fetch": "~3.6.2",
248
243
  "workbox-webpack-plugin": "~6.4.1",
249
- "yargs": "~17.2.1"
244
+ "yargs": "~17.3.0"
250
245
  },
251
246
  "devDependencies": {
252
247
  "redux": "~4.1.2",