@elliemae/pui-cli 6.0.0-beta.2 → 6.0.0-beta.23

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.
Files changed (35) hide show
  1. package/lib/babel/babel.config.js +8 -3
  2. package/lib/cli-commands/build.js +1 -1
  3. package/lib/cli-commands/lint.js +6 -4
  4. package/lib/cli-commands/pack.js +6 -11
  5. package/lib/cli-commands/storybook.js +1 -1
  6. package/lib/cli-commands/test.js +18 -17
  7. package/lib/lint/eslint/common.js +7 -9
  8. package/lib/lint/lint-staged.config.js +1 -1
  9. package/lib/lint/stylelint.config.js +2 -9
  10. package/lib/release/release.config.js +1 -1
  11. package/lib/server/csp.js +2 -0
  12. package/lib/server/index.js +5 -9
  13. package/lib/server/middlewares/addDevMiddlewares.js +2 -2
  14. package/lib/server/middlewares/addProdMiddlewares.js +10 -3
  15. package/lib/server/util/index.js +2 -2
  16. package/lib/testing/jest.config.js +15 -6
  17. package/lib/testing/mocks/matchMedia.js +2 -2
  18. package/lib/testing/mocks/pui-app-loader.js +1 -3
  19. package/lib/testing/mocks/pui-diagnostics.js +27 -35
  20. package/lib/testing/mocks/pui-user-monitoring.js +3 -5
  21. package/lib/testing/mocks/retry-axios.js +3 -5
  22. package/lib/testing/mocks/svg.js +5 -3
  23. package/lib/testing/setup-tests.js +4 -4
  24. package/lib/transpile/esbuild.js +62 -0
  25. package/lib/transpile/react-shim.js +2 -0
  26. package/lib/typescript/util.js +1 -1
  27. package/lib/webpack/helpers.js +46 -36
  28. package/lib/webpack/webpack.base.babel.js +39 -69
  29. package/lib/webpack/webpack.dev.babel.js +15 -7
  30. package/lib/webpack/webpack.lib.base.babel.js +43 -50
  31. package/lib/webpack/webpack.lib.dev.babel.js +0 -6
  32. package/lib/webpack/webpack.lib.prod.babel.js +7 -22
  33. package/lib/webpack/webpack.prod.babel.js +6 -36
  34. package/lib/webpack/webpack.storybook.js +21 -85
  35. package/package.json +129 -125
@@ -10,7 +10,7 @@ const nodeEnvPreset = {
10
10
  const webEnvPreset = {
11
11
  modules: process.env.ES_MODULES === 'false' ? 'commonjs' : false,
12
12
  useBuiltIns: 'usage',
13
- corejs: { version: '3.18', proposals: true },
13
+ corejs: { version: '3.19', proposals: true },
14
14
  };
15
15
 
16
16
  const presetEnvOptions =
@@ -39,13 +39,14 @@ const config = {
39
39
  '@babel/plugin-proposal-class-properties',
40
40
  '@babel/plugin-syntax-dynamic-import',
41
41
  '@babel/plugin-proposal-export-default-from',
42
+ 'lodash',
43
+ 'date-fns',
42
44
  ],
43
45
  env: {
44
46
  development: {
45
47
  plugins: [
46
48
  ['babel-plugin-styled-components', { displayName: true }],
47
49
  '@babel/plugin-transform-react-jsx-source',
48
- 'react-refresh/babel',
49
50
  ],
50
51
  },
51
52
  production: {
@@ -79,7 +80,11 @@ if (process.env.MODULE_EXTENSIONS === 'true') {
79
80
  config.plugins.push('babel-plugin-add-import-extension');
80
81
  }
81
82
 
82
- // ToDo: Once ECC team migrates from webpack 3 to webpack 5 remove tis strip-block plugin from commonjs output. without this they are receiving error when import.meta is used in app sdk
83
+ if (process.env.STORYBOOK_BUILD !== 'true') {
84
+ config.env?.development?.plugins?.push?.('react-refresh/babel');
85
+ }
86
+
87
+ // ToDo: Once ECC team migrates from webpack 3 to webpack 5 remove this strip-block plugin from commonjs output. without this they are receiving error when import.meta is used in app sdk
83
88
  if (process.env.ES_MODULES === 'false') {
84
89
  config.plugins.push([
85
90
  'babel-plugin-transform-strip-block',
@@ -21,7 +21,7 @@ async function buildWebApp() {
21
21
  async function buildService() {
22
22
  await exec('rimraf ./build');
23
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 --ignore '**/*.test.js','**/*.test.ts' ./app`,
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
25
  );
26
26
  }
27
27
 
@@ -1,10 +1,11 @@
1
1
  const { exit } = require('yargs');
2
2
  const { exec, logError, logSuccess } = require('./utils');
3
- const { isTypeScripEnabled } = require('../typescript/util');
3
+ const { isTypeScriptEnabled } = require('../typescript/util');
4
4
 
5
- async function lintCSS() {
5
+ async function lintCSS(fix = false) {
6
+ const fixIssues = fix ? '--fix' : '';
6
7
  await exec(
7
- `stylelint "./**/*.{js, ts}" --color --allowEmptyInput --ignore-pattern '/dist/**/*'`,
8
+ `stylelint ./{lib,app}/**/*.{js,jsx,ts,tsx} ${fixIssues} --color --allowEmptyInput --ignore-pattern /dist/**/*`,
8
9
  );
9
10
  }
10
11
 
@@ -18,7 +19,8 @@ async function lintJS(fix = false) {
18
19
  async function handler(argv) {
19
20
  if (argv.js) {
20
21
  // run typescript compilation
21
- if (isTypeScripEnabled) await exec('tsc');
22
+ if (isTypeScriptEnabled())
23
+ await exec('tsc --noEmit --emitDeclarationOnly false');
22
24
  try {
23
25
  await exec('rimraf ./reports/eslint.json');
24
26
  await lintJS(argv.fix);
@@ -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
- const { isTypeScripEnabled } = require('../typescript/util');
6
+ const { isTypeScriptEnabled } = require('../typescript/util');
7
+ const { esBuild } = require('../transpile/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 --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(
@@ -58,7 +55,7 @@ async function nodeBuild({ srcPath, commonJS, emitModuleType, target }) {
58
55
  async function pack({ production, target, module, srcPath, emitModuleType }) {
59
56
  logInfo('Build in-progress...');
60
57
  await exec('rimraf ./dist');
61
- if (isTypeScripEnabled()) {
58
+ if (isTypeScriptEnabled()) {
62
59
  await compileTypeScript();
63
60
  }
64
61
  if (target !== 'node') await webBuild(production);
@@ -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',
@@ -10,7 +10,7 @@ async function buildStoryBook(isDoc = false) {
10
10
 
11
11
  async function startStoryBook(isDoc = false) {
12
12
  await exec(
13
- `cross-env FORCE_COLOR=true start-storybook ${
13
+ `cross-env NODE_ENV=development STORYBOOK_BUILD=true FORCE_COLOR=true start-storybook ${
14
14
  isDoc && '--docs'
15
15
  } -p 11000 --quiet`,
16
16
  );
@@ -1,11 +1,13 @@
1
1
  const { exit } = require('yargs');
2
2
  const { exec, logError, logSuccess } = require('./utils');
3
- const { lintCSS, lintJS } = require('./lint');
3
+ // const { lintCSS, lintJS } = require('./lint');
4
4
 
5
5
  const { CI = false } = process.env;
6
6
 
7
7
  async function test(commandOptions) {
8
- await exec(`cross-env FORCE_COLOR=true NODE_ENV=test jest ${commandOptions}`);
8
+ await exec(
9
+ `cross-env FORCE_COLOR=true NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest ${commandOptions}`,
10
+ );
9
11
  }
10
12
 
11
13
  // eslint-disable-next-line max-statements
@@ -13,25 +15,24 @@ async function handler(argv) {
13
15
  let commandOptions = '--coverage';
14
16
  if (argv.fix) commandOptions = '-u';
15
17
  else if (argv.watch) commandOptions = '--watchAll';
16
- if (CI) commandOptions += ' --ci';
18
+ if (CI) commandOptions += ' --ci --runInBand';
19
+ else commandOptions += ' --maxWorkers=50%';
17
20
  if (argv.p) commandOptions += ' --passWithNoTests';
18
21
  if (argv.r) commandOptions += ' --bail --findRelatedTests';
19
22
  if (argv.s) commandOptions += ' --silent';
20
23
  try {
21
- if (!CI) {
22
- try {
23
- await lintJS();
24
- await lintCSS();
25
- logSuccess('Linting completed');
26
- } catch (err) {
27
- logError('Linting failed');
28
- exit(-1, err);
29
- return -1;
30
- }
31
- } else {
32
- await exec('rimraf ./reports');
33
- }
34
-
24
+ // if (!CI) {
25
+ // try {
26
+ // await lintJS();
27
+ // await lintCSS();
28
+ // logSuccess('Linting completed');
29
+ // } catch (err) {
30
+ // logError('Linting failed');
31
+ // exit(-1, err);
32
+ // return -1;
33
+ // }
34
+ // }
35
+ await exec('rimraf ./reports');
35
36
  // eslint-disable-next-line jest/valid-title, jest/no-disabled-tests, jest/expect-expect
36
37
  await test(commandOptions);
37
38
  logSuccess('Unit test execution completed');
@@ -9,6 +9,7 @@ exports.baseExtends = [
9
9
  'plugin:jsdoc/recommended',
10
10
  'plugin:wdio/recommended',
11
11
  'plugin:testing-library/dom',
12
+ 'plugin:storybook/recommended',
12
13
  ];
13
14
 
14
15
  const basePlugins = ['testing-library', 'jest', 'jsdoc', 'wdio'];
@@ -36,12 +37,10 @@ const baseRules = {
36
37
  'import/prefer-default-export': 0,
37
38
  'import/extensions': [
38
39
  2,
39
- 'ignorePackages',
40
+ 'never',
40
41
  {
41
- js: 'never',
42
- jsx: 'never',
43
- ts: 'never',
44
- tsx: 'never',
42
+ json: 'ignorePackages',
43
+ js: 'ignorePackages',
45
44
  },
46
45
  ],
47
46
  indent: [
@@ -104,7 +103,7 @@ const reactRules = {
104
103
  'react/react-in-jsx-scope': 0,
105
104
  'react/jsx-filename-extension': [
106
105
  1,
107
- { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
106
+ { extensions: ['.js', '.jsx', '.tsx', '.mdx'] },
108
107
  ],
109
108
  'redux-saga/no-yield-in-race': 2,
110
109
  'redux-saga/yield-effects': 2,
@@ -112,16 +111,15 @@ const reactRules = {
112
111
  exports.reactRules = reactRules;
113
112
 
114
113
  exports.baseConfig = {
115
- parser: 'babel-eslint',
114
+ parser: '@babel/eslint-parser',
116
115
  plugins: basePlugins,
117
116
  env: {
118
117
  jest: true,
119
118
  browser: true,
120
119
  node: true,
121
- es6: true,
120
+ es2021: true,
122
121
  },
123
122
  parserOptions: {
124
- ecmaVersion: 2020,
125
123
  sourceType: 'module',
126
124
  ecmaFeatures: {
127
125
  jsx: true,
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- '*.{ts,tsx}': ['tsc-files'],
2
+ '*.{ts,tsx}': ['tsc-files --noEmit --emitDeclarationOnly false'],
3
3
  '*.{js,ts,jsx,tsx}': [
4
4
  'npm run lint:fix',
5
5
  'npm run test:staged',
@@ -1,16 +1,9 @@
1
1
  module.exports = {
2
- processors: [
3
- [
4
- 'stylelint-processor-styled-components',
5
- {
6
- ignoreFiles: ['**/*.scss'],
7
- },
8
- ],
9
- ],
2
+ customSyntax: '@stylelint/postcss-css-in-js',
10
3
  plugins: [],
11
4
  extends: [
12
5
  'stylelint-config-recommended',
13
6
  'stylelint-config-styled-components',
14
7
  ],
15
- rules: { 'selector-type-no-unknown': null },
8
+ rules: { 'selector-type-no-unknown': null, 'no-extra-semicolons': null },
16
9
  };
@@ -2,11 +2,11 @@ module.exports = {
2
2
  branches: [
3
3
  '+([0-9])?(.{+([0-9]),x}).x',
4
4
  'master',
5
- 'next',
6
5
  'next-major',
7
6
  { name: 'beta', prerelease: true },
8
7
  { name: 'alpha', prerelease: true },
9
8
  { name: 'hotfix', prerelease: true },
9
+ { name: 'next', prerelease: true },
10
10
  ],
11
11
  plugins: [
12
12
  '@semantic-release/commit-analyzer',
package/lib/server/csp.js CHANGED
@@ -12,6 +12,8 @@ const sources = [
12
12
  '*.ellielabs.com',
13
13
  'http://pdx-col.eum-appdynamics.com',
14
14
  'https://pdx-col.eum-appdynamics.com/',
15
+ 'https://www.google-analytics.com',
16
+ 'https://www.googletagmanager.com',
15
17
  ];
16
18
 
17
19
  const sendFileWithCSPNonce = ({
@@ -13,8 +13,11 @@ const { loadRoutes } = require('./util');
13
13
  const { getAssetPath } = require('../webpack/helpers');
14
14
 
15
15
  const pino = expressPinoLogger({
16
- prettyPrint: {
17
- levelFirst: true,
16
+ transport: {
17
+ target: 'pino-pretty',
18
+ options: {
19
+ colorize: true,
20
+ },
18
21
  },
19
22
  });
20
23
  pino.logger.level = 'warn';
@@ -57,13 +60,6 @@ const customHost = argv.host || process.env.HOST;
57
60
  const host = customHost || null; // Let http.Server use its default IPv6/4 host
58
61
  const prettyHost = customHost || 'localhost';
59
62
 
60
- // use the gzipped bundle
61
- app.get('*.js', (req, res, next) => {
62
- req.url += '.gz';
63
- res.set('Content-Encoding', 'gzip');
64
- next();
65
- });
66
-
67
63
  // Start your app.
68
64
  app.listen(port, host, async (err) => {
69
65
  if (err) {
@@ -1,5 +1,5 @@
1
1
  const webpack = require('webpack');
2
- const express = require('express');
2
+ const expressStaticGzip = require('express-static-gzip');
3
3
  const webpackDevMiddleware = require('webpack-dev-middleware');
4
4
  const webpackHotMiddleware = require('webpack-hot-middleware');
5
5
  const { sendFileWithCSPNonce } = require('../csp');
@@ -25,7 +25,7 @@ module.exports = function addDevMiddlewares(app, webpackConfig) {
25
25
  heartbeat: 10 * 1000,
26
26
  }),
27
27
  );
28
- app.use(express.static('cdn'));
28
+ app.use(expressStaticGzip('cdn'));
29
29
 
30
30
  const { outputFileSystem } = (middleware || {}).context || {};
31
31
 
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
- const express = require('express');
3
2
  const compression = require('compression');
3
+ const expressStaticGzip = require('express-static-gzip');
4
4
  const { sendFileWithCSPNonce } = require('../csp');
5
5
 
6
6
  module.exports = function addProdMiddlewares(app, options) {
@@ -17,8 +17,15 @@ module.exports = function addProdMiddlewares(app, options) {
17
17
  sendFileWithCSPNonce({ outputPath, res });
18
18
  });
19
19
 
20
- app.use(publicPath, express.static(outputPath, { index: false }));
21
- app.use(express.static('cdn'));
20
+ app.use(
21
+ publicPath,
22
+ expressStaticGzip(outputPath, {
23
+ index: false,
24
+ enableBrotli: true,
25
+ orderPreference: ['br'],
26
+ }),
27
+ );
28
+ app.use(expressStaticGzip('cdn'));
22
29
 
23
30
  app.get('*', (req, res) => sendFileWithCSPNonce({ outputPath, res }));
24
31
  };
@@ -3,9 +3,9 @@ const path = require('path');
3
3
 
4
4
  const getCWD = () => process.cwd();
5
5
 
6
- const allJS = new RegExp(/\.js$/);
6
+ const allJS = /\.js$/;
7
7
 
8
- const serviceEndpoints = new RegExp(/\.endpoint\.js$/);
8
+ const serviceEndpoints = /\.endpoint\.js$/;
9
9
 
10
10
  const getFilesMatching = (filePattern) => {
11
11
  const getFiles = (dir) => {
@@ -42,8 +42,8 @@ const jestConfig = {
42
42
  '!app/*/RbGenerated*/*.{js, ts, jsx, tsx}',
43
43
  '!app/index.{js, ts, jsx, tsx}',
44
44
  '!app/global-styles.{js, ts, jsx, tsx}',
45
- '!app/*/*/loadable.{js, ts, jsx, tsx}',
46
- '!lib/*/*/loadable.{js, ts, jsx, tsx}',
45
+ '!app/**/loadable.{js, ts, jsx, tsx}',
46
+ '!lib/**/loadable.{js, ts, jsx, tsx}',
47
47
  ],
48
48
  coverageThreshold: {
49
49
  // Todo: enable the coverage threshold later
@@ -62,6 +62,7 @@ const jestConfig = {
62
62
  '.*\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$': `${getRootDir()}/lib/testing/mocks/image.js`,
63
63
  '.*\\.svg$': `${getRootDir()}/lib/testing/mocks/svg.js`,
64
64
  '.*\\.(html)$': `${getRootDir()}/lib/testing/mocks/html.js`,
65
+ '^lodash-es$': 'lodash',
65
66
  '@elliemae/pui-user-monitoring': `${getRootDir()}/lib/testing/mocks/pui-user-monitoring.js`,
66
67
  '@elliemae/pui-app-loader': `${getRootDir()}/lib/testing/mocks/pui-app-loader.js`,
67
68
  '@elliemae/pui-diagnostics': `${getRootDir()}/lib/testing/mocks/pui-diagnostics.js`,
@@ -70,12 +71,20 @@ const jestConfig = {
70
71
  },
71
72
  setupFilesAfterEnv: [`${getRootDir()}/lib/testing/setup-tests.js`],
72
73
  setupFiles: ['raf/polyfill', 'whatwg-fetch'],
73
- testRegex: '(app|lib).*/tests/.*\\.test\\.(js|ts)$',
74
+ testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
74
75
  snapshotSerializers: [],
75
76
  testResultsProcessor: 'jest-sonar-reporter',
77
+ resolver: 'ts-jest-resolver',
78
+ transform: {
79
+ '^.+\\.[jt]sx?$': [
80
+ 'esbuild-jest',
81
+ {
82
+ target: 'node14',
83
+ },
84
+ ],
85
+ },
76
86
  transformIgnorePatterns: [
77
- 'node_modules/(?!(@elliemae/*)/)',
78
- 'node_modules/@elliemae/em-platform-document-viewer',
87
+ 'node_modules/(?!(@elliemae/pui-cli/lib/testing/*)/)',
79
88
  ],
80
89
  globals: {
81
90
  APP_CONFIG: getAppConfig(),
@@ -85,7 +94,7 @@ const jestConfig = {
85
94
  testEnvironment: 'jsdom',
86
95
  };
87
96
 
88
- if (isReactModule)
97
+ if (isReactModule && jestConfig.setupFilesAfterEnv)
89
98
  jestConfig.setupFilesAfterEnv.push(
90
99
  `${getRootDir()}/lib/testing/setup-styled-components-tests.js`,
91
100
  );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
3
  */
4
- export default function () {
4
+ export default () => {
5
5
  Object.defineProperty(window, 'matchMedia', {
6
6
  value: () => ({
7
7
  matches: false,
@@ -15,4 +15,4 @@ export default function () {
15
15
  getPropertyValue: () => {},
16
16
  }),
17
17
  });
18
- }
18
+ };
@@ -1,3 +1 @@
1
- module.exports = {
2
- load: () => {},
3
- };
1
+ export const load = () => {};
@@ -1,36 +1,28 @@
1
- module.exports = {
2
- logger() {
3
- return {
4
- setLogLevel() {},
5
- setOptions() {},
6
- info() {},
7
- warn() {},
8
- error() {},
9
- trace() {},
10
- debug() {},
11
- audit() {},
12
- fatal() {},
13
- };
14
- },
15
- LogLevel: {
16
- info: 'info',
17
- debug: 'debug',
18
- trace: 'trace',
19
- warn: 'warn',
20
- error: 'error',
21
- audit: 'audit',
22
- fatal: 'fatal',
23
- },
24
- Console() {
25
- return {
26
- log() {},
27
- };
28
- },
29
- http() {
30
- return {
31
- log() {},
32
- };
33
- },
34
- webvitals() {},
35
- logUnhandledErrors() {},
1
+ export const logger = () => ({
2
+ setLogLevel() {},
3
+ setOptions() {},
4
+ info() {},
5
+ warn() {},
6
+ error() {},
7
+ trace() {},
8
+ debug() {},
9
+ audit() {},
10
+ fatal() {},
11
+ });
12
+ export const LogLevel = {
13
+ info: 'info',
14
+ debug: 'debug',
15
+ trace: 'trace',
16
+ warn: 'warn',
17
+ error: 'error',
18
+ audit: 'audit',
19
+ fatal: 'fatal',
36
20
  };
21
+ export const Console = () => ({
22
+ log: () => {},
23
+ });
24
+ export const http = () => ({
25
+ log() {},
26
+ });
27
+ export const webvitals = () => {};
28
+ export const logUnhandledErrors = () => {};
@@ -1,5 +1,3 @@
1
- module.exports = {
2
- setCustomUserData: () => {},
3
- setCustomVirtualPageName: () => {},
4
- startVirtualPageMonitoringWithAutoEnd: () => {},
5
- };
1
+ export const setCustomUserData = () => {};
2
+ export const setCustomVirtualPageName = () => {};
3
+ export const startVirtualPageMonitoringWithAutoEnd = () => {};
@@ -1,5 +1,3 @@
1
- module.exports = {
2
- attach: jest.fn(),
3
- detach: jest.fn(),
4
- getConfig: jest.fn(),
5
- };
1
+ export const attach = jest.fn();
2
+ export const detach = jest.fn();
3
+ export const getConfig = jest.fn();
@@ -1,3 +1,5 @@
1
- module.exports = {
2
- ReactComponent: 'IMAGE_MOCK',
3
- };
1
+ // eslint-disable-next-line no-unused-vars
2
+ import * as React from 'react';
3
+
4
+ export default 'SvgrURL';
5
+ export const ReactComponent = 'div';
@@ -3,12 +3,12 @@
3
3
  import 'core-js/stable';
4
4
  import 'regenerator-runtime/runtime';
5
5
  import '@testing-library/jest-dom/extend-expect';
6
- import { toHaveNoViolations } from 'jest-axe';
6
+ import jestAxe from 'jest-axe';
7
7
  import ResizeObserver from 'resize-observer-polyfill';
8
- import addMatchMedia from './mocks/matchMedia';
9
- import { logger } from './mocks/pui-diagnostics';
8
+ import addMatchMedia from './mocks/matchMedia.js';
9
+ import { logger } from './mocks/pui-diagnostics.js';
10
10
 
11
- if (expect) expect.extend(toHaveNoViolations);
11
+ if (expect) expect.extend(jestAxe.toHaveNoViolations);
12
12
  jest.setTimeout(60000);
13
13
 
14
14
  const addElementToBody = (element) => {
@@ -0,0 +1,62 @@
1
+ const esbuild = require('esbuild');
2
+ const fg = require('fast-glob');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const ESBUILD_TARGET = 'es2020';
7
+
8
+ const commonConfig = {
9
+ bundle: false,
10
+ target: ESBUILD_TARGET,
11
+ loader: { '.js': 'jsx' },
12
+ mainFields: ['module', 'browser', 'main'],
13
+ inject: [path.resolve(__dirname, './react-shim.js')],
14
+ };
15
+
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
+ };
28
+
29
+ const build = async ({ srcPath, commonJS }) => {
30
+ const inputFiles = [
31
+ `${srcPath}/**/*.{js,jsx,ts,tsx}`,
32
+ `!${srcPath}/**/*.test.{js,jsx,ts,tsx}`,
33
+ `!${srcPath}/**/*.stories.{js,jsx,ts,tsx}`,
34
+ `!${srcPath}/**/*.endpoint.{js,jsx,ts,tsx}`,
35
+ ];
36
+ if (!commonJS) {
37
+ const outdir = `${distFolder}/es`;
38
+ const entryPoints = await fg(inputFiles);
39
+ await esbuild.build({
40
+ entryPoints,
41
+ ...commonConfig,
42
+ outdir,
43
+ format: 'esm',
44
+ });
45
+ await copyFiles({ srcdir: srcPath, outdir });
46
+ } else {
47
+ const outdir = `${distFolder}/cjs`;
48
+ const commonJSEntryPoints = await fg(
49
+ inputFiles.concat([`${srcPath}/**/*.cjs`]),
50
+ );
51
+ await esbuild.build({
52
+ entryPoints: commonJSEntryPoints,
53
+ ...commonConfig,
54
+ outdir,
55
+ format: 'cjs',
56
+ });
57
+ await copyFiles({ srcdir: srcPath, outdir });
58
+ }
59
+ };
60
+
61
+ exports.esBuild = build;
62
+ exports.ESBUILD_TARGET = ESBUILD_TARGET;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export { React };
@@ -1,5 +1,5 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- exports.isTypeScripEnabled = () =>
4
+ exports.isTypeScriptEnabled = () =>
5
5
  fs.existsSync(path.join(process.cwd(), 'tsconfig.json'));