@elliemae/pui-cli 6.0.0-beta.12 → 6.0.0-beta.16

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,7 @@
1
1
  const esbuild = require('esbuild');
2
2
  const fg = require('fast-glob');
3
+ const fs = require('fs');
4
+ const svgrPlugin = require('esbuild-plugin-svgr');
3
5
 
4
6
  const ESBUILD_TARGET = 'es2020';
5
7
 
@@ -8,9 +10,21 @@ const commonConfig = {
8
10
  target: ESBUILD_TARGET,
9
11
  loader: { '.js': 'jsx' },
10
12
  mainFields: ['module', 'browser', 'main'],
13
+ plugins: [svgrPlugin()],
11
14
  };
12
15
 
13
- const outDir = 'dist';
16
+ const distFolder = 'dist';
17
+
18
+ const copyFiles = async ({ srcdir, outdir }) => {
19
+ const files = await fg([
20
+ `${srcdir}/**/*.*`,
21
+ `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
22
+ ]);
23
+ files.forEach((srcFilePath) => {
24
+ const destFilePath = srcFilePath.replace(srcdir, outdir);
25
+ fs.copyFileSync(srcFilePath, destFilePath);
26
+ });
27
+ };
14
28
 
15
29
  const build = async ({ srcPath, commonJS }) => {
16
30
  const inputFiles = [
@@ -20,23 +34,27 @@ const build = async ({ srcPath, commonJS }) => {
20
34
  `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
21
35
  ];
22
36
  if (!commonJS) {
37
+ const outdir = `${distFolder}/es`;
23
38
  const entryPoints = await fg(inputFiles);
24
39
  await esbuild.build({
25
40
  entryPoints,
26
41
  ...commonConfig,
27
- outdir: `${outDir}/es`,
42
+ outdir,
28
43
  format: 'esm',
29
44
  });
45
+ await copyFiles({ srcdir: srcPath, outdir });
30
46
  } else {
47
+ const outdir = `${distFolder}/cjs`;
31
48
  const commonJSEntryPoints = await fg(
32
49
  inputFiles.concat([`${srcPath}/**/*.cjs`]),
33
50
  );
34
51
  await esbuild.build({
35
52
  entryPoints: commonJSEntryPoints,
36
53
  ...commonConfig,
37
- outdir: `${outDir}/cjs`,
54
+ outdir,
38
55
  format: 'cjs',
39
56
  });
57
+ await copyFiles({ srcdir: srcPath, outdir });
40
58
  }
41
59
  };
42
60
 
@@ -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,13 +1,11 @@
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,
8
+ getCompressionPlugins,
11
9
  } = require('./helpers');
12
10
 
13
11
  const IS_APP = isApp();
@@ -45,30 +43,7 @@ const getAdditionalPlugins = () => [
45
43
  }),
46
44
  ];
47
45
 
48
- const compressionPlugin = new CompressionPlugin({
49
- filename: '[path][base].gz',
50
- algorithm: 'gzip',
51
- test: /\.js$|\.css$$/,
52
- // 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
53
- minRatio: Number.MAX_SAFE_INTEGER,
54
- });
55
-
56
- const getModulePreRules = () => [
57
- {
58
- test: /\.(jpe?g|png|gif|svg|ico)$/,
59
- use: [
60
- 'file-loader',
61
- {
62
- loader: 'image-webpack-loader',
63
- options: {
64
- gifsicle: {
65
- enabled: false,
66
- },
67
- },
68
- },
69
- ],
70
- enforce: 'pre',
71
- },
46
+ const getModuleRules = () => [
72
47
  {
73
48
  test: /\.(js|ts|jsx|tsx)$/,
74
49
  enforce: 'pre',
@@ -86,14 +61,6 @@ const getModulePreRules = () => [
86
61
  },
87
62
  ],
88
63
  },
89
- ];
90
-
91
- const getModuleRules = () => [
92
- {
93
- test: /\.(woff|woff2)$/,
94
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
95
- type: 'asset/resource',
96
- },
97
64
  {
98
65
  type: 'asset',
99
66
  resourceQuery: /url/, // *.svg?react
@@ -103,35 +70,23 @@ const getModuleRules = () => [
103
70
  issuer: /\.[jt]sx?$/,
104
71
  use: ['@svgr/webpack'],
105
72
  },
106
- {
107
- test: /\.(jpe?g|png|gif|ico)$/i,
108
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
109
- type: 'asset',
110
- },
111
- {
112
- test: /\.(mp4|webm)$/,
113
- exclude: excludeNodeModulesExcept(['@elliemae/*']),
114
- type: 'asset',
115
- },
116
73
  ];
117
74
 
118
75
  exports.webpackFinal = async (config, { configType }) => {
119
76
  const isProd = configType === 'PRODUCTION';
120
- // remove asset processing that comes with storybook webpack, we will use ours
121
- config.module.rules = config.module.rules.filter(
122
- ({ type }) => type !== 'asset/resource',
77
+ const fileLoaderRule = config.module.rules.find((rule) =>
78
+ rule.test?.test?.('.svg'),
123
79
  );
124
- config.module.rules.push(...getModulePreRules());
125
- config.module.rules.unshift(...getModuleRules(isProd));
126
-
80
+ fileLoaderRule.exclude = /\.svg$/i;
81
+ config.module.rules.unshift(...getModuleRules());
127
82
  config.plugins.push(...getAdditionalPlugins());
128
83
  if (isProd) {
129
- config.plugins.push(compressionPlugin);
84
+ config.plugins = config.plugins.concat(getCompressionPlugins());
130
85
  }
131
86
 
132
87
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
133
88
  config.resolve.fallback = { ...config.resolve.fallback, crypto: false };
134
-
89
+ config.resolve.extensions.push('.svg');
135
90
  config.externals = config.externals || {};
136
91
  config.externals['@elliemae/pui-user-monitoring'] = 'emuiUserMonitoring';
137
92
  config.externals['@elliemae/pui-app-loader'] = 'emuiAppLoader';
@@ -141,7 +96,7 @@ exports.webpackFinal = async (config, { configType }) => {
141
96
 
142
97
  // storybook manager webpack
143
98
  exports.managerWebpack = async (config) => {
144
- config.plugins.push(compressionPlugin);
99
+ config.plugins = config.plugins.concat(getCompressionPlugins());
145
100
  config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
146
101
  return config;
147
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.12",
3
+ "version": "6.0.0-beta.16",
4
4
  "private": false,
5
5
  "description": "EllieMae Platform UI CLI",
6
6
  "sideEffects": false,
@@ -70,31 +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-interactions": "~6.4.1",
80
- "@storybook/addon-links": "~6.4.1",
81
- "@storybook/addon-storysource": "~6.4.1",
82
- "@storybook/addon-toolbars": "~6.4.1",
83
- "@storybook/addon-viewport": "~6.4.1",
84
- "@storybook/addons": "~6.4.1",
85
- "@storybook/builder-webpack5": "~6.4.1",
86
- "@storybook/manager-webpack5": "~6.4.1",
87
- "@storybook/react": "~6.4.1",
88
- "@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",
89
83
  "@stylelint/postcss-css-in-js": "~0.37.2",
90
- "@svgr/webpack": "~6.0.0",
84
+ "@svgr/webpack": "~6.1.0",
91
85
  "@testing-library/jest-dom": "~5.15.1",
92
86
  "@testing-library/react": "~12.1.2",
93
87
  "@testing-library/react-hooks": "~7.0.2",
94
88
  "@types/jest": "~27.0.3",
95
89
  "@types/node": "~16.11.11",
96
90
  "@types/rimraf": "~3.0.2",
97
- "@types/testing-library__jest-dom": "~5.14.1",
91
+ "@types/testing-library__jest-dom": "~5.14.2",
98
92
  "@typescript-eslint/eslint-plugin": "~5.5.0",
99
93
  "@typescript-eslint/parser": "~5.5.0",
100
94
  "autoprefixer": "~10.4.0",
@@ -134,6 +128,7 @@
134
128
  "esbuild": "~0.14.1",
135
129
  "esbuild-jest": "~0.5.0",
136
130
  "esbuild-loader": "~2.16.0",
131
+ "esbuild-plugin-svgr": "~0.0.3",
137
132
  "eslint": "~8.3.0",
138
133
  "eslint-config-airbnb": "~18.2.1",
139
134
  "eslint-config-airbnb-base": "~15.0.0",
@@ -147,15 +142,15 @@
147
142
  "eslint-plugin-eslint-comments": "~3.2.0",
148
143
  "eslint-plugin-import": "~2.25.3",
149
144
  "eslint-plugin-jest": "~25.3.0",
150
- "eslint-plugin-jsdoc": "~37.0.3",
145
+ "eslint-plugin-jsdoc": "~37.1.0",
151
146
  "eslint-plugin-jsx-a11y": "~6.5.1",
152
147
  "eslint-plugin-mdx": "~1.16.0",
153
148
  "eslint-plugin-prettier": "~4.0.0",
154
149
  "eslint-plugin-react": "~7.27.1",
155
150
  "eslint-plugin-react-hooks": "~4.3.0",
156
151
  "eslint-plugin-redux-saga": "~1.2.1",
157
- "eslint-plugin-storybook": "~0.5.1",
158
- "eslint-plugin-testing-library": "~5.0.0",
152
+ "eslint-plugin-storybook": "~0.5.2",
153
+ "eslint-plugin-testing-library": "~5.0.1",
159
154
  "eslint-plugin-wdio": "~7.4.2",
160
155
  "execa": "~5.1.1",
161
156
  "express": "~4.17.1",
@@ -172,7 +167,7 @@
172
167
  "imports-loader": "~3.1.1",
173
168
  "ip": "~1.1.5",
174
169
  "jest-axe": "~5.0.1",
175
- "jest-cli": "~27.4.2",
170
+ "jest-cli": "~27.4.3",
176
171
  "jest-sonar-reporter": "~2.0.0",
177
172
  "jest-styled-components": "~7.0.8",
178
173
  "jscodeshift": "~0.13.0",
@@ -187,7 +182,7 @@
187
182
  "nodemon": "~2.0.15",
188
183
  "npm-check-updates": "12.0.2",
189
184
  "null-loader": "~4.0.1",
190
- "pino": "~7.5.0",
185
+ "pino": "~7.5.1",
191
186
  "pino-pretty": "~7.2.0",
192
187
  "pinst": "~2.1.6",
193
188
  "plop": "~3.0.1",
@@ -230,7 +225,7 @@
230
225
  "tsc-files": "~1.1.3",
231
226
  "tsconfig-paths": "~3.12.0",
232
227
  "tsconfig-paths-webpack-plugin": "~3.5.2",
233
- "type-fest": "~2.7.0",
228
+ "type-fest": "~2.8.0",
234
229
  "typescript": "~4.5.2",
235
230
  "update-notifier": "~5.1.0",
236
231
  "url-loader": "~4.1.1",