@elliemae/pui-cli 5.17.3 → 6.0.0-beta.4

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('../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',
package/lib/esbuild.js ADDED
@@ -0,0 +1,39 @@
1
+ const esbuild = require('esbuild');
2
+ const fg = require('fast-glob');
3
+
4
+ const ESBUILD_TARGET = 'es2020';
5
+
6
+ const commonConfig = {
7
+ bundle: false,
8
+ target: ESBUILD_TARGET,
9
+ loader: { '.js': 'jsx' },
10
+ mainFields: ['module', 'browser', 'main'],
11
+ };
12
+
13
+ const outDir = 'dist';
14
+
15
+ const build = async ({ srcPath, commonJS }) => {
16
+ const entryPoints = await fg([
17
+ `${srcPath}/**/*.{js,jsx,ts,tsx}`,
18
+ `!${srcPath}/**/*.test.{js,jsx,ts,tsx}`,
19
+ `!${srcPath}/**/*.stories.{js,jsx,ts,tsx}`,
20
+ ]);
21
+ if (!commonJS) {
22
+ await esbuild.build({
23
+ entryPoints,
24
+ ...commonConfig,
25
+ outdir: `${outDir}/es`,
26
+ format: 'esm',
27
+ });
28
+ } else {
29
+ await esbuild.build({
30
+ entryPoints,
31
+ ...commonConfig,
32
+ outdir: `${outDir}/cjs`,
33
+ format: 'cjs',
34
+ });
35
+ }
36
+ };
37
+
38
+ exports.esBuild = build;
39
+ exports.ESBUILD_TARGET = ESBUILD_TARGET;
@@ -8,6 +8,7 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
8
8
  const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
9
9
  const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
10
10
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
11
+ const { ProvidePlugin } = require('webpack');
11
12
 
12
13
  const {
13
14
  excludeNodeModulesExcept,
@@ -17,6 +18,7 @@ const {
17
18
  getPaths,
18
19
  getMediaPath,
19
20
  } = require('./helpers');
21
+ const { ESBUILD_TARGET } = require('../esbuild');
20
22
  const { isTypeScriptEnabled } = require('../typescript/util');
21
23
 
22
24
  // get the application configuration
@@ -46,6 +48,10 @@ const plugins = [
46
48
  APP_CONFIG: getAppConfig(),
47
49
  }),
48
50
  new CaseSensitivePathsPlugin(),
51
+ // new ESLintPlugin(),
52
+ new ProvidePlugin({
53
+ React: 'react',
54
+ }),
49
55
  new CopyWebpackPlugin({
50
56
  patterns: [
51
57
  {
@@ -153,17 +159,30 @@ module.exports = (options) => ({
153
159
  ],
154
160
  },
155
161
  {
156
- test: /\.(js|ts|jsx|tsx)$/,
162
+ test: /\.(js|jsx)$/,
163
+ exclude: excludeNodeModulesExcept(modulesToTranspile),
164
+ resolve: {
165
+ fullySpecified: false,
166
+ },
167
+ use: {
168
+ loader: 'esbuild-loader',
169
+ options: {
170
+ loader: 'jsx',
171
+ target: ESBUILD_TARGET,
172
+ },
173
+ },
174
+ },
175
+ {
176
+ test: /\.(ts|tsx)$/,
157
177
  exclude: excludeNodeModulesExcept(modulesToTranspile),
158
178
  resolve: {
159
179
  fullySpecified: false,
160
180
  },
161
181
  use: {
162
- loader: 'babel-loader',
182
+ loader: 'esbuild-loader',
163
183
  options: {
164
- cacheDirectory: true,
165
- compact: !devMode,
166
- ...(options.babelQuery || {}),
184
+ loader: 'tsx',
185
+ target: ESBUILD_TARGET,
167
186
  },
168
187
  },
169
188
  },
@@ -178,6 +197,13 @@ module.exports = (options) => ({
178
197
  sourceMap: true,
179
198
  },
180
199
  },
200
+ {
201
+ loader: 'esbuild-loader',
202
+ options: {
203
+ loader: 'css',
204
+ minify: options.mode === 'production',
205
+ },
206
+ },
181
207
  {
182
208
  loader: 'postcss-loader',
183
209
  options: {
@@ -210,7 +236,7 @@ module.exports = (options) => ({
210
236
  ],
211
237
  },
212
238
  {
213
- test: /\.(jpe?g|png|gif)$/i,
239
+ test: /\.(jpe?g|png|gif|ico)$/i,
214
240
  exclude: excludeNodeModulesExcept(['@elliemae/*']),
215
241
  type: 'asset',
216
242
  },
@@ -26,6 +26,14 @@ const {
26
26
  const devConfig = {
27
27
  mode: 'development',
28
28
 
29
+ cache: {
30
+ type: 'filesystem',
31
+ allowCollectingMemory: true,
32
+ buildDependencies: {
33
+ config: [__filename],
34
+ },
35
+ },
36
+
29
37
  // Add hot reloading in development
30
38
  entry: {
31
39
  app: [
@@ -21,6 +21,7 @@ const {
21
21
  getAlias,
22
22
  getMediaPath,
23
23
  } = require('./helpers');
24
+ const { ESBUILD_TARGET } = require('../esbuild');
24
25
  const { isTypeScriptEnabled } = require('../typescript/util');
25
26
 
26
27
  const devMode = process.env.NODE_ENV !== 'production';
@@ -126,11 +127,10 @@ module.exports = (options) => ({
126
127
  fullySpecified: false,
127
128
  },
128
129
  use: {
129
- loader: 'babel-loader',
130
+ loader: 'esbuild-loader',
130
131
  options: {
131
- cacheDirectory: true,
132
- compact: !devMode,
133
- ...(options.babelQuery || {}),
132
+ loader: 'jsx',
133
+ target: ESBUILD_TARGET,
134
134
  },
135
135
  },
136
136
  },
@@ -201,7 +201,7 @@ module.exports = (options) => ({
201
201
  ],
202
202
  },
203
203
  {
204
- test: /\.(jpe?g|png|gif)$/i,
204
+ test: /\.(jpe?g|png|gif|ico)$/i,
205
205
  exclude: excludeNodeModulesExcept(['@elliemae/*']),
206
206
  type: 'asset',
207
207
  },
@@ -1,11 +1,11 @@
1
1
  const path = require('path');
2
- const TerserPlugin = require('terser-webpack-plugin');
3
2
  const CompressionPlugin = require('compression-webpack-plugin');
4
3
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
4
  const HtmlWebpackPlugin = require('html-webpack-plugin');
6
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
7
5
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6
+ const { ESBuildMinifyPlugin } = require('esbuild-loader');
8
7
  const { getLibraryName } = require('./helpers');
8
+ const { ESBUILD_TARGET } = require('../esbuild');
9
9
 
10
10
  const libraryName = getLibraryName();
11
11
 
@@ -23,17 +23,10 @@ module.exports = require('./webpack.lib.base.babel')({
23
23
  moduleIds: 'deterministic',
24
24
  minimize: true,
25
25
  minimizer: [
26
- new TerserPlugin({
27
- terserOptions: {
28
- compress: {
29
- comparisons: false,
30
- },
31
- format: {
32
- comments: false,
33
- },
34
- },
26
+ new ESBuildMinifyPlugin({
27
+ target: ESBUILD_TARGET,
28
+ css: true,
35
29
  }),
36
- new CssMinimizerPlugin(),
37
30
  ],
38
31
  nodeEnv: 'production',
39
32
  sideEffects: true,
@@ -1,11 +1,11 @@
1
+ /* eslint-disable max-lines */
1
2
  const path = require('path');
2
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
3
4
  const { GenerateSW } = require('workbox-webpack-plugin');
4
- const TerserPlugin = require('terser-webpack-plugin');
5
5
  const CompressionPlugin = require('compression-webpack-plugin');
6
6
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
8
7
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
8
+ const { ESBuildMinifyPlugin } = require('esbuild-loader');
9
9
 
10
10
  const baseConfigFactory = require('./webpack.base.babel');
11
11
  const {
@@ -16,6 +16,7 @@ const {
16
16
  getAppVersion,
17
17
  isGoogleTagManagerEnabled,
18
18
  } = require('./helpers');
19
+ const { ESBUILD_TARGET } = require('../esbuild');
19
20
 
20
21
  const getProdConfig = ({ latestVersion = true } = {}) => {
21
22
  const { buildPath, publicPath } = getPaths(latestVersion);
@@ -39,17 +40,10 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
39
40
  optimization: {
40
41
  moduleIds: 'deterministic',
41
42
  minimizer: [
42
- new TerserPlugin({
43
- terserOptions: {
44
- compress: {
45
- comparisons: false,
46
- },
47
- format: {
48
- comments: false,
49
- },
50
- },
43
+ new ESBuildMinifyPlugin({
44
+ target: ESBUILD_TARGET,
45
+ css: true,
51
46
  }),
52
- new CssMinimizerPlugin(),
53
47
  ],
54
48
  runtimeChunk: true,
55
49
  splitChunks: {
@@ -120,7 +114,6 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
120
114
  ? 'app/index.html'
121
115
  : 'app/index-app-loader.html',
122
116
  minify: {
123
- // eslint-disable-next-line max-lines
124
117
  removeComments: true,
125
118
  collapseWhitespace: true,
126
119
  removeRedundantAttributes: true,
@@ -14,6 +14,7 @@ const {
14
14
  mainFields,
15
15
  getMediaPath,
16
16
  } = require('./helpers');
17
+ const { ESBUILD_TARGET } = require('../esbuild');
17
18
 
18
19
  const IS_APP = isApp();
19
20
  const CWD = process.cwd();
@@ -101,9 +102,10 @@ const getModuleRules = () => [
101
102
  fullySpecified: false,
102
103
  },
103
104
  use: {
104
- loader: 'babel-loader',
105
+ loader: 'esbuild-loader',
105
106
  options: {
106
- cacheDirectory: true,
107
+ loader: 'jsx',
108
+ target: ESBUILD_TARGET,
107
109
  },
108
110
  },
109
111
  },
@@ -128,7 +130,7 @@ const getModuleRules = () => [
128
130
  ],
129
131
  },
130
132
  {
131
- test: /\.(jpe?g|png|gif)$/i,
133
+ test: /\.(jpe?g|png|gif|ico)$/i,
132
134
  exclude: excludeNodeModulesExcept(['@elliemae/*']),
133
135
  type: 'asset',
134
136
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "5.17.3",
3
+ "version": "6.0.0-beta.4",
4
4
  "private": false,
5
5
  "description": "EllieMae Platform UI CLI",
6
6
  "sideEffects": false,
@@ -132,6 +132,8 @@
132
132
  "dotenv": "~10.0.0",
133
133
  "dotenv-webpack": "~7.0.3",
134
134
  "duplicate-package-checker-webpack-plugin": "~3.0.0",
135
+ "esbuild": "~0.13.15",
136
+ "esbuild-loader": "~2.16.0",
135
137
  "eslint": "~8.3.0",
136
138
  "eslint-config-airbnb": "~18.2.1",
137
139
  "eslint-config-airbnb-base": "~15.0.0",
@@ -188,7 +190,7 @@
188
190
  "pino-pretty": "~7.2.0",
189
191
  "pinst": "~2.1.6",
190
192
  "plop": "~2.7.6",
191
- "postcss": "~8.4.0",
193
+ "postcss": "~8.4.1",
192
194
  "postcss-jsx": "~0.36.4",
193
195
  "postcss-html": "~1.3.0",
194
196
  "postcss-markdown": "~1.2.0",
@@ -211,6 +213,7 @@
211
213
  "shelljs": "~0.8.4",
212
214
  "slackify-markdown": "~4.3.0",
213
215
  "storybook-react-router": "~1.0.8",
216
+ "storybook-addon-turbo-build": "~1.0.1",
214
217
  "style-loader": "~3.3.1",
215
218
  "stylelint": "~14.1.0",
216
219
  "stylelint-config-recommended": "~6.0.0",