@elliemae/pui-cli 6.0.0-beta.55 → 6.0.0-beta.56

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.
@@ -6,6 +6,7 @@ const {
6
6
  logSuccess,
7
7
  writeAppInfo,
8
8
  } = require('./utils');
9
+ const { esBuild, TARGETS } = require('../transpile/esbuild');
9
10
 
10
11
  const { name } = require('../../package.json');
11
12
 
@@ -20,9 +21,13 @@ async function buildWebApp() {
20
21
 
21
22
  async function buildService() {
22
23
  await exec('rimraf ./build');
23
- await exec(
24
- `cross-env NODE_ENV=production MODULE_EXTENSIONS=true TARGET_ENV=node babel --extensions '.ts,.js' --config-file ./babel.config.cjs --out-dir ./build --copy-files --no-copy-ignored --ignore '**/*.test.ts','**/*.test.js','**/*.spec.ts','**/*.test.js' ./app`,
25
- );
24
+ await esBuild({
25
+ srcdir: './app',
26
+ outdir: 'build',
27
+ esmOnly: true,
28
+ target: TARGETS.node,
29
+ injectReactShim: false,
30
+ });
26
31
  }
27
32
 
28
33
  async function handler({ service = false }) {
@@ -1,58 +1,22 @@
1
- /* eslint-disable max-lines */
2
1
  const { exit } = require('yargs');
3
- const path = require('path');
4
- const { writeFile, readFile } = require('fs/promises');
5
2
  const { exec, logInfo, logError, logSuccess } = require('./utils');
6
3
  const { isTypeScriptEnabled } = require('../typescript/util');
7
4
  const { esBuild } = require('../transpile/esbuild');
8
-
9
5
  const { name } = require('../../package.json');
10
6
 
11
- async function compileTypeScript() {
7
+ const compileTypeScript = async () => {
12
8
  logInfo('Compiling typescript files...');
13
9
  await exec('tsc');
14
- await exec('tsc-alias');
15
- }
10
+ };
16
11
 
17
- async function webBuild(productionBuild) {
12
+ const webBuild = async (productionBuild) => {
18
13
  logInfo('Compiling source files for browser environment...');
19
14
  const devCmd = `node_modules/${name}/lib/webpack/webpack.lib.dev.babel.js --color`;
20
15
  const prodCmd = `node_modules/${name}/lib/webpack/webpack.lib.prod.babel.js --color`;
21
- await exec(
22
- `cross-env NODE_ENV=production webpack --config ${
23
- productionBuild ? prodCmd : devCmd
24
- }`,
25
- );
26
- }
27
-
28
- async function getSideEffects() {
29
- const data = await readFile(path.join(process.cwd(), './package.json'));
30
- const packageJSON = JSON.parse(data);
31
- return packageJSON?.sideEffects || false;
32
- }
33
-
34
- async function createPackageJson(file, commonJS, sideEffects) {
35
- const packageJSON = JSON.stringify({
36
- type: commonJS ? 'commonjs' : 'module',
37
- sideEffects,
38
- });
39
- await writeFile(file, packageJSON);
40
- }
41
-
42
- async function nodeBuild({ srcPath, commonJS, emitModuleType }) {
43
- const outDir = `./dist/${commonJS ? 'cjs' : 'es'}`;
44
- await esBuild({ srcPath, commonJS });
45
- if (emitModuleType) {
46
- const sideEffects = await getSideEffects();
47
- await createPackageJson(
48
- path.join(process.cwd(), outDir, 'package.json'),
49
- commonJS,
50
- sideEffects,
51
- );
52
- }
53
- }
16
+ await exec(`webpack --config ${productionBuild ? prodCmd : devCmd}`);
17
+ };
54
18
 
55
- async function pack({ production, target, module, srcPath, emitModuleType }) {
19
+ const pack = async ({ production, target, srcPath }) => {
56
20
  logInfo('Build in-progress...');
57
21
  await exec('rimraf ./dist');
58
22
  if (isTypeScriptEnabled()) {
@@ -60,28 +24,12 @@ async function pack({ production, target, module, srcPath, emitModuleType }) {
60
24
  }
61
25
  if (target !== 'node') await webBuild(production);
62
26
  if (target !== 'web') {
63
- logInfo('Compiling source files for nodejs environment');
64
- if (module !== 'es') {
65
- logInfo('output format: commonjs');
66
- await nodeBuild({
67
- srcPath,
68
- commonJS: true,
69
- emitModuleType,
70
- target,
71
- });
72
- }
73
- if (module !== 'cjs') {
74
- logInfo('output format: es');
75
- await nodeBuild({
76
- srcPath,
77
- commonJS: false,
78
- emitModuleType,
79
- });
80
- }
27
+ logInfo('building source files for nodejs environment');
28
+ await esBuild({ srcdir: srcPath });
81
29
  }
82
- }
30
+ };
83
31
 
84
- async function handler(argv) {
32
+ const handler = async (argv) => {
85
33
  try {
86
34
  await pack(argv);
87
35
  logSuccess('Build completed');
@@ -89,7 +37,7 @@ async function handler(argv) {
89
37
  logError('Build failed', err);
90
38
  exit(-1, err);
91
39
  }
92
- }
40
+ };
93
41
 
94
42
  exports.command = 'pack';
95
43
 
@@ -107,17 +55,6 @@ exports.builder = {
107
55
  description:
108
56
  'target environment where this library will be used. allowed values are web, node. by default libraries will be compiled for both web and nodejs environments',
109
57
  },
110
- module: {
111
- type: 'string',
112
- description:
113
- 'specify the format in which the library to be compiled. es - es module format, cjs - commonjs module format. by default libraries will be compiled in both es and cjs format ',
114
- },
115
- emitModuleType: {
116
- type: 'boolean',
117
- default: true,
118
- description:
119
- 'creates type attribute in the package.json and sets its value to commonjs or module based on module cli argument. default: true',
120
- },
121
58
  srcPath: {
122
59
  type: 'string',
123
60
  default: './lib',
@@ -1,63 +1,108 @@
1
- const esbuild = require('esbuild');
1
+ const { build } = require('esbuild');
2
2
  const fg = require('fast-glob');
3
- const fs = require('fs');
3
+ const { writeFile, copyFile, readFile } = require('fs/promises');
4
4
  const path = require('path');
5
- const { getPUIConfig } = require('../pui-config');
6
- // const browserslistToEsbuild = require('browserslist-to-esbuild');
5
+ const browserslistToEsbuild = require('browserslist-to-esbuild');
7
6
 
8
- const { esBuild } = getPUIConfig();
7
+ const TARGETS = {
8
+ browerslist: browserslistToEsbuild(),
9
+ web: 'es2020',
10
+ node: 'node14',
11
+ };
12
+
13
+ const ESBUILD_FORMAT = {
14
+ CJS: 'cjs',
15
+ ESM: 'esm',
16
+ };
17
+
18
+ const NODE_MODULE_TYPES = {
19
+ CJS: 'commonjs',
20
+ ESM: 'module',
21
+ };
9
22
 
10
- const commonConfig = {
23
+ const getCommonConfig = ({ injectReactShim }) => ({
11
24
  bundle: false,
12
- target: esBuild.target, // browserslistToEsbuild(),
13
25
  loader: { '.js': 'jsx' },
14
26
  mainFields: ['module', 'browser', 'main'],
15
- inject: [path.resolve(__dirname, './react-shim.js')],
16
- };
17
-
18
- const distFolder = 'dist';
27
+ inject: [
28
+ injectReactShim ? path.resolve(__dirname, './react-shim.js') : '',
29
+ ].filter(Boolean),
30
+ });
19
31
 
20
32
  const copyFiles = async ({ srcdir, outdir }) => {
21
33
  const files = await fg([
22
34
  `${srcdir}/**/*.*`,
23
35
  `!${srcdir}/**/*.{js,jsx,ts,tsx,cjs,mjs}`,
24
36
  ]);
25
- files.forEach((srcFilePath) => {
37
+ files.forEach(async (srcFilePath) => {
26
38
  const destFilePath = srcFilePath.replace(srcdir, outdir);
27
- fs.copyFileSync(srcFilePath, destFilePath);
39
+ await copyFile(srcFilePath, destFilePath);
28
40
  });
29
41
  };
30
42
 
31
- const build = async ({ srcPath, commonJS }) => {
43
+ const getSideEffects = async () => {
44
+ const data = await readFile(path.join(process.cwd(), './package.json'));
45
+ const packageJSON = JSON.parse(data);
46
+ return packageJSON?.sideEffects || false;
47
+ };
48
+
49
+ const createPackageJson = async ({ outdir, type = NODE_MODULE_TYPES.ESM }) => {
50
+ const filePath = path.join(process.cwd(), outdir, 'package.json');
51
+ const packageJSON = JSON.stringify(
52
+ {
53
+ type,
54
+ sideEffects: await getSideEffects(),
55
+ },
56
+ null,
57
+ 2,
58
+ );
59
+ await writeFile(filePath, packageJSON);
60
+ };
61
+
62
+ exports.esBuild = async ({
63
+ srcdir,
64
+ outdir = 'dist',
65
+ esmOnly = false,
66
+ target = TARGETS.browerslist,
67
+ injectReactShim = true,
68
+ }) => {
32
69
  const inputFiles = [
33
- `${srcPath}/**/*.{js,jsx,ts,tsx}`,
34
- `!${srcPath}/**/*.test.{js,jsx,ts,tsx}`,
35
- `!${srcPath}/**/*.stories.{js,jsx,ts,tsx}`,
36
- `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
70
+ `${srcdir}/**/*.{js,jsx,ts,tsx}`,
71
+ `!${srcdir}/**/*.test.{js,jsx,ts,tsx}`,
72
+ `!${srcdir}/**/*.stories.{js,jsx,ts,tsx}`,
73
+ `!${srcdir}/**/*.endpoint.{js,jsx,ts,tsx}`,
37
74
  ];
38
- if (commonJS) {
39
- const outdir = `${distFolder}/cjs`;
75
+
76
+ // build commonjs
77
+ if (!esmOnly) {
78
+ const cjsOutdir = `${outdir}/cjs`;
40
79
  const commonJSEntryPoints = await fg(inputFiles);
41
- await esbuild.build({
80
+ await build({
42
81
  entryPoints: commonJSEntryPoints,
43
- ...commonConfig,
44
- outdir,
45
- format: 'cjs',
82
+ ...getCommonConfig({ injectReactShim }),
83
+ outdir: cjsOutdir,
84
+ format: ESBUILD_FORMAT.CJS,
85
+ target,
46
86
  });
47
- await copyFiles({ srcdir: srcPath, outdir });
48
- } else {
49
- const outdir = `${distFolder}/es`;
50
- const entryPoints = await fg(
51
- inputFiles.concat([`!${srcPath}/**/cjs/**/*.{js,jsx,ts,tsx}`]),
52
- );
53
- await esbuild.build({
54
- entryPoints,
55
- ...commonConfig,
56
- outdir,
57
- format: 'esm',
58
- });
59
- await copyFiles({ srcdir: srcPath, outdir });
87
+ // copy files that are not built by esbuild
88
+ await copyFiles({ srcdir, outdir: cjsOutdir });
89
+ await createPackageJson({ outdir: cjsOutdir, type: NODE_MODULE_TYPES.CJS });
60
90
  }
61
- };
62
91
 
63
- exports.esBuild = build;
92
+ // build esm
93
+ const esmOutdir = esmOnly ? outdir : `${outdir}/esm`;
94
+ const entryPoints = await fg(
95
+ inputFiles.concat([`!${srcdir}/**/cjs/**/*.{js,jsx,ts,tsx}`]),
96
+ );
97
+ await build({
98
+ entryPoints,
99
+ ...getCommonConfig({ injectReactShim }),
100
+ outdir: esmOutdir,
101
+ format: ESBUILD_FORMAT.ESM,
102
+ target,
103
+ });
104
+ // copy files that are not built by esbuild
105
+ await copyFiles({ srcdir, outdir: esmOutdir });
106
+ await createPackageJson({ outdir: esmOutdir, type: NODE_MODULE_TYPES.ESM });
107
+ };
108
+ exports.TARGETS = TARGETS;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable max-lines */
2
2
  const path = require('path');
3
- const webpack = require('webpack');
3
+ const { EnvironmentPlugin, DefinePlugin } = require('webpack');
4
4
  const {
5
5
  optimize: { LimitChunkCountPlugin },
6
6
  ProgressPlugin,
@@ -10,6 +10,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
10
10
  const PostcssPresetEnv = require('postcss-preset-env');
11
11
  const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
12
12
  const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
13
+ const browserslistToEsbuild = require('browserslist-to-esbuild');
13
14
 
14
15
  const {
15
16
  excludeNodeModulesExcept,
@@ -18,9 +19,8 @@ const {
18
19
  modulesToTranspile,
19
20
  getAssetPath,
20
21
  getAlias,
22
+ filterByFilePresence,
21
23
  } = require('./helpers');
22
- const { getPUIConfig } = require('../pui-config');
23
- const { esBuild } = getPUIConfig();
24
24
 
25
25
  const minicssLoader = {
26
26
  loader: MiniCssExtractPlugin.loader,
@@ -31,16 +31,16 @@ const finalCSSLoader = (mode) =>
31
31
  mode !== 'production' ? { loader: 'style-loader' } : minicssLoader;
32
32
 
33
33
  const plugins = [
34
- new webpack.EnvironmentPlugin({
34
+ new EnvironmentPlugin({
35
35
  NODE_ENV: 'development',
36
36
  ASSET_PATH: '/',
37
37
  CI: 'false',
38
38
  }),
39
- new webpack.DefinePlugin({
39
+ new DefinePlugin({
40
40
  APP_CONFIG: getAppConfig(true),
41
41
  }),
42
42
  new CopyWebpackPlugin({
43
- patterns: [
43
+ patterns: filterByFilePresence([
44
44
  {
45
45
  from: 'lib/app.config.json',
46
46
  to: 'app.config.json',
@@ -50,7 +50,7 @@ const plugins = [
50
50
  from: 'lib/public',
51
51
  noErrorOnMissing: true,
52
52
  },
53
- ],
53
+ ]),
54
54
  }),
55
55
  new DuplicatePackageCheckerPlugin(),
56
56
  new LimitChunkCountPlugin({
@@ -84,7 +84,7 @@ module.exports = (options) => ({
84
84
  loader: 'esbuild-loader',
85
85
  options: {
86
86
  loader: 'jsx',
87
- target: esBuild.target,
87
+ target: browserslistToEsbuild(),
88
88
  },
89
89
  },
90
90
  },
@@ -98,7 +98,7 @@ module.exports = (options) => ({
98
98
  loader: 'esbuild-loader',
99
99
  options: {
100
100
  loader: 'tsx',
101
- target: esBuild.target,
101
+ target: browserslistToEsbuild(),
102
102
  },
103
103
  },
104
104
  },
@@ -157,6 +157,7 @@ module.exports = (options) => ({
157
157
  test: /\.svg$/i,
158
158
  issuer: /\.[jt]sx?$/,
159
159
  resourceQuery: /^((?!url).)*$/,
160
+ exclude: excludeNodeModulesExcept(['@elliemae/*']),
160
161
  use: ['@svgr/webpack'],
161
162
  },
162
163
  {
@@ -177,10 +178,12 @@ module.exports = (options) => ({
177
178
  {
178
179
  resourceQuery: /resource/,
179
180
  type: 'asset/resource',
181
+ exclude: excludeNodeModulesExcept(['@elliemae/*']),
180
182
  },
181
183
  {
182
184
  type: 'asset',
183
185
  resourceQuery: /url/,
186
+ exclude: excludeNodeModulesExcept(['@elliemae/*']),
184
187
  },
185
188
  ],
186
189
  },
@@ -35,7 +35,7 @@ module.exports = require('./webpack.lib.base.babel')({
35
35
  libraryName,
36
36
  }),
37
37
  new CircularDependencyPlugin({
38
- exclude: /a\.js|node_modules/, // exclude node_modules
38
+ exclude: /a\.(js|ts|jsx|tsx)|node_modules/, // exclude node_modules
39
39
  failOnError: false, // show a warning when there is a circular dependency
40
40
  }),
41
41
  new MiniCssExtractPlugin({
@@ -3,9 +3,8 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
4
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
5
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
6
+ const browserslistToEsbuild = require('browserslist-to-esbuild');
6
7
  const { getLibraryName, getCompressionPlugins } = require('./helpers');
7
- const { getPUIConfig } = require('../pui-config');
8
- const { esBuild } = getPUIConfig();
9
8
 
10
9
  const libraryName = getLibraryName();
11
10
 
@@ -24,7 +23,7 @@ module.exports = require('./webpack.lib.base.babel')({
24
23
  minimize: true,
25
24
  minimizer: [
26
25
  new ESBuildMinifyPlugin({
27
- target: esBuild.target,
26
+ target: browserslistToEsbuild(),
28
27
  css: true,
29
28
  }),
30
29
  ],
@@ -6,6 +6,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
6
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
7
  const { ESBuildMinifyPlugin } = require('esbuild-loader');
8
8
  const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
9
+ const browserslistToEsbuild = require('browserslist-to-esbuild');
9
10
 
10
11
  const baseConfigFactory = require('./webpack.base.babel');
11
12
  const {
@@ -17,8 +18,6 @@ const {
17
18
  isGoogleTagManagerEnabled,
18
19
  getCompressionPlugins,
19
20
  } = require('./helpers');
20
- const { getPUIConfig } = require('../pui-config');
21
- const { esBuild } = getPUIConfig();
22
21
 
23
22
  const getProdConfig = ({ latestVersion = true } = {}) => {
24
23
  const { buildPath, publicPath } = getPaths(latestVersion);
@@ -43,7 +42,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
43
42
  moduleIds: 'deterministic',
44
43
  minimizer: [
45
44
  new ESBuildMinifyPlugin({
46
- target: esBuild.target,
45
+ target: browserslistToEsbuild(),
47
46
  css: true,
48
47
  }),
49
48
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.55",
3
+ "version": "6.0.0-beta.56",
4
4
  "private": false,
5
5
  "description": "ICE MT UI Platform CLI",
6
6
  "sideEffects": false,
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/cli": "~7.16.8",
51
- "@babel/core": "~7.16.7",
51
+ "@babel/core": "~7.16.10",
52
52
  "@babel/eslint-parser": "~7.16.5",
53
53
  "@babel/node": "~7.16.8",
54
54
  "@babel/plugin-proposal-class-properties": "~7.16.7",
@@ -58,14 +58,14 @@
58
58
  "@babel/plugin-transform-react-constant-elements": "~7.16.7",
59
59
  "@babel/plugin-transform-react-inline-elements": "~7.16.7",
60
60
  "@babel/plugin-transform-react-jsx-source": "~7.16.7",
61
- "@babel/plugin-transform-runtime": "~7.16.8",
62
- "@babel/preset-env": "~7.16.8",
61
+ "@babel/plugin-transform-runtime": "~7.16.10",
62
+ "@babel/preset-env": "~7.16.11",
63
63
  "@babel/preset-react": "~7.16.7",
64
64
  "@babel/preset-typescript": "~7.16.7",
65
65
  "@babel/runtime": "~7.16.7",
66
- "@commitlint/cli": "~16.0.2",
66
+ "@commitlint/cli": "~16.1.0",
67
67
  "@commitlint/config-conventional": "~16.0.0",
68
- "@elliemae/browserslist-config-elliemae": "~1.2.1",
68
+ "@elliemae/browserslist-config-elliemae-latest-browsers": "~1.2.1",
69
69
  "@pmmmwh/react-refresh-webpack-plugin": "~0.5.4",
70
70
  "@semantic-release/changelog": "~6.0.1",
71
71
  "@semantic-release/exec": "~6.0.3",
@@ -83,7 +83,7 @@
83
83
  "@stylelint/postcss-css-in-js": "~0.37.2",
84
84
  "@svgr/webpack": "~6.2.0",
85
85
  "@swc/cli": "~0.1.55",
86
- "@swc/core": "~1.2.130",
86
+ "@swc/core": "~1.2.133",
87
87
  "@swc/jest": "~0.2.17",
88
88
  "@testing-library/jest-dom": "~5.16.1",
89
89
  "@testing-library/react": "~12.1.2",
@@ -117,7 +117,7 @@
117
117
  "circular-dependency-plugin": "~5.2.2",
118
118
  "compression": "~1.7.4",
119
119
  "compression-webpack-plugin": "~9.2.0",
120
- "copy-webpack-plugin": "~10.2.0",
120
+ "copy-webpack-plugin": "~10.2.1",
121
121
  "cors": "~2.8.5",
122
122
  "cross-env": "~7.0.3",
123
123
  "css-loader": "~6.5.1",
@@ -151,7 +151,7 @@
151
151
  "eslint-plugin-react": "~7.28.0",
152
152
  "eslint-plugin-react-hooks": "~4.3.0",
153
153
  "eslint-plugin-redux-saga": "~1.3.2",
154
- "eslint-plugin-storybook": "~0.5.5",
154
+ "eslint-plugin-storybook": "~0.5.6",
155
155
  "eslint-plugin-testing-library": "~5.0.3",
156
156
  "eslint-plugin-wdio": "~7.4.2",
157
157
  "execa": "~5.1.1",
@@ -160,7 +160,7 @@
160
160
  "express-static-gzip": "~2.1.1",
161
161
  "favicons": "~6.2.2",
162
162
  "favicons-webpack-plugin": "~5.0.2",
163
- "happy-dom": "~2.27.0",
163
+ "happy-dom": "~2.27.2",
164
164
  "helmet-csp": "~3.4.0",
165
165
  "html-webpack-plugin": "~5.5.0",
166
166
  "http-server": "~14.1.0",
@@ -174,7 +174,7 @@
174
174
  "jest-styled-components": "~7.0.8",
175
175
  "jscodeshift": "~0.13.1",
176
176
  "jsdoc": "~3.6.7",
177
- "lint-staged": "~12.2.0",
177
+ "lint-staged": "~12.2.2",
178
178
  "mini-css-extract-plugin": "~2.5.2",
179
179
  "minimist": "~1.2.5",
180
180
  "moment": "~2.29.1",
@@ -185,8 +185,8 @@
185
185
  "nodemon": "~2.0.15",
186
186
  "npm-check-updates": "12.1.0",
187
187
  "null-loader": "~4.0.1",
188
- "pino": "~7.6.3",
189
- "pino-pretty": "~7.3.0",
188
+ "pino": "~7.6.4",
189
+ "pino-pretty": "~7.5.0",
190
190
  "pinst": "~2.1.6",
191
191
  "plop": "~3.0.5",
192
192
  "postcss": "~8.4.5",
@@ -221,12 +221,12 @@
221
221
  "terser-webpack-plugin": "~5.3.0",
222
222
  "ts-node": "~10.4.0",
223
223
  "tsc-alias": "~1.5.0",
224
- "typescript": "~4.5.4",
224
+ "typescript": "~4.5.5",
225
225
  "update-notifier": "~5.1.0",
226
226
  "url-loader": "~4.1.1",
227
227
  "uuid": "~8.3.2",
228
228
  "vite": "~2.7.13",
229
- "vitest": "~0.1.21",
229
+ "vitest": "~0.1.24",
230
230
  "webpack": "~5.65.0",
231
231
  "webpack-bundle-analyzer": "~4.5.0",
232
232
  "webpack-cli": "~4.9.1",