@elliemae/pui-cli 7.0.0-alpha.28 → 7.0.0-alpha.30

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 (62) hide show
  1. package/dist/cjs/cli.js +4 -1
  2. package/dist/cjs/commands/build.js +10 -2
  3. package/dist/cjs/commands/codemod.js +4 -1
  4. package/dist/cjs/commands/gendoc.js +4 -1
  5. package/dist/cjs/commands/lint.js +10 -2
  6. package/dist/cjs/commands/pack.js +12 -3
  7. package/dist/cjs/commands/start.js +16 -3
  8. package/dist/cjs/commands/storybook.js +10 -3
  9. package/dist/cjs/commands/test.js +7 -2
  10. package/dist/cjs/commands/tscheck.js +15 -4
  11. package/dist/cjs/commands/utils.js +17 -10
  12. package/dist/cjs/commands/version.js +7 -2
  13. package/dist/cjs/commands/vitest.js +7 -2
  14. package/dist/cjs/lint-config/lint-staged.config.js +4 -1
  15. package/dist/cjs/monorepo/set-registry-version.js +12 -7
  16. package/dist/cjs/monorepo/set-workspace-version.js +19 -8
  17. package/dist/cjs/pui-config.js +4 -1
  18. package/dist/cjs/server/csp.js +24 -19
  19. package/dist/cjs/server/index.js +4 -1
  20. package/dist/cjs/server/logger.js +11 -4
  21. package/dist/cjs/server/middlewares.js +12 -6
  22. package/dist/cjs/server/utils.js +8 -2
  23. package/dist/cjs/testing/mocks/svg.js +4 -1
  24. package/dist/cjs/testing/setup-react-env.js +4 -1
  25. package/dist/cjs/testing/setup-test-env.js +4 -1
  26. package/dist/cjs/testing/setup-tests.js +7 -2
  27. package/dist/cjs/testing/vitest.config.js +4 -1
  28. package/dist/cjs/transpile/esbuild.js +23 -12
  29. package/dist/cjs/transpile/react-shim.js +4 -1
  30. package/dist/cjs/update-notifier.js +4 -1
  31. package/dist/cjs/webpack/helpers.js +68 -33
  32. package/dist/cjs/webpack/webpack.base.babel.js +4 -1
  33. package/dist/cjs/webpack/webpack.dev.babel.js +4 -1
  34. package/dist/cjs/webpack/webpack.lib.base.babel.js +4 -1
  35. package/dist/cjs/webpack/webpack.lib.dev.babel.js +18 -7
  36. package/dist/cjs/webpack/webpack.lib.prod.babel.js +29 -19
  37. package/dist/cjs/webpack/webpack.prod.babel.js +10 -5
  38. package/dist/cjs/webpack/webpack.storybook.js +7 -2
  39. package/dist/esm/commands/build.js +6 -1
  40. package/dist/esm/commands/lint.js +6 -1
  41. package/dist/esm/commands/pack.js +8 -2
  42. package/dist/esm/commands/start.js +12 -2
  43. package/dist/esm/commands/storybook.js +6 -2
  44. package/dist/esm/commands/test.js +3 -1
  45. package/dist/esm/commands/tscheck.js +11 -3
  46. package/dist/esm/commands/utils.js +13 -9
  47. package/dist/esm/commands/version.js +3 -1
  48. package/dist/esm/commands/vitest.js +3 -1
  49. package/dist/esm/monorepo/set-registry-version.js +8 -6
  50. package/dist/esm/monorepo/set-workspace-version.js +15 -7
  51. package/dist/esm/server/csp.js +20 -18
  52. package/dist/esm/server/logger.js +7 -3
  53. package/dist/esm/server/middlewares.js +8 -5
  54. package/dist/esm/server/utils.js +4 -1
  55. package/dist/esm/testing/setup-tests.js +3 -1
  56. package/dist/esm/transpile/esbuild.js +19 -11
  57. package/dist/esm/webpack/helpers.js +64 -32
  58. package/dist/esm/webpack/webpack.lib.dev.babel.js +14 -6
  59. package/dist/esm/webpack/webpack.lib.prod.babel.js +25 -18
  60. package/dist/esm/webpack/webpack.prod.babel.js +6 -4
  61. package/dist/esm/webpack/webpack.storybook.js +3 -1
  62. package/package.json +24 -23
@@ -6,7 +6,10 @@ const randomChars = () => Math.random().toString(36).slice(2);
6
6
  const validateTypescript = async (files = []) => {
7
7
  const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
8
8
  const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath));
9
- const tmpTsconfigPath = path.join(process.cwd(), `tsconfig.${randomChars()}.json`);
9
+ const tmpTsconfigPath = path.join(
10
+ process.cwd(),
11
+ `tsconfig.${randomChars()}.json`
12
+ );
10
13
  const tmpTsconfig = {
11
14
  ...tsconfig,
12
15
  compilerOptions: {
@@ -17,9 +20,14 @@ const validateTypescript = async (files = []) => {
17
20
  include: ["app", "lib"]
18
21
  };
19
22
  fs.writeFileSync(tmpTsconfigPath, JSON.stringify(tmpTsconfig, null, 2));
20
- const tscPath = path.resolve(process.cwd(), `./node_modules/.bin/tsc${process.platform === "win32" ? ".cmd" : ""}`);
23
+ const tscPath = path.resolve(
24
+ process.cwd(),
25
+ `./node_modules/.bin/tsc${process.platform === "win32" ? ".cmd" : ""}`
26
+ );
21
27
  try {
22
- await exec(`${tscPath} -p ${tmpTsconfigPath} --noEmit --emitDeclarationOnly false`);
28
+ await exec(
29
+ `${tscPath} -p ${tmpTsconfigPath} --noEmit --emitDeclarationOnly false`
30
+ );
23
31
  } finally {
24
32
  fs.unlinkSync(tmpTsconfigPath);
25
33
  }
@@ -50,7 +50,9 @@ const getModulesInfo = async () => {
50
50
  return {
51
51
  react: getModuleVersion("react"),
52
52
  "react-dom": getModuleVersion("react-dom"),
53
- "app-react-dependencies": getModuleVersion("@elliemae/app-react-dependencies"),
53
+ "app-react-dependencies": getModuleVersion(
54
+ "@elliemae/app-react-dependencies"
55
+ ),
54
56
  "app-sdk": getModuleVersion("@elliemae/pui-app-sdk"),
55
57
  cli: getModuleVersion("@elliemae/pui-cli"),
56
58
  dimsum: getModuleVersion("@elliemae/ds-system")
@@ -85,14 +87,16 @@ const copyDir = async (src, dest) => {
85
87
  withFileTypes: true
86
88
  });
87
89
  await mkdir(dest);
88
- return Promise.all(entries.map((entry) => {
89
- const srcPath = path.join(src, entry.name);
90
- const destPath = path.join(dest, entry.name);
91
- if (entry.isDirectory()) {
92
- return copyDir(srcPath, destPath);
93
- }
94
- return copyFile(srcPath, destPath);
95
- }));
90
+ return Promise.all(
91
+ entries.map((entry) => {
92
+ const srcPath = path.join(src, entry.name);
93
+ const destPath = path.join(dest, entry.name);
94
+ if (entry.isDirectory()) {
95
+ return copyDir(srcPath, destPath);
96
+ }
97
+ return copyFile(srcPath, destPath);
98
+ })
99
+ );
96
100
  };
97
101
  const updateManifestWithVersionInfo = async (dest) => {
98
102
  const manifestFile = path.join(dest, "manifest.json");
@@ -4,7 +4,9 @@ import { setWorkspaceVersion } from "../monorepo/set-workspace-version.js";
4
4
  import { setRegistryVersion } from "../monorepo/set-registry-version.js";
5
5
  import { deleteMergedTags } from "../monorepo/delete-merged-tags.js";
6
6
  const version = async (lernaOptions = "") => {
7
- await exec(`cross-env NODE_ENV=production lerna version --conventional-commits --exact --create-release github --force-publish --yes ${lernaOptions}`);
7
+ await exec(
8
+ `cross-env NODE_ENV=production lerna version --conventional-commits --exact --create-release github --force-publish --yes ${lernaOptions}`
9
+ );
8
10
  };
9
11
  const versionCmd = {
10
12
  handler: async (argv) => {
@@ -6,7 +6,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
  const { CI = false } = process.env;
7
7
  const configPath = path.resolve(__dirname, "../testing/vitest.config.js");
8
8
  const test = async (commandOptions) => {
9
- await exec(`cross-env FORCE_COLOR=true vitest --config ${configPath} ${commandOptions}`);
9
+ await exec(
10
+ `cross-env FORCE_COLOR=true vitest --config ${configPath} ${commandOptions}`
11
+ );
10
12
  };
11
13
  const vitestCmd = {
12
14
  handler: async (argv) => {
@@ -9,12 +9,14 @@ const setRegistryVersion = async () => {
9
9
  `${monorepoRoot}/apps/*/package.json`,
10
10
  `${monorepoRoot}/package.json`
11
11
  ]);
12
- Promise.all(files.map(async (file) => {
13
- let pkgJSONData = await readFile(file, "utf8");
14
- const pkgVersion = JSON.parse(pkgJSONData).version;
15
- pkgJSONData = pkgJSONData.replace(/workspace:\*/g, pkgVersion);
16
- await writeFile(file, pkgJSONData);
17
- }));
12
+ Promise.all(
13
+ files.map(async (file) => {
14
+ let pkgJSONData = await readFile(file, "utf8");
15
+ const pkgVersion = JSON.parse(pkgJSONData).version;
16
+ pkgJSONData = pkgJSONData.replace(/workspace:\*/g, pkgVersion);
17
+ await writeFile(file, pkgJSONData);
18
+ })
19
+ );
18
20
  };
19
21
  export {
20
22
  setRegistryVersion
@@ -9,13 +9,21 @@ const setWorkspaceVersion = async () => {
9
9
  `${monorepoRoot}/apps/*/package.json`,
10
10
  `${monorepoRoot}/package.json`
11
11
  ]);
12
- Promise.all(files.map(async (file) => {
13
- let pkgJSONData = await readFile(file, "utf8");
14
- const pkgVersion = JSON.parse(pkgJSONData).version;
15
- pkgJSONData = pkgJSONData.replace(new RegExp(pkgVersion, "g"), "workspace:*");
16
- pkgJSONData = pkgJSONData.replace(/"version": "workspace:\*"/g, `"version": "${pkgVersion}"`);
17
- await writeFile(file, pkgJSONData);
18
- }));
12
+ Promise.all(
13
+ files.map(async (file) => {
14
+ let pkgJSONData = await readFile(file, "utf8");
15
+ const pkgVersion = JSON.parse(pkgJSONData).version;
16
+ pkgJSONData = pkgJSONData.replace(
17
+ new RegExp(pkgVersion, "g"),
18
+ "workspace:*"
19
+ );
20
+ pkgJSONData = pkgJSONData.replace(
21
+ /"version": "workspace:\*"/g,
22
+ `"version": "${pkgVersion}"`
23
+ );
24
+ await writeFile(file, pkgJSONData);
25
+ })
26
+ );
19
27
  };
20
28
  export {
21
29
  setWorkspaceVersion
@@ -41,24 +41,26 @@ const csp = (app) => {
41
41
  res.locals.cspNonce = crypto.randomBytes(16).toString("hex");
42
42
  next();
43
43
  });
44
- app.use(cspPolicy({
45
- directives: {
46
- defaultSrc: ["'self'"],
47
- baseUri: ["'self'"],
48
- blockAllMixedContent: [],
49
- connectSrc: sources,
50
- fontSrc: sources.concat(["data:"]),
51
- frameAncestors: sources,
52
- imgSrc: sources.concat(["data:"]),
53
- objectSrc: ["'none'"],
54
- scriptSrc: getScriptSrc(),
55
- scriptSrcAttr: ["'none'"],
56
- styleSrc: sources.concat(["'unsafe-inline'"]),
57
- upgradeInsecureRequests: [],
58
- reportUri: "/v1/csp"
59
- },
60
- reportOnly: true
61
- }));
44
+ app.use(
45
+ cspPolicy({
46
+ directives: {
47
+ defaultSrc: ["'self'"],
48
+ baseUri: ["'self'"],
49
+ blockAllMixedContent: [],
50
+ connectSrc: sources,
51
+ fontSrc: sources.concat(["data:"]),
52
+ frameAncestors: sources,
53
+ imgSrc: sources.concat(["data:"]),
54
+ objectSrc: ["'none'"],
55
+ scriptSrc: getScriptSrc(),
56
+ scriptSrcAttr: ["'none'"],
57
+ styleSrc: sources.concat(["'unsafe-inline'"]),
58
+ upgradeInsecureRequests: [],
59
+ reportUri: "/v1/csp"
60
+ },
61
+ reportOnly: true
62
+ })
63
+ );
62
64
  };
63
65
  export {
64
66
  csp,
@@ -12,14 +12,18 @@ const logger = {
12
12
  }
13
13
  const accessUrls = `${chalk.bold("Access URLs:")}${divider}
14
14
  `;
15
- const localHostUrl = `Localhost: ${chalk.magenta(`http://${host}:${port}`)}
15
+ const localHostUrl = `Localhost: ${chalk.magenta(
16
+ `http://${host}:${port}`
17
+ )}
16
18
  `;
17
19
  const lanUrl = `LAN: ${chalk.magenta(`http://${ip.address()}:${port}`)}
18
20
  `;
19
21
  const proxy = tunnelStarted ? `
20
22
  Proxy: ${chalk.magenta(tunnelStarted)}` : "";
21
- console.log(`${accessUrls}${localHostUrl}${lanUrl}${proxy}${divider}${chalk.blue(`
22
- Press ${chalk.italic("CTRL-C")} to stop`)}
23
+ console.log(`${accessUrls}${localHostUrl}${lanUrl}${proxy}${divider}${chalk.blue(
24
+ `
25
+ Press ${chalk.italic("CTRL-C")} to stop`
26
+ )}
23
27
  `);
24
28
  }
25
29
  };
@@ -31,11 +31,14 @@ const setupAdditionalMiddlewars = (app, options = {}) => {
31
31
  app.get(basePath, (req, res) => {
32
32
  sendFileWithCSPNonce({ buildPath, res });
33
33
  });
34
- app.use(basePath, expressStaticGzip(buildPath, {
35
- index: false,
36
- enableBrotli: true,
37
- orderPreference: ["br"]
38
- }));
34
+ app.use(
35
+ basePath,
36
+ expressStaticGzip(buildPath, {
37
+ index: false,
38
+ enableBrotli: true,
39
+ orderPreference: ["br"]
40
+ })
41
+ );
39
42
  app.use(expressStaticGzip("cdn"));
40
43
  app.get("*", (req, res) => sendFileWithCSPNonce({ buildPath, res }));
41
44
  return app;
@@ -1,7 +1,10 @@
1
1
  import minimist from "minimist";
2
2
  const argv = minimist(process.argv.slice(2));
3
3
  const getCWD = () => process.cwd();
4
- const port = parseInt(argv.port || process.env.port || process.env.PORT || "3000", 10);
4
+ const port = parseInt(
5
+ argv.port || process.env.port || process.env.PORT || "3000",
6
+ 10
7
+ );
5
8
  const host = argv.host || process.env.HOST;
6
9
  export {
7
10
  getCWD,
@@ -18,7 +18,9 @@ console.error = (...args) => {
18
18
  "Warning: The tag <%s> is unrecognized in this browser",
19
19
  "Warning: Invalid arguments supplied to oneOf"
20
20
  ];
21
- if (ignoreList.find((ignoreMsg) => !!args.find((arg) => arg?.includes?.(ignoreMsg))))
21
+ if (ignoreList.find(
22
+ (ignoreMsg) => !!args.find((arg) => arg?.includes?.(ignoreMsg))
23
+ ))
22
24
  return false;
23
25
  return originalError(...args);
24
26
  };
@@ -32,12 +32,14 @@ const copyFiles = async ({ srcdir, outdir }) => {
32
32
  `${srcdir}/**/.swcrc`,
33
33
  `!${srcdir}/**/*.{js,jsx,ts,tsx,mjs}`
34
34
  ]);
35
- await Promise.all(files.map(async (srcFilePath) => {
36
- const destFilePath = srcFilePath.replace(srcdir, outdir);
37
- const fileDir = path.dirname(destFilePath);
38
- await mkdir(fileDir, { recursive: true });
39
- await copyFile(srcFilePath, destFilePath);
40
- }));
35
+ await Promise.all(
36
+ files.map(async (srcFilePath) => {
37
+ const destFilePath = srcFilePath.replace(srcdir, outdir);
38
+ const fileDir = path.dirname(destFilePath);
39
+ await mkdir(fileDir, { recursive: true });
40
+ await copyFile(srcFilePath, destFilePath);
41
+ })
42
+ );
41
43
  };
42
44
  const getSideEffects = async () => {
43
45
  const data = await readFile(path.join(process.cwd(), "./package.json"));
@@ -46,10 +48,14 @@ const getSideEffects = async () => {
46
48
  };
47
49
  const createPackageJson = async ({ outdir, type = NODE_MODULE_TYPES.ESM }) => {
48
50
  const filePath = path.join(process.cwd(), outdir, "package.json");
49
- const packageJSON = JSON.stringify({
50
- type,
51
- sideEffects: await getSideEffects()
52
- }, null, 2);
51
+ const packageJSON = JSON.stringify(
52
+ {
53
+ type,
54
+ sideEffects: await getSideEffects()
55
+ },
56
+ null,
57
+ 2
58
+ );
53
59
  await writeFile(filePath, packageJSON);
54
60
  };
55
61
  const esBuild = async ({
@@ -81,7 +87,9 @@ const esBuild = async ({
81
87
  await createPackageJson({ outdir: cjsOutdir, type: NODE_MODULE_TYPES.CJS });
82
88
  }
83
89
  const esmOutdir = esmOnly ? outdir : `${outdir}/esm`;
84
- const entryPoints = await fg(inputFiles.concat([`!${srcdir}/**/cjs/**/*.{js,jsx,ts,tsx}`]));
90
+ const entryPoints = await fg(
91
+ inputFiles.concat([`!${srcdir}/**/cjs/**/*.{js,jsx,ts,tsx}`])
92
+ );
85
93
  await build({
86
94
  entryPoints,
87
95
  ...getCommonConfig({ injectReactShim }),
@@ -9,7 +9,9 @@ let pathSep = path.sep;
9
9
  if (pathSep === "\\")
10
10
  pathSep = "\\\\";
11
11
  const LATEST_VERSION = "latest";
12
- const getNodeModulesRegEx = (modules) => modules.map((modName) => new RegExp(`node_modules${pathSep}${modName.replace("/", pathSep)}`));
12
+ const getNodeModulesRegEx = (modules) => modules.map(
13
+ (modName) => new RegExp(`node_modules${pathSep}${modName.replace("/", pathSep)}`)
14
+ );
13
15
  const excludeNodeModulesExcept = (modules) => {
14
16
  const moduleRegExps = getNodeModulesRegEx(modules);
15
17
  return function(modulePath) {
@@ -23,34 +25,42 @@ const excludeNodeModulesExcept = (modules) => {
23
25
  };
24
26
  };
25
27
  const getLibraryName = () => {
26
- const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json")));
28
+ const packageJson = JSON.parse(
29
+ fs.readFileSync(path.join(process.cwd(), "package.json"))
30
+ );
27
31
  const libraryName = packageJson ? packageJson.name : process.env.LIBRARY_NAME || "mylibrary";
28
32
  const modifiedLibName = `emui-${libraryName.replace("@elliemae/", "").replace("pui-", "")}`;
29
33
  return _.camelCase(modifiedLibName);
30
34
  };
31
- const mapToFolder = (dependencies, folder) => dependencies.reduce((acc, dependency) => ({
32
- [dependency]: path.resolve(`${folder}/${dependency.replace("$", "")}`),
33
- ...acc
34
- }), {});
35
+ const mapToFolder = (dependencies, folder) => dependencies.reduce(
36
+ (acc, dependency) => ({
37
+ [dependency]: path.resolve(`${folder}/${dependency.replace("$", "")}`),
38
+ ...acc
39
+ }),
40
+ {}
41
+ );
35
42
  const getAlias = () => {
36
43
  const monorepoRoot = findMonoRepoRoot(process.cwd()) || "";
37
- return mapToFolder([
38
- "@babel/runtime",
39
- "react",
40
- "react-dom",
41
- "react-redux",
42
- "redux",
43
- "redux-saga",
44
- "moment",
45
- "lodash",
46
- "styled-components",
47
- "immer",
48
- "react-dates",
49
- "react-transition-group",
50
- "@elliemae/pui-cli",
51
- "@elliemae/pui-app-sdk$",
52
- "@elliemae/pui-theme$"
53
- ], path.join(monorepoRoot, "./node_modules"));
44
+ return mapToFolder(
45
+ [
46
+ "@babel/runtime",
47
+ "react",
48
+ "react-dom",
49
+ "react-redux",
50
+ "redux",
51
+ "redux-saga",
52
+ "moment",
53
+ "lodash",
54
+ "styled-components",
55
+ "immer",
56
+ "react-dates",
57
+ "react-transition-group",
58
+ "@elliemae/pui-cli",
59
+ "@elliemae/pui-app-sdk$",
60
+ "@elliemae/pui-theme$"
61
+ ],
62
+ path.join(monorepoRoot, "./node_modules")
63
+ );
54
64
  };
55
65
  const modulesToTranspile = [
56
66
  "@elliemae/pui-*",
@@ -60,35 +70,55 @@ const modulesToTranspile = [
60
70
  ];
61
71
  const getUserMonitoringFileName = () => {
62
72
  const libName = "emuiUserMonitoring";
63
- const userMonLibPath = path.join(process.cwd(), "node_modules/@elliemae/pui-user-monitoring/dist/public/js");
73
+ const userMonLibPath = path.join(
74
+ process.cwd(),
75
+ "node_modules/@elliemae/pui-user-monitoring/dist/public/js"
76
+ );
64
77
  if (!fs.existsSync(userMonLibPath))
65
78
  return `${libName}.js`;
66
79
  const distJSFiles = fs.readdirSync(userMonLibPath);
67
- return distJSFiles.filter((fName) => fName.match(/emuiUserMonitoring+((?!chunk).)*\.js$/))[0];
80
+ return distJSFiles.filter(
81
+ (fName) => fName.match(/emuiUserMonitoring+((?!chunk).)*\.js$/)
82
+ )[0];
68
83
  };
69
84
  const getAppLoaderFileName = () => {
70
85
  const libName = "emuiAppLoader";
71
- const appLoaderLibPath = path.join(process.cwd(), "node_modules/@elliemae/pui-app-loader/dist/public/js");
86
+ const appLoaderLibPath = path.join(
87
+ process.cwd(),
88
+ "node_modules/@elliemae/pui-app-loader/dist/public/js"
89
+ );
72
90
  if (!fs.existsSync(appLoaderLibPath))
73
91
  return `${libName}.js`;
74
92
  const distJSFiles = fs.readdirSync(appLoaderLibPath);
75
- return distJSFiles.filter((fName) => fName.match(/emuiAppLoader+((?!chunk).)*\.js$/))[0];
93
+ return distJSFiles.filter(
94
+ (fName) => fName.match(/emuiAppLoader+((?!chunk).)*\.js$/)
95
+ )[0];
76
96
  };
77
97
  const getDiagnosticsFileName = () => {
78
98
  const libName = "emuiDiagnostics";
79
- const libPath = path.join(process.cwd(), "node_modules/@elliemae/pui-diagnostics/dist/public/js");
99
+ const libPath = path.join(
100
+ process.cwd(),
101
+ "node_modules/@elliemae/pui-diagnostics/dist/public/js"
102
+ );
80
103
  if (!fs.existsSync(libPath))
81
104
  return `${libName}.js`;
82
105
  const distJSFiles = fs.readdirSync(libPath);
83
- return distJSFiles.filter((fName) => fName.match(/emuiDiagnostics+((?!chunk).)*\.js$/))[0];
106
+ return distJSFiles.filter(
107
+ (fName) => fName.match(/emuiDiagnostics+((?!chunk).)*\.js$/)
108
+ )[0];
84
109
  };
85
110
  const getENCWLoaderFileName = () => {
86
111
  const libName = "emuiEncwLoader";
87
- const appLoaderLibPath = path.join(process.cwd(), "node_modules/@elliemae/encw-loader/dist/public/js");
112
+ const appLoaderLibPath = path.join(
113
+ process.cwd(),
114
+ "node_modules/@elliemae/encw-loader/dist/public/js"
115
+ );
88
116
  if (!fs.existsSync(appLoaderLibPath))
89
117
  return `${libName}.js`;
90
118
  const distJSFiles = fs.readdirSync(appLoaderLibPath);
91
- return distJSFiles.filter((fName) => fName.match(/emuiEncwLoader+((?!chunk).)*\.js$/))[0];
119
+ return distJSFiles.filter(
120
+ (fName) => fName.match(/emuiEncwLoader+((?!chunk).)*\.js$/)
121
+ )[0];
92
122
  };
93
123
  const getAppVersion = () => {
94
124
  if (!process.env.APP_VERSION)
@@ -149,7 +179,9 @@ const getCompressionPlugins = (isLibrary = false) => {
149
179
  })
150
180
  ];
151
181
  };
152
- const filterByFilePresence = (patterns) => patterns.filter(({ from, noErrorOnMissing }) => !noErrorOnMissing || fs.existsSync(path.resolve(process.cwd(), from)));
182
+ const filterByFilePresence = (patterns) => patterns.filter(
183
+ ({ from, noErrorOnMissing }) => !noErrorOnMissing || fs.existsSync(path.resolve(process.cwd(), from))
184
+ );
153
185
  const resolveExtensions = [
154
186
  ".wasm",
155
187
  ".mjs",
@@ -1,9 +1,22 @@
1
+ import path from "node:path";
2
+ import fg from "fast-glob";
1
3
  import CircularDependencyPlugin from "circular-dependency-plugin";
2
4
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
3
5
  import HtmlWebpackPlugin from "html-webpack-plugin";
4
6
  import { getLibraryName } from "./helpers.js";
5
7
  import { baseConfig } from "./webpack.base.babel.js";
6
8
  const libraryName = getLibraryName();
9
+ const getHtmlWebpackPlugins = () => {
10
+ const htmlTemplateFiles = fg.sync([path.join(process.cwd(), "lib/*.html")]);
11
+ return htmlTemplateFiles.map(
12
+ (htmlTemplateFile) => new HtmlWebpackPlugin({
13
+ template: htmlTemplateFile,
14
+ filename: path.basename(htmlTemplateFile),
15
+ libraryName,
16
+ inject: true
17
+ })
18
+ );
19
+ };
7
20
  var webpack_lib_dev_babel_default = baseConfig({
8
21
  mode: "development",
9
22
  output: {
@@ -20,12 +33,7 @@ var webpack_lib_dev_babel_default = baseConfig({
20
33
  alias: {}
21
34
  },
22
35
  plugins: [
23
- new HtmlWebpackPlugin({
24
- inject: true,
25
- template: "lib/index.pug",
26
- filename: "index.html",
27
- libraryName
28
- }),
36
+ ...getHtmlWebpackPlugins(),
29
37
  new CircularDependencyPlugin({
30
38
  exclude: /a\.(js|ts|jsx|tsx)|node_modules/,
31
39
  failOnError: false
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import fg from "fast-glob";
2
3
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
3
4
  import HtmlWebpackPlugin from "html-webpack-plugin";
4
5
  import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
@@ -7,6 +8,29 @@ import browserslistToEsbuild from "browserslist-to-esbuild";
7
8
  import { getLibraryName, getCompressionPlugins } from "./helpers.js";
8
9
  import { baseConfig } from "./webpack.lib.base.babel.js";
9
10
  const libraryName = process.env.LIBRARY_FILE_NAME || getLibraryName();
11
+ const getHtmlWebpackPlugins = () => {
12
+ const htmlTemplateFiles = fg.sync([path.join(process.cwd(), "lib/*.html")]);
13
+ return htmlTemplateFiles.map(
14
+ (htmlTemplateFile) => new HtmlWebpackPlugin({
15
+ template: htmlTemplateFile,
16
+ filename: path.basename(htmlTemplateFile),
17
+ libraryName,
18
+ inject: true,
19
+ minify: {
20
+ removeComments: true,
21
+ collapseWhitespace: true,
22
+ removeRedundantAttributes: true,
23
+ useShortDoctype: true,
24
+ removeEmptyAttributes: true,
25
+ removeStyleLinkTypeAttributes: true,
26
+ keepClosingSlash: true,
27
+ minifyJS: true,
28
+ minifyCSS: true,
29
+ minifyURLs: true
30
+ }
31
+ })
32
+ );
33
+ };
10
34
  var webpack_lib_prod_babel_default = baseConfig({
11
35
  mode: "production",
12
36
  output: {
@@ -31,24 +55,7 @@ var webpack_lib_prod_babel_default = baseConfig({
31
55
  }
32
56
  },
33
57
  plugins: [
34
- new HtmlWebpackPlugin({
35
- template: "lib/index.pug",
36
- filename: "index.html",
37
- libraryName,
38
- minify: {
39
- removeComments: true,
40
- collapseWhitespace: true,
41
- removeRedundantAttributes: true,
42
- useShortDoctype: true,
43
- removeEmptyAttributes: true,
44
- removeStyleLinkTypeAttributes: true,
45
- keepClosingSlash: true,
46
- minifyJS: true,
47
- minifyCSS: true,
48
- minifyURLs: true
49
- },
50
- inject: true
51
- }),
58
+ ...getHtmlWebpackPlugins(),
52
59
  new MiniCssExtractPlugin({
53
60
  filename: `css/${libraryName}.[contenthash].css`,
54
61
  chunkFilename: `css/${libraryName}.[contenthash].chunk.css`
@@ -110,10 +110,12 @@ const addSMPPlugin = (webpackConfig) => {
110
110
  const smpConfig = new SpeedMeasurePlugin({
111
111
  disable: !process.env.MEASURE
112
112
  }).wrap(webpackConfig);
113
- smpConfig.plugins.push(new MiniCssExtractPlugin({
114
- filename: "latest/css/[name].[contenthash].css",
115
- chunkFilename: "latest/css/[name].[contenthash].chunk.css"
116
- }));
113
+ smpConfig.plugins.push(
114
+ new MiniCssExtractPlugin({
115
+ filename: "latest/css/[name].[contenthash].css",
116
+ chunkFilename: "latest/css/[name].[contenthash].chunk.css"
117
+ })
118
+ );
117
119
  return smpConfig;
118
120
  };
119
121
  var webpack_prod_babel_default = addSMPPlugin(config);
@@ -52,7 +52,9 @@ const getModuleRules = () => [
52
52
  ];
53
53
  const webpackFinal = async (config, { configType }) => {
54
54
  const isProd = configType === "PRODUCTION";
55
- const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.(".svg"));
55
+ const fileLoaderRule = config.module.rules.find(
56
+ (rule) => rule.test?.test?.(".svg")
57
+ );
56
58
  fileLoaderRule.exclude = /\.svg$/i;
57
59
  config.module.rules.unshift(...getModuleRules());
58
60
  config.plugins.push(...getAdditionalPlugins());