@elliemae/pui-cli 9.0.0-next.2 → 9.0.0-next.21
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/dist/cjs/commands/lint.js +26 -7
- package/dist/cjs/commands/start.js +1 -1
- package/dist/cjs/commands/storybook.js +2 -2
- package/dist/cjs/commands/test.js +2 -2
- package/dist/cjs/commands/utils.js +3 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/lint-config/eslint/common.cjs +3 -2
- package/dist/cjs/lint-config/eslint/typescript/common.cjs +3 -3
- package/dist/cjs/lint-config/stylelint.config.cjs +14 -13
- package/dist/cjs/monorepo/delete-merged-tags.js +1 -1
- package/dist/cjs/monorepo/set-registry-version.js +1 -1
- package/dist/cjs/monorepo/set-workspace-version.js +1 -1
- package/dist/cjs/pui-config.js +2 -2
- package/dist/cjs/server/csp.js +1 -1
- package/dist/cjs/server/utils.js +2 -2
- package/dist/cjs/testing/ExtendedJSDomEnv.cjs +38 -0
- package/dist/cjs/testing/extended/axe-core/getMessageAndPass.js +37 -0
- package/dist/cjs/testing/extended/axe-core/index.js +24 -0
- package/dist/cjs/testing/extended/axe-core/reporter.js +51 -0
- package/dist/cjs/testing/extended/axe-core/shouldIgnoreNodeViolation.js +31 -0
- package/dist/cjs/testing/extended/axe-core/toHaveNoViolations.js +43 -0
- package/dist/cjs/testing/jest.config.cjs +3 -1
- package/dist/cjs/testing/setup-test-env.js +1 -1
- package/dist/cjs/testing/setup-tests.js +25 -4
- package/dist/cjs/transpile/esbuild.js +4 -2
- package/dist/cjs/update-notifier.js +1 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/webpack/helpers.js +18 -6
- package/dist/cjs/webpack/webpack.base.babel.js +27 -5
- package/dist/cjs/webpack/webpack.dev.babel.js +4 -3
- package/dist/cjs/webpack/webpack.lib.base.babel.js +13 -5
- package/dist/cjs/webpack/webpack.lib.dev.babel.js +5 -11
- package/dist/cjs/webpack/webpack.lib.prod.babel.js +4 -5
- package/dist/cjs/webpack/webpack.prod.babel.js +3 -2
- package/dist/cjs/webpack/webpack.storybook.js +10 -11
- package/dist/esm/commands/lint.js +27 -7
- package/dist/esm/commands/start.js +1 -1
- package/dist/esm/commands/storybook.js +2 -2
- package/dist/esm/commands/test.js +2 -2
- package/dist/esm/commands/utils.js +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/lint-config/eslint/common.cjs +3 -2
- package/dist/esm/lint-config/eslint/typescript/common.cjs +3 -3
- package/dist/esm/lint-config/stylelint.config.cjs +14 -13
- package/dist/esm/monorepo/delete-merged-tags.js +1 -1
- package/dist/esm/monorepo/set-registry-version.js +1 -1
- package/dist/esm/monorepo/set-workspace-version.js +1 -1
- package/dist/esm/server/csp.js +1 -1
- package/dist/esm/server/utils.js +2 -2
- package/dist/esm/testing/ExtendedJSDomEnv.cjs +38 -0
- package/dist/esm/testing/extended/axe-core/getMessageAndPass.js +17 -0
- package/dist/esm/testing/extended/axe-core/index.js +4 -0
- package/dist/esm/testing/extended/axe-core/reporter.js +31 -0
- package/dist/esm/testing/extended/axe-core/shouldIgnoreNodeViolation.js +11 -0
- package/dist/esm/testing/extended/axe-core/toHaveNoViolations.js +23 -0
- package/dist/esm/testing/jest.config.cjs +3 -1
- package/dist/esm/testing/setup-test-env.js +1 -1
- package/dist/esm/testing/setup-tests.js +25 -4
- package/dist/esm/transpile/esbuild.js +4 -2
- package/dist/esm/update-notifier.js +1 -1
- package/dist/esm/utils.js +1 -1
- package/dist/esm/webpack/helpers.js +18 -6
- package/dist/esm/webpack/webpack.base.babel.js +27 -5
- package/dist/esm/webpack/webpack.dev.babel.js +4 -3
- package/dist/esm/webpack/webpack.lib.base.babel.js +13 -5
- package/dist/esm/webpack/webpack.lib.dev.babel.js +6 -12
- package/dist/esm/webpack/webpack.lib.prod.babel.js +9 -6
- package/dist/esm/webpack/webpack.prod.babel.js +3 -2
- package/dist/esm/webpack/webpack.storybook.js +11 -12
- package/dist/types/babel.config.d.cts +7 -7
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/codemod.d.ts +2 -2
- package/dist/types/commands/lint.d.ts +3 -2
- package/dist/types/commands/pack.d.ts +2 -2
- package/dist/types/commands/start.d.ts +2 -2
- package/dist/types/commands/storybook.d.ts +2 -2
- package/dist/types/commands/test.d.ts +2 -2
- package/dist/types/commands/tscheck.d.ts +2 -2
- package/dist/types/commands/utils.d.ts +2 -1
- package/dist/types/commands/version.d.ts +2 -2
- package/dist/types/commands/vitest.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lint-config/commitlint.config.d.cts +1 -1
- package/dist/types/lint-config/eslint/common.d.cts +18 -12
- package/dist/types/lint-config/eslint/non-react.d.cts +8 -1
- package/dist/types/lint-config/eslint/react.d.cts +8 -1
- package/dist/types/lint-config/eslint/typescript/common.d.cts +6 -6
- package/dist/types/lint-config/eslint/typescript/non-react.d.cts +9 -2
- package/dist/types/lint-config/eslint/typescript/react.d.cts +9 -2
- package/dist/types/lint-config/lint-staged.config.d.ts +3 -3
- package/dist/types/lint-config/prettier.config.d.cts +6 -6
- package/dist/types/lint-config/stylelint.config.d.cts +6 -6
- package/dist/types/release.config.d.cts +2 -2
- package/dist/types/server/csp.d.ts +2 -2
- package/dist/types/testing/ExtendedJSDomEnv.d.cts +5 -0
- package/dist/types/testing/extended/axe-core/getMessageAndPass.d.ts +8 -0
- package/dist/types/testing/extended/axe-core/index.d.ts +1 -0
- package/dist/types/testing/extended/axe-core/reporter.d.ts +2 -0
- package/dist/types/testing/extended/axe-core/shouldIgnoreNodeViolation.d.ts +2 -0
- package/dist/types/testing/extended/axe-core/toHaveNoViolations.d.ts +12 -0
- package/dist/types/testing/jest.config.d.cts +24 -22
- package/dist/types/testing/jest.node.config.d.cts +2 -0
- package/dist/types/testing/mocks/axios.d.ts +7 -7
- package/dist/types/testing/mocks/pui-diagnostics.d.ts +13 -13
- package/dist/types/testing/vitest.config.d.ts +1 -1
- package/dist/types/tests/basic.test.d.ts +0 -0
- package/dist/types/transpile/esbuild.d.ts +3 -3
- package/dist/types/typedoc.d.cts +3 -3
- package/dist/types/webpack/helpers.d.ts +4 -1
- package/dist/types/webpack/webpack.storybook.d.ts +0 -1
- package/package.json +151 -140
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { TestEnvironment } = require('jest-environment-jsdom');
|
|
2
|
+
|
|
3
|
+
// ICE platform is meant to be run on node > 18
|
|
4
|
+
// "jest-environment-jsdom": "~29.6.3" is instead meant to support node >16
|
|
5
|
+
// features that are supported since node 17 & 18 are not supported in jsdom env
|
|
6
|
+
// the limitation is not relevant for us since we are already running on node 18 anyway,
|
|
7
|
+
// this "ExtendedJSDomEnv" is an extension of the
|
|
8
|
+
// jest.config.cjs
|
|
9
|
+
// {
|
|
10
|
+
// ...
|
|
11
|
+
// testEnvironment: 'jsdom'
|
|
12
|
+
// ...
|
|
13
|
+
// }
|
|
14
|
+
// that actually uses node 18 features that are not supported in "jest-environment-jsdom": "~29.6.3"
|
|
15
|
+
|
|
16
|
+
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
|
|
17
|
+
class FixJSDOMEnvironment extends TestEnvironment {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
|
|
21
|
+
// From here on we are using "node" (currently running version of it) to polyfill jsdom this.global
|
|
22
|
+
|
|
23
|
+
// FIXME https://github.com/jsdom/jsdom/issues/3363
|
|
24
|
+
if (structuredClone) this.global.structuredClone = structuredClone;
|
|
25
|
+
|
|
26
|
+
// fix: 'TypeError: Failed to parse URL from latest/app.config.json' relative urls not supported in nodejs native fetch, using whatwg-fetch instead
|
|
27
|
+
// // FIXME https://github.com/jsdom/jsdom/issues/1724
|
|
28
|
+
// if (fetch) this.global.fetch = fetch;
|
|
29
|
+
// if (Headers) this.global.Headers = Headers;
|
|
30
|
+
// if (Request) this.global.Request = Request;
|
|
31
|
+
// if (Response) this.global.Response = Response;
|
|
32
|
+
|
|
33
|
+
// // FIXME https://github.com/jsdom/jsdom/issues/1721
|
|
34
|
+
// if (URL) this.global.URL = URL;
|
|
35
|
+
// if (Blob) this.global.Blob = Blob;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
module.exports = FixJSDOMEnvironment;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { matcherHint } from "jest-matcher-utils";
|
|
2
|
+
import { reporter } from "./reporter.js";
|
|
3
|
+
const getMessageAndPass = (violations) => {
|
|
4
|
+
const formatedViolations = reporter(violations);
|
|
5
|
+
const pass = formatedViolations.length === 0;
|
|
6
|
+
if (pass)
|
|
7
|
+
return { message: () => "", pass };
|
|
8
|
+
return {
|
|
9
|
+
message: () => `${matcherHint(".toHaveNoViolations")}
|
|
10
|
+
|
|
11
|
+
${formatedViolations}`,
|
|
12
|
+
pass
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
getMessageAndPass
|
|
17
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { printReceived } from "jest-matcher-utils";
|
|
2
|
+
const colorYellow = (arg) => `\x1B[93m ${arg ?? ""} \x1B[0m`;
|
|
3
|
+
const colorGrey = (arg) => `\x1B[90m ${arg ?? ""} \x1B[0m`;
|
|
4
|
+
const colorBlue = (arg) => `\x1B[34m ${arg ?? ""} \x1B[0m`;
|
|
5
|
+
const reporter = (violToFormat) => {
|
|
6
|
+
if (violToFormat.length === 0)
|
|
7
|
+
return "";
|
|
8
|
+
const lineBreak = "\n\n";
|
|
9
|
+
const horizontalLine = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
10
|
+
return violToFormat.map((violation) => {
|
|
11
|
+
const errorBody = violation.nodes.map((node) => {
|
|
12
|
+
const selector = node.target.join(", ");
|
|
13
|
+
const expectedText = `Expected the HTML found at $('${selector}') to have no violations:${lineBreak}`;
|
|
14
|
+
let violationHelpUrl = "";
|
|
15
|
+
if (violation.helpUrl)
|
|
16
|
+
violationHelpUrl = `You can find more information on this issue here:
|
|
17
|
+
${colorBlue(
|
|
18
|
+
violation.helpUrl
|
|
19
|
+
)}`;
|
|
20
|
+
return `${expectedText + colorGrey(node.html) + lineBreak}Received:${lineBreak}${printReceived(
|
|
21
|
+
`${violation.help} (${violation.id})`
|
|
22
|
+
)}${lineBreak}${colorYellow(
|
|
23
|
+
node.failureSummary
|
|
24
|
+
)}${lineBreak}${violationHelpUrl}`;
|
|
25
|
+
}).join(lineBreak);
|
|
26
|
+
return errorBody;
|
|
27
|
+
}).join(lineBreak + horizontalLine + lineBreak);
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
reporter
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const dataAttributeRegexp = /(data-[\S]*)=["']([\S]*)["']/gm;
|
|
2
|
+
const shouldIgnoreNodeViolation = (node, violation) => [...node.html.matchAll(dataAttributeRegexp)].map(([fullMatch, dataKey, dataValue]) => ({
|
|
3
|
+
fullMatch,
|
|
4
|
+
dataKey,
|
|
5
|
+
dataValue
|
|
6
|
+
})).some(
|
|
7
|
+
({ dataKey, dataValue }) => dataKey === `data-axe-ignore-${violation.id}` && dataValue === "true"
|
|
8
|
+
);
|
|
9
|
+
export {
|
|
10
|
+
shouldIgnoreNodeViolation
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getMessageAndPass } from "./getMessageAndPass.js";
|
|
2
|
+
import { shouldIgnoreNodeViolation } from "./shouldIgnoreNodeViolation.js";
|
|
3
|
+
const toHaveNoViolations = {
|
|
4
|
+
toHaveNoViolations(results) {
|
|
5
|
+
const { violations } = results;
|
|
6
|
+
const finalViolations = [];
|
|
7
|
+
violations.forEach((violation) => {
|
|
8
|
+
const { nodes } = violation;
|
|
9
|
+
const newNodes = [];
|
|
10
|
+
nodes.forEach((node) => {
|
|
11
|
+
if (!shouldIgnoreNodeViolation(node, violation))
|
|
12
|
+
newNodes.push(node);
|
|
13
|
+
});
|
|
14
|
+
if (newNodes.length > 0) {
|
|
15
|
+
finalViolations.push({ ...violation, nodes: newNodes });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return { actual: violations, ...getMessageAndPass(finalViolations) };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
toHaveNoViolations
|
|
23
|
+
};
|
|
@@ -57,6 +57,8 @@ const jestConfig = {
|
|
|
57
57
|
coverageReporters: ['lcov', 'html', 'text-summary'],
|
|
58
58
|
moduleDirectories: ['node_modules', 'app', 'lib'],
|
|
59
59
|
moduleNameMapper: {
|
|
60
|
+
d3: '<rootDir>/node_modules/d3/dist/d3.min.js',
|
|
61
|
+
'^d3-(.*)$': '<rootDir>/node_modules/d3-$1/dist/d3-$1.min.js',
|
|
60
62
|
'.*\\webpack-hmr(.[t|j]s)?$': getMockFilePath('webpack-hmr.js'),
|
|
61
63
|
'.*\\.(css|scss)$': getMockFilePath('cssModule.js'),
|
|
62
64
|
'.*\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$':
|
|
@@ -92,7 +94,7 @@ const jestConfig = {
|
|
|
92
94
|
url: `http://localhost:3111${basePath}`,
|
|
93
95
|
resources: 'usable',
|
|
94
96
|
},
|
|
95
|
-
testEnvironment: '
|
|
97
|
+
testEnvironment: path.resolve(__dirname, './ExtendedJSDomEnv.cjs'),
|
|
96
98
|
watchPlugins: [
|
|
97
99
|
'jest-watch-typeahead/filename',
|
|
98
100
|
'jest-watch-typeahead/testname',
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "core-js/stable";
|
|
2
1
|
import "regenerator-runtime/runtime";
|
|
3
|
-
import "@testing-library/jest-dom/
|
|
4
|
-
import jestAxe from "jest-axe";
|
|
2
|
+
import "@testing-library/jest-dom/jest-globals";
|
|
5
3
|
import ResizeObserver from "resize-observer-polyfill";
|
|
4
|
+
import { toHaveNoViolations } from "./extended/axe-core";
|
|
6
5
|
import { addMatchMedia } from "./mocks/matchMedia.js";
|
|
7
6
|
import { logger } from "./mocks/pui-diagnostics.js";
|
|
8
7
|
const originalError = console.error;
|
|
@@ -25,7 +24,7 @@ console.error = (...args) => {
|
|
|
25
24
|
return originalError(...args);
|
|
26
25
|
};
|
|
27
26
|
if (expect)
|
|
28
|
-
expect.extend(
|
|
27
|
+
expect.extend(toHaveNoViolations);
|
|
29
28
|
const addElementToBody = (element) => {
|
|
30
29
|
const documentEle = (window || {}).document;
|
|
31
30
|
if (!documentEle)
|
|
@@ -49,3 +48,25 @@ window.emui = {
|
|
|
49
48
|
logger: logger(),
|
|
50
49
|
_BASE_PATH: new URL(document.baseURI).pathname
|
|
51
50
|
};
|
|
51
|
+
let showCorejsWarn = false;
|
|
52
|
+
afterAll(() => {
|
|
53
|
+
if (showCorejsWarn) {
|
|
54
|
+
console.warn(
|
|
55
|
+
`IMPORTANT: Try importing core-js/stable in your failed test files and retrying.
|
|
56
|
+
Some tests might have failed because of it`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const originalTest = global.test;
|
|
61
|
+
global.it = (name, fn, timeout = void 0) => {
|
|
62
|
+
const fnWrapper = async () => {
|
|
63
|
+
try {
|
|
64
|
+
await fn();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
showCorejsWarn = true;
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
originalTest(name, fnWrapper, timeout);
|
|
71
|
+
};
|
|
72
|
+
global.it.skip = originalTest.skip;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { writeFile, copyFile, readFile, mkdir } from "node:fs/promises";
|
|
3
4
|
import fg from "fast-glob";
|
|
4
5
|
import { build } from "esbuild";
|
|
5
|
-
import { writeFile, copyFile, readFile, mkdir } from "node:fs/promises";
|
|
6
6
|
import browserslistToEsbuild from "browserslist-to-esbuild";
|
|
7
|
+
import lodashTransformer from "esbuild-plugin-lodash";
|
|
7
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const TARGETS = {
|
|
9
10
|
browserslist: browserslistToEsbuild(),
|
|
@@ -81,7 +82,8 @@ const esBuild = async ({
|
|
|
81
82
|
...getCommonConfig({ injectReactShim }),
|
|
82
83
|
outdir: cjsOutdir,
|
|
83
84
|
format: ESBUILD_FORMAT.CJS,
|
|
84
|
-
target
|
|
85
|
+
target,
|
|
86
|
+
plugins: [lodashTransformer()]
|
|
85
87
|
});
|
|
86
88
|
await copyFiles({ srcdir, outdir: cjsOutdir });
|
|
87
89
|
await createPackageJson({ outdir: cjsOutdir, type: NODE_MODULE_TYPES.CJS });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import updateNotifier from "update-notifier";
|
|
2
1
|
import path from "node:path";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
3
|
+
import updateNotifier from "update-notifier";
|
|
4
4
|
const notifyUpdates = async () => {
|
|
5
5
|
const pkgFile = await fs.readFile(path.join(process.cwd(), "./package.json"));
|
|
6
6
|
const pkg = JSON.parse(pkgFile);
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
const basePath = (process.env.BASE_PATH
|
|
3
|
+
const basePath = (process.env.BASE_PATH ?? "/").replace(/\/?$/, "/");
|
|
4
4
|
const isApp = () => fs.existsSync(path.join(process.cwd(), "app"));
|
|
5
5
|
const getAppConfig = () => {
|
|
6
6
|
const appConfigPath = path.join(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
+
import zlib from "zlib";
|
|
3
4
|
import _ from "lodash";
|
|
4
5
|
import CompressionPlugin from "compression-webpack-plugin";
|
|
5
|
-
import zlib from "zlib";
|
|
6
6
|
import { findMonoRepoRoot } from "../monorepo/utils.js";
|
|
7
7
|
import { basePath, getAppConfig } from "../utils.js";
|
|
8
8
|
let pathSep = path.sep;
|
|
@@ -16,8 +16,8 @@ const excludeNodeModulesExcept = (modules) => {
|
|
|
16
16
|
const moduleRegExps = getNodeModulesRegEx(modules);
|
|
17
17
|
return function(modulePath) {
|
|
18
18
|
if (/node_modules/.test(modulePath)) {
|
|
19
|
-
for (
|
|
20
|
-
if (
|
|
19
|
+
for (const moduleRegExp of moduleRegExps)
|
|
20
|
+
if (moduleRegExp.test(modulePath))
|
|
21
21
|
return false;
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
@@ -32,7 +32,7 @@ const getLibraryName = () => {
|
|
|
32
32
|
const modifiedLibName = `emui-${libraryName.replace("@elliemae/", "").replace("pui-", "")}`;
|
|
33
33
|
return _.camelCase(modifiedLibName);
|
|
34
34
|
};
|
|
35
|
-
const getLibraryVariableName = () => (process.env.LIBRARY_VARIABLE_NAME
|
|
35
|
+
const getLibraryVariableName = () => (process.env.LIBRARY_VARIABLE_NAME ?? getLibraryName()).split(".");
|
|
36
36
|
const mapToFolder = (dependencies, folder) => dependencies.reduce(
|
|
37
37
|
(acc, dependency) => ({
|
|
38
38
|
[dependency]: path.resolve(`${folder}/${dependency.replace("$", "")}`),
|
|
@@ -41,7 +41,7 @@ const mapToFolder = (dependencies, folder) => dependencies.reduce(
|
|
|
41
41
|
{}
|
|
42
42
|
);
|
|
43
43
|
const getAlias = () => {
|
|
44
|
-
const monorepoRoot = findMonoRepoRoot(process.cwd())
|
|
44
|
+
const monorepoRoot = findMonoRepoRoot(process.cwd()) ?? "";
|
|
45
45
|
return mapToFolder(
|
|
46
46
|
[
|
|
47
47
|
"@babel/runtime",
|
|
@@ -55,6 +55,8 @@ const getAlias = () => {
|
|
|
55
55
|
"styled-components",
|
|
56
56
|
"immer",
|
|
57
57
|
"react-dates",
|
|
58
|
+
"react-select",
|
|
59
|
+
"react-spring",
|
|
58
60
|
"react-transition-group",
|
|
59
61
|
"@elliemae/pui-cli",
|
|
60
62
|
"@elliemae/pui-app-sdk$",
|
|
@@ -63,6 +65,15 @@ const getAlias = () => {
|
|
|
63
65
|
path.join(monorepoRoot, "./node_modules")
|
|
64
66
|
);
|
|
65
67
|
};
|
|
68
|
+
const getLibraryAlias = (name, alias) => {
|
|
69
|
+
const monorepoRoot = findMonoRepoRoot(process.cwd()) ?? "";
|
|
70
|
+
const aliasPath = path.resolve(
|
|
71
|
+
`${path.join(monorepoRoot, "./node_modules")}/${alias}`
|
|
72
|
+
);
|
|
73
|
+
return {
|
|
74
|
+
[name]: aliasPath
|
|
75
|
+
};
|
|
76
|
+
};
|
|
66
77
|
const modulesToTranspile = [
|
|
67
78
|
"@elliemae/pui-*",
|
|
68
79
|
"@elliemae/ds-*",
|
|
@@ -125,7 +136,7 @@ const getAppVersion = () => {
|
|
|
125
136
|
if (!process.env.APP_VERSION)
|
|
126
137
|
return LATEST_VERSION;
|
|
127
138
|
const match = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
|
|
128
|
-
return match
|
|
139
|
+
return match?.[1] ?? LATEST_VERSION;
|
|
129
140
|
};
|
|
130
141
|
const getPaths = (latestVersion = true) => {
|
|
131
142
|
const version = latestVersion ? LATEST_VERSION : getAppVersion();
|
|
@@ -202,6 +213,7 @@ export {
|
|
|
202
213
|
getAlias,
|
|
203
214
|
getAppVersion,
|
|
204
215
|
getCompressionPlugins,
|
|
216
|
+
getLibraryAlias,
|
|
205
217
|
getLibraryName,
|
|
206
218
|
getLibraryVariableName,
|
|
207
219
|
getMediaPath,
|
|
@@ -257,17 +257,39 @@ const baseConfig = (options) => ({
|
|
|
257
257
|
mainFields: ["browser", "module", "main"],
|
|
258
258
|
alias: {
|
|
259
259
|
...getAlias(),
|
|
260
|
-
...
|
|
260
|
+
...options.resolve?.alias ?? {}
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
|
+
externalsPresets: {
|
|
264
|
+
web: true
|
|
265
|
+
},
|
|
263
266
|
externals: {
|
|
264
267
|
"@elliemae/pui-user-monitoring": "emuiUserMonitoring",
|
|
265
268
|
"@elliemae/pui-app-loader": "emuiAppLoader",
|
|
266
|
-
"@elliemae/pui-diagnostics": "emuiDiagnostics"
|
|
269
|
+
"@elliemae/pui-diagnostics": "emuiDiagnostics",
|
|
270
|
+
react: "emuiAppReactDependencies.react",
|
|
271
|
+
"react-dom": "emuiAppReactDependencies.reactDOM",
|
|
272
|
+
"@reduxjs/toolkit": "emuiAppReactDependencies.rtk",
|
|
273
|
+
axios: "emuiAppReactDependencies.axios.default",
|
|
274
|
+
dompurify: "emuiAppReactDependencies.dompurify",
|
|
275
|
+
history: "emuiAppReactDependencies.history",
|
|
276
|
+
immer: "emuiAppReactDependencies.immer",
|
|
277
|
+
invariant: "emuiAppReactDependencies.invariant",
|
|
278
|
+
"pubsub-js": "emuiAppReactDependencies.pubsubjs",
|
|
279
|
+
"react-aria-live": "emuiAppReactDependencies.reactAriaLive",
|
|
280
|
+
"react-helmet": "emuiAppReactDependencies.reactHelmet",
|
|
281
|
+
"react-hook-form": "emuiAppReactDependencies.reactHookForm",
|
|
282
|
+
"react-redux": "emuiAppReactDependencies.reactRedux",
|
|
283
|
+
"react-router-dom": "emuiAppReactDependencies.reactRouterDOM",
|
|
284
|
+
reduxInjectors: "emuiAppReactDependencies.reduxInjectors",
|
|
285
|
+
reselect: "emuiAppReactDependencies.reselect",
|
|
286
|
+
// "styled-components": "emuiAppReactDependencies.styledComponents",
|
|
287
|
+
"styled-system": "emuiAppReactDependencies.styledSystem"
|
|
288
|
+
// "@xstyled/styled-components": "emuiAppReactDependencies.xstyled",
|
|
267
289
|
},
|
|
268
|
-
devtool: options.devtool
|
|
269
|
-
performance: options.performance
|
|
270
|
-
devServer: options.devServer
|
|
290
|
+
devtool: options.devtool ?? "eval-source-map",
|
|
291
|
+
performance: options.performance ?? {},
|
|
292
|
+
devServer: options.devServer ?? {}
|
|
271
293
|
});
|
|
272
294
|
export {
|
|
273
295
|
baseConfig
|
|
@@ -68,7 +68,7 @@ const devConfig = {
|
|
|
68
68
|
// Add development plugins
|
|
69
69
|
plugins: [
|
|
70
70
|
new HtmlWebpackPlugin({
|
|
71
|
-
inject: !isAppLoaderEnabled(),
|
|
71
|
+
inject: !isAppLoaderEnabled() ? "head" : false,
|
|
72
72
|
// Inject all files that are generated by webpack, e.g. bundle.js
|
|
73
73
|
template: !isAppLoaderEnabled() ? "app/index.html" : "app/index-app-loader.html",
|
|
74
74
|
emui: {
|
|
@@ -80,7 +80,8 @@ const devConfig = {
|
|
|
80
80
|
diagnosticsScriptPath,
|
|
81
81
|
encwLoaderScriptPath,
|
|
82
82
|
googleTagManager: isGoogleTagManagerEnabled()
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
|
+
scriptLoading: "defer"
|
|
84
85
|
}),
|
|
85
86
|
new CircularDependencyPlugin({
|
|
86
87
|
exclude: /a\.(js|ts|jsx|tsx)|node_modules/,
|
|
@@ -113,7 +114,7 @@ const devConfig = {
|
|
|
113
114
|
},
|
|
114
115
|
hot: true,
|
|
115
116
|
open: [basePath],
|
|
116
|
-
port: process.env.PORT
|
|
117
|
+
port: process.env.PORT ?? "auto",
|
|
117
118
|
setupMiddlewares: (middlewares, devServer) => {
|
|
118
119
|
if (devServer.app) {
|
|
119
120
|
setupDefaultMiddlewares(devServer.app);
|
|
@@ -57,14 +57,22 @@ const baseConfig = (options) => ({
|
|
|
57
57
|
output: {
|
|
58
58
|
clean: true,
|
|
59
59
|
path: path.resolve(process.cwd(), "dist/umd"),
|
|
60
|
+
filename: "[name].js",
|
|
61
|
+
chunkFilename: "[name].[chunkhash].chunk.js",
|
|
62
|
+
assetModuleFilename: "assets/[name].[hash][ext][query]",
|
|
60
63
|
publicPath: "auto",
|
|
61
64
|
library: {
|
|
62
65
|
name: getLibraryVariableName(),
|
|
63
|
-
type: "
|
|
66
|
+
type: "var"
|
|
67
|
+
// type: 'module',
|
|
64
68
|
},
|
|
69
|
+
// module: true,
|
|
65
70
|
...options.output
|
|
66
71
|
},
|
|
67
72
|
// Merge with env dependent settings
|
|
73
|
+
// experiments: {
|
|
74
|
+
// outputModule: true,
|
|
75
|
+
// },
|
|
68
76
|
optimization: options.optimization,
|
|
69
77
|
module: {
|
|
70
78
|
rules: [
|
|
@@ -177,7 +185,7 @@ const baseConfig = (options) => ({
|
|
|
177
185
|
mainFields: ["browser", "module", "main"],
|
|
178
186
|
alias: {
|
|
179
187
|
...getAlias(),
|
|
180
|
-
...
|
|
188
|
+
...options.resolve?.alias ?? {}
|
|
181
189
|
},
|
|
182
190
|
plugins: [new ResolveTypeScriptPlugin({})]
|
|
183
191
|
},
|
|
@@ -186,9 +194,9 @@ const baseConfig = (options) => ({
|
|
|
186
194
|
"@elliemae/pui-app-loader": "emuiAppLoader",
|
|
187
195
|
"@elliemae/pui-diagnostics": "emuiDiagnostics"
|
|
188
196
|
},
|
|
189
|
-
devtool: options.devtool
|
|
190
|
-
performance: options.performance
|
|
191
|
-
devServer: options.devServer
|
|
197
|
+
devtool: options.devtool ?? "eval-source-map",
|
|
198
|
+
performance: options.performance ?? {},
|
|
199
|
+
devServer: options.devServer ?? {}
|
|
192
200
|
});
|
|
193
201
|
export {
|
|
194
202
|
baseConfig
|
|
@@ -5,7 +5,7 @@ import fg from "fast-glob";
|
|
|
5
5
|
import CircularDependencyPlugin from "circular-dependency-plugin";
|
|
6
6
|
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
7
7
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
8
|
-
import { getPaths } from "./helpers.js";
|
|
8
|
+
import { getPaths, getLibraryVariableName } from "./helpers.js";
|
|
9
9
|
import { baseConfig } from "./webpack.lib.base.babel.js";
|
|
10
10
|
const { basePath } = getPaths();
|
|
11
11
|
const getHtmlWebpackPlugins = () => {
|
|
@@ -14,17 +14,14 @@ const getHtmlWebpackPlugins = () => {
|
|
|
14
14
|
(htmlTemplateFile) => new HtmlWebpackPlugin({
|
|
15
15
|
template: htmlTemplateFile,
|
|
16
16
|
filename: path.basename(htmlTemplateFile),
|
|
17
|
-
inject:
|
|
17
|
+
inject: "head",
|
|
18
|
+
scriptLoading: "defer",
|
|
19
|
+
library: getLibraryVariableName()
|
|
18
20
|
})
|
|
19
21
|
);
|
|
20
22
|
};
|
|
21
23
|
var webpack_lib_dev_babel_default = baseConfig({
|
|
22
24
|
mode: "development",
|
|
23
|
-
// output: {
|
|
24
|
-
// filename: `js/${libraryName}.js`,
|
|
25
|
-
// chunkFilename: `js/${libraryName}.chunk.js`,
|
|
26
|
-
// assetModuleFilename: '[name][ext][query]',
|
|
27
|
-
// },
|
|
28
25
|
optimization: {
|
|
29
26
|
splitChunks: {
|
|
30
27
|
chunks: "all"
|
|
@@ -41,10 +38,7 @@ var webpack_lib_dev_babel_default = baseConfig({
|
|
|
41
38
|
failOnError: false
|
|
42
39
|
// show a warning when there is a circular dependency
|
|
43
40
|
}),
|
|
44
|
-
new MiniCssExtractPlugin({
|
|
45
|
-
// filename: `css/${libraryName}.css`,
|
|
46
|
-
// chunkFilename: `css/${libraryName}.chunk.css`,
|
|
47
|
-
}),
|
|
41
|
+
new MiniCssExtractPlugin({}),
|
|
48
42
|
new webpack.ProgressPlugin()
|
|
49
43
|
],
|
|
50
44
|
devtool: "eval-source-map",
|
|
@@ -62,7 +56,7 @@ var webpack_lib_dev_babel_default = baseConfig({
|
|
|
62
56
|
historyApiFallback: true,
|
|
63
57
|
hot: true,
|
|
64
58
|
open: [basePath],
|
|
65
|
-
port: process.env.PORT
|
|
59
|
+
port: process.env.PORT ?? "auto",
|
|
66
60
|
headers: {
|
|
67
61
|
"Access-Control-Allow-Origin": "*",
|
|
68
62
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS"
|
|
@@ -5,7 +5,11 @@ import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
|
5
5
|
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
6
6
|
import { EsbuildPlugin } from "esbuild-loader";
|
|
7
7
|
import browserslistToEsbuild from "browserslist-to-esbuild";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getCompressionPlugins,
|
|
10
|
+
getLibraryName,
|
|
11
|
+
getLibraryVariableName
|
|
12
|
+
} from "./helpers.js";
|
|
9
13
|
import { baseConfig } from "./webpack.lib.base.babel.js";
|
|
10
14
|
const getHtmlWebpackPlugins = () => {
|
|
11
15
|
const htmlTemplateFiles = fg.sync([path.join(process.cwd(), "lib/*.html")]);
|
|
@@ -13,7 +17,9 @@ const getHtmlWebpackPlugins = () => {
|
|
|
13
17
|
(htmlTemplateFile) => new HtmlWebpackPlugin({
|
|
14
18
|
template: htmlTemplateFile,
|
|
15
19
|
filename: path.basename(htmlTemplateFile),
|
|
16
|
-
inject:
|
|
20
|
+
inject: "head",
|
|
21
|
+
scriptLoading: "defer",
|
|
22
|
+
library: getLibraryVariableName(),
|
|
17
23
|
minify: {
|
|
18
24
|
removeComments: true,
|
|
19
25
|
collapseWhitespace: true,
|
|
@@ -49,10 +55,7 @@ const prodConfig = {
|
|
|
49
55
|
},
|
|
50
56
|
plugins: [
|
|
51
57
|
...getHtmlWebpackPlugins(),
|
|
52
|
-
new MiniCssExtractPlugin({
|
|
53
|
-
// filename: `css/${libraryName}.[contenthash].css`,
|
|
54
|
-
// chunkFilename: `css/${libraryName}.[contenthash].chunk.css`,
|
|
55
|
-
}),
|
|
58
|
+
new MiniCssExtractPlugin({}),
|
|
56
59
|
...getCompressionPlugins(true),
|
|
57
60
|
new BundleAnalyzerPlugin({
|
|
58
61
|
analyzerMode: "static",
|
|
@@ -83,7 +83,7 @@ const {
|
|
|
83
83
|
basePath
|
|
84
84
|
} = getPaths();
|
|
85
85
|
const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
86
|
-
inject: !isAppLoaderEnabled(),
|
|
86
|
+
inject: !isAppLoaderEnabled() ? "head" : false,
|
|
87
87
|
template: !isAppLoaderEnabled() ? "app/index.html" : "app/index-app-loader.html",
|
|
88
88
|
minify: {
|
|
89
89
|
removeComments: true,
|
|
@@ -106,7 +106,8 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
|
|
|
106
106
|
diagnosticsScriptPath,
|
|
107
107
|
encwLoaderScriptPath,
|
|
108
108
|
googleTagManager: isGoogleTagManagerEnabled()
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
|
+
scriptLoading: "defer"
|
|
110
111
|
});
|
|
111
112
|
const config = baseConfig(getProdConfig());
|
|
112
113
|
if (config.plugins)
|
|
@@ -2,7 +2,7 @@ import webpack from "webpack";
|
|
|
2
2
|
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
3
3
|
import CopyWebpackPlugin from "copy-webpack-plugin";
|
|
4
4
|
import ResolveTypeScriptPlugin from "resolve-typescript-plugin";
|
|
5
|
-
import { getAlias, getCompressionPlugins } from "./helpers.js";
|
|
5
|
+
import { getAlias, getLibraryAlias, getCompressionPlugins } from "./helpers.js";
|
|
6
6
|
import { isApp } from "../utils.js";
|
|
7
7
|
const IS_APP = isApp();
|
|
8
8
|
const CWD = process.cwd();
|
|
@@ -63,15 +63,22 @@ const webpackFinal = (config, { configType }) => {
|
|
|
63
63
|
config.plugins = config?.plugins?.concat(getCompressionPlugins());
|
|
64
64
|
}
|
|
65
65
|
if (config.resolve) {
|
|
66
|
-
config.resolve.alias = {
|
|
66
|
+
config.resolve.alias = {
|
|
67
|
+
...config?.resolve?.alias,
|
|
68
|
+
...getAlias(),
|
|
69
|
+
...getLibraryAlias(
|
|
70
|
+
"@reduxjs/toolkit/query/react",
|
|
71
|
+
"@reduxjs/toolkit/dist/query/react/rtk-query-react.esm.js"
|
|
72
|
+
)
|
|
73
|
+
};
|
|
67
74
|
config.resolve.fallback = { ...config.resolve.fallback, crypto: false };
|
|
68
75
|
config.resolve.extensions?.push(".svg");
|
|
69
76
|
config.resolve.plugins = [
|
|
70
|
-
...config.resolve.plugins
|
|
77
|
+
...config.resolve.plugins ?? [],
|
|
71
78
|
new ResolveTypeScriptPlugin({})
|
|
72
79
|
];
|
|
73
80
|
}
|
|
74
|
-
config.externals = config.externals
|
|
81
|
+
config.externals = config.externals ?? {};
|
|
75
82
|
if (config.externals) {
|
|
76
83
|
config.externals["@elliemae/pui-user-monitoring"] = "emuiUserMonitoring";
|
|
77
84
|
config.externals["@elliemae/pui-app-loader"] = "emuiAppLoader";
|
|
@@ -79,14 +86,6 @@ const webpackFinal = (config, { configType }) => {
|
|
|
79
86
|
}
|
|
80
87
|
return config;
|
|
81
88
|
};
|
|
82
|
-
const managerWebpack = (config) => {
|
|
83
|
-
if (config.plugins)
|
|
84
|
-
config.plugins = config.plugins.concat(getCompressionPlugins());
|
|
85
|
-
if (config.resolve)
|
|
86
|
-
config.resolve.alias = { ...config.resolve.alias, ...getAlias() };
|
|
87
|
-
return config;
|
|
88
|
-
};
|
|
89
89
|
export {
|
|
90
|
-
managerWebpack,
|
|
91
90
|
webpackFinal
|
|
92
91
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { config as babelConfig };
|
|
2
2
|
declare namespace config {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
let ignore: RegExp[];
|
|
4
|
+
let sourceType: string;
|
|
5
|
+
let presets: (string | (string | {
|
|
6
6
|
modules: string | boolean;
|
|
7
7
|
targets: {
|
|
8
8
|
node: string;
|
|
@@ -17,7 +17,7 @@ declare namespace config {
|
|
|
17
17
|
})[] | (string | {
|
|
18
18
|
runtime: string;
|
|
19
19
|
})[])[];
|
|
20
|
-
|
|
20
|
+
let plugins: (string | (string | {
|
|
21
21
|
alias: {
|
|
22
22
|
'@': string;
|
|
23
23
|
};
|
|
@@ -29,13 +29,13 @@ declare namespace config {
|
|
|
29
29
|
})[])[];
|
|
30
30
|
namespace env {
|
|
31
31
|
namespace development {
|
|
32
|
-
|
|
32
|
+
let plugins_1: (string | (string | {
|
|
33
33
|
displayName: boolean;
|
|
34
34
|
})[])[];
|
|
35
35
|
export { plugins_1 as plugins };
|
|
36
36
|
}
|
|
37
37
|
namespace production {
|
|
38
|
-
|
|
38
|
+
let plugins_2: (string | (string | {
|
|
39
39
|
displayName: boolean;
|
|
40
40
|
pure: boolean;
|
|
41
41
|
})[] | (string | {
|
|
@@ -44,7 +44,7 @@ declare namespace config {
|
|
|
44
44
|
export { plugins_2 as plugins };
|
|
45
45
|
}
|
|
46
46
|
namespace test {
|
|
47
|
-
|
|
47
|
+
let plugins_3: (string | (string | {
|
|
48
48
|
displayName: boolean;
|
|
49
49
|
})[] | (string | {
|
|
50
50
|
requireDirective: boolean;
|