@elliemae/pui-cli 6.0.0-beta.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;
@@ -209,4 +209,3 @@ exports.resolveExtensions = [
209
209
  ];
210
210
  exports.mainFields = ['browser', 'module', 'main'];
211
211
  exports.isGoogleTagManagerEnabled = isGoogleTagManagerEnabled;
212
- exports.ESBUILD_TARGET = 'es2020';
@@ -17,8 +17,8 @@ const {
17
17
  getAlias,
18
18
  getPaths,
19
19
  getMediaPath,
20
- ESBUILD_TARGET,
21
20
  } = require('./helpers');
21
+ const { ESBUILD_TARGET } = require('../esbuild');
22
22
  const { isTypeScriptEnabled } = require('../typescript/util');
23
23
 
24
24
  // get the application configuration
@@ -236,7 +236,7 @@ module.exports = (options) => ({
236
236
  ],
237
237
  },
238
238
  {
239
- test: /\.(jpe?g|png|gif)$/i,
239
+ test: /\.(jpe?g|png|gif|ico)$/i,
240
240
  exclude: excludeNodeModulesExcept(['@elliemae/*']),
241
241
  type: 'asset',
242
242
  },
@@ -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,
@@ -15,8 +15,8 @@ const {
15
15
  getPaths,
16
16
  getAppVersion,
17
17
  isGoogleTagManagerEnabled,
18
- ESBUILD_TARGET,
19
18
  } = require('./helpers');
19
+ const { ESBUILD_TARGET } = require('../esbuild');
20
20
 
21
21
  const getProdConfig = ({ latestVersion = true } = {}) => {
22
22
  const { buildPath, publicPath } = getPaths(latestVersion);
@@ -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": "6.0.0-beta.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,7 @@
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",
135
136
  "esbuild-loader": "~2.16.0",
136
137
  "eslint": "~8.3.0",
137
138
  "eslint-config-airbnb": "~18.2.1",