@prosopo/config 3.1.0 → 3.1.1

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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/index.cjs +4 -38
  3. package/dist/cjs/vite/index.cjs +4 -0
  4. package/dist/cjs/vite/vite-plugin-copy.cjs +42 -0
  5. package/dist/cjs/vite/vite-plugin-remove-unused-translations.cjs +2 -2
  6. package/dist/cjs/vite/vite.commonjs.config.cjs +7 -1
  7. package/dist/cjs/vite/vite.esm.config.cjs +54 -0
  8. package/dist/cjs/vite/vite.test.config.cjs +14 -2
  9. package/dist/dependencies.js +134 -112
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +31 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/vite/TsNoCheckPlugin.js +17 -13
  15. package/dist/vite/index.d.ts +2 -0
  16. package/dist/vite/index.d.ts.map +1 -1
  17. package/dist/vite/index.js +24 -10
  18. package/dist/vite/index.js.map +1 -1
  19. package/dist/vite/vite-plugin-close-and-copy.js +41 -36
  20. package/dist/vite/vite-plugin-copy.d.ts +10 -0
  21. package/dist/vite/vite-plugin-copy.d.ts.map +1 -0
  22. package/dist/vite/vite-plugin-copy.js +43 -0
  23. package/dist/vite/vite-plugin-copy.js.map +1 -0
  24. package/dist/vite/vite-plugin-fix-absolute-imports.js +25 -20
  25. package/dist/vite/vite-plugin-remove-unused-translations.js +76 -70
  26. package/dist/vite/vite-plugin-sourcemap-exclude.js +17 -14
  27. package/dist/vite/vite.backend.config.js +90 -84
  28. package/dist/vite/vite.commonjs.config.d.ts.map +1 -1
  29. package/dist/vite/vite.commonjs.config.js +53 -41
  30. package/dist/vite/vite.commonjs.config.js.map +1 -1
  31. package/dist/vite/vite.esm.config.d.ts +3 -0
  32. package/dist/vite/vite.esm.config.d.ts.map +1 -0
  33. package/dist/vite/vite.esm.config.js +55 -0
  34. package/dist/vite/vite.esm.config.js.map +1 -0
  35. package/dist/vite/vite.frontend.config.js +171 -141
  36. package/dist/vite/vite.test.config.d.ts +1 -1
  37. package/dist/vite/vite.test.config.d.ts.map +1 -1
  38. package/dist/vite/vite.test.config.js +58 -42
  39. package/dist/vite/vite.test.config.js.map +1 -1
  40. package/dist/webpack/index.js +1 -2
  41. package/dist/webpack/webpack.config.js +115 -109
  42. package/package.json +26 -21
  43. package/vite.cjs.config.ts +3 -4
  44. package/vite.esm.config.ts +19 -0
  45. package/dist/cjs/projectInfo.cjs +0 -76
  46. package/dist/projectInfo.d.ts +0 -38
  47. package/dist/projectInfo.d.ts.map +0 -1
  48. package/dist/projectInfo.js +0 -38
  49. package/dist/projectInfo.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @prosopo/config
2
2
 
3
+ ## 3.1.1
4
+ ### Patch Changes
5
+
6
+ - 3573f0b: fix npm scripts bundle command
7
+ - 3573f0b: build using vite, typecheck using tsc
8
+ - 3573f0b: standardise all vite based npm scripts for bundling
9
+ - 2d0dd8a: Integration tests for UAPs
10
+
3
11
  ## 3.1.0
4
12
  ### Minor Changes
5
13
 
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./vite/index.cjs");
4
4
  const dependencies = require("./dependencies.cjs");
5
- const projectInfo = require("./projectInfo.cjs");
6
5
  require("./webpack/index.cjs");
7
6
  const vitePluginCloseAndCopy = require("./vite/vite-plugin-close-and-copy.cjs");
8
7
  const vite_test_config = require("./vite/vite.test.config.cjs");
@@ -11,49 +10,14 @@ const vite_frontend_config = require("./vite/vite.frontend.config.cjs");
11
10
  const vite_backend_config = require("./vite/vite.backend.config.cjs");
12
11
  const vitePluginFixAbsoluteImports = require("./vite/vite-plugin-fix-absolute-imports.cjs");
13
12
  const vite_commonjs_config = require("./vite/vite.commonjs.config.cjs");
13
+ const vite_esm_config = require("./vite/vite.esm.config.cjs");
14
14
  const vitePluginRemoveUnusedTranslations = require("./vite/vite-plugin-remove-unused-translations.cjs");
15
+ const vitePluginCopy = require("./vite/vite-plugin-copy.cjs");
15
16
  const TsNoCheckPlugin = require("./vite/TsNoCheckPlugin.cjs");
16
17
  exports.filterDependencies = dependencies.filterDependencies;
17
18
  exports.getDependencies = dependencies.getDependencies;
18
19
  exports.getExternalsFromReferences = dependencies.getExternalsFromReferences;
19
20
  exports.getTsConfigs = dependencies.getTsConfigs;
20
- exports.getAccountPkgDir = projectInfo.getAccountPkgDir;
21
- exports.getApiPkgDir = projectInfo.getApiPkgDir;
22
- exports.getCacheDir = projectInfo.getCacheDir;
23
- exports.getCliPkgDir = projectInfo.getCliPkgDir;
24
- exports.getClientBundleExampleDir = projectInfo.getClientBundleExampleDir;
25
- exports.getClientExampleDir = projectInfo.getClientExampleDir;
26
- exports.getClientExampleServerDir = projectInfo.getClientExampleServerDir;
27
- exports.getCommonPkgDir = projectInfo.getCommonPkgDir;
28
- exports.getConfigPkgDir = projectInfo.getConfigPkgDir;
29
- exports.getDappExampleDir = projectInfo.getDappExampleDir;
30
- exports.getDatabasePkgDir = projectInfo.getDatabasePkgDir;
31
- exports.getDatasetsFsPkgDir = projectInfo.getDatasetsFsPkgDir;
32
- exports.getDatasetsPkgDir = projectInfo.getDatasetsPkgDir;
33
- exports.getDemosDir = projectInfo.getDemosDir;
34
- exports.getDevDir = projectInfo.getDevDir;
35
- exports.getDotEnvPkgDir = projectInfo.getDotEnvPkgDir;
36
- exports.getEnvPkgDir = projectInfo.getEnvPkgDir;
37
- exports.getFileServerPkgDir = projectInfo.getFileServerPkgDir;
38
- exports.getLocalePkgDir = projectInfo.getLocalePkgDir;
39
- exports.getNodeModulesDir = projectInfo.getNodeModulesDir;
40
- exports.getPackagesDir = projectInfo.getPackagesDir;
41
- exports.getProcaptchaBundlePkgDir = projectInfo.getProcaptchaBundlePkgDir;
42
- exports.getProcaptchaCommonPkgDir = projectInfo.getProcaptchaCommonPkgDir;
43
- exports.getProcaptchaFrictionlessPkgDir = projectInfo.getProcaptchaFrictionlessPkgDir;
44
- exports.getProcaptchaPkgDir = projectInfo.getProcaptchaPkgDir;
45
- exports.getProcaptchaPoWPkgDir = projectInfo.getProcaptchaPoWPkgDir;
46
- exports.getProcaptchaReactPkgDir = projectInfo.getProcaptchaReactPkgDir;
47
- exports.getProviderPkgDir = projectInfo.getProviderPkgDir;
48
- exports.getRootDir = projectInfo.getRootDir;
49
- exports.getScriptsPkgDir = projectInfo.getScriptsPkgDir;
50
- exports.getServerPkgDir = projectInfo.getServerPkgDir;
51
- exports.getTestResultsDir = projectInfo.getTestResultsDir;
52
- exports.getTypesDatabasePkgDir = projectInfo.getTypesDatabasePkgDir;
53
- exports.getTypesEnvPkgDir = projectInfo.getTypesEnvPkgDir;
54
- exports.getTypesPkgDir = projectInfo.getTypesPkgDir;
55
- exports.getUtilPkgDir = projectInfo.getUtilPkgDir;
56
- exports.getWidgetSkeletonPkgDir = projectInfo.getWidgetSkeletonPkgDir;
57
21
  exports.VitePluginCloseAndCopy = vitePluginCloseAndCopy;
58
22
  exports.ViteTestConfig = vite_test_config;
59
23
  exports.VitePluginSourceMapExclude = vitePluginSourcemapExclude;
@@ -61,5 +25,7 @@ exports.ViteFrontendConfig = vite_frontend_config;
61
25
  exports.ViteBackendConfig = vite_backend_config;
62
26
  exports.VitePluginFixAbsoluteImports = vitePluginFixAbsoluteImports;
63
27
  exports.ViteCommonJSConfig = vite_commonjs_config;
28
+ exports.ViteEsmConfig = vite_esm_config;
64
29
  exports.VitePluginRemoveUnusedTranslations = vitePluginRemoveUnusedTranslations.default;
30
+ exports.VitePluginCopy = vitePluginCopy;
65
31
  exports.tsNoCheckPlugin = TsNoCheckPlugin.tsNoCheckPlugin;
@@ -7,8 +7,10 @@ const vite_frontend_config = require("./vite.frontend.config.cjs");
7
7
  const vite_backend_config = require("./vite.backend.config.cjs");
8
8
  const vitePluginFixAbsoluteImports = require("./vite-plugin-fix-absolute-imports.cjs");
9
9
  const vite_commonjs_config = require("./vite.commonjs.config.cjs");
10
+ const vite_esm_config = require("./vite.esm.config.cjs");
10
11
  const vitePluginRemoveUnusedTranslations = require("./vite-plugin-remove-unused-translations.cjs");
11
12
  const TsNoCheckPlugin = require("./TsNoCheckPlugin.cjs");
13
+ const vitePluginCopy = require("./vite-plugin-copy.cjs");
12
14
  exports.VitePluginCloseAndCopy = vitePluginCloseAndCopy;
13
15
  exports.ViteTestConfig = vite_test_config;
14
16
  exports.VitePluginSourceMapExclude = vitePluginSourcemapExclude;
@@ -16,5 +18,7 @@ exports.ViteFrontendConfig = vite_frontend_config;
16
18
  exports.ViteBackendConfig = vite_backend_config;
17
19
  exports.VitePluginFixAbsoluteImports = vitePluginFixAbsoluteImports;
18
20
  exports.ViteCommonJSConfig = vite_commonjs_config;
21
+ exports.ViteEsmConfig = vite_esm_config;
19
22
  exports.VitePluginRemoveUnusedTranslations = vitePluginRemoveUnusedTranslations.default;
20
23
  exports.tsNoCheckPlugin = TsNoCheckPlugin.tsNoCheckPlugin;
24
+ exports.VitePluginCopy = vitePluginCopy;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+ const fg = require("fast-glob");
5
+ function ensureDirExists(filePath) {
6
+ const dir = path.dirname(filePath);
7
+ if (!fs.existsSync(dir)) {
8
+ fs.mkdirSync(dir, { recursive: true });
9
+ }
10
+ }
11
+ function VitePluginCopy(options) {
12
+ const __dirname = path.resolve();
13
+ return {
14
+ name: "copy-plugin",
15
+ async closeBundle() {
16
+ const srcAbs = path.resolve(__dirname, options.srcDir);
17
+ const destAbs = path.resolve(__dirname, options.destDir);
18
+ const include = options.include && options.include.length > 0 ? options.include : void 0;
19
+ const exclude = options.exclude || [];
20
+ if (!include) {
21
+ console.info(
22
+ "[copy-plugin] No include globs specified, nothing to copy."
23
+ );
24
+ return;
25
+ }
26
+ const files = await fg(include, {
27
+ cwd: srcAbs,
28
+ ignore: exclude,
29
+ onlyFiles: true,
30
+ absolute: false
31
+ });
32
+ for (const relFile of files) {
33
+ const srcFile = path.join(srcAbs, relFile);
34
+ const destFile = path.join(destAbs, relFile);
35
+ ensureDirExists(destFile);
36
+ console.info(`[copy-plugin] copying ${srcFile} to ${destFile}`);
37
+ fs.copyFileSync(srcFile, destFile);
38
+ }
39
+ }
40
+ };
41
+ }
42
+ module.exports = VitePluginCopy;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const fs = require("node:fs/promises");
4
- const glob = require("fast-glob");
4
+ const fg = require("fast-glob");
5
5
  const used = /* @__PURE__ */ new Set();
6
6
  const flatten = (obj, prefix = "") => {
7
7
  const flattenedObj = {};
@@ -45,7 +45,7 @@ function VitePluginRemoveUnusedTranslations(translationKeys, jsonPattern) {
45
45
  },
46
46
  enforce: "post",
47
47
  async writeBundle() {
48
- const jsonFiles = await glob(jsonPattern, { absolute: true });
48
+ const jsonFiles = await fg(jsonPattern, { absolute: true });
49
49
  console.info(`Found ${jsonFiles.length} JSON files at ${jsonPattern}`);
50
50
  const filePromises = [];
51
51
  for (const filePath of jsonFiles) {
@@ -7,6 +7,7 @@ const noBundlePlugin = require("vite-plugin-no-bundle");
7
7
  const tsconfigPaths = require("vite-tsconfig-paths");
8
8
  const dependencies = require("../dependencies.cjs");
9
9
  const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
10
+ const vitePluginCopy = require("./vite-plugin-copy.cjs");
10
11
  async function vite_commonjs_config(name, tsConfigPath, entry) {
11
12
  console.info(`ViteCommonJSConfig: ${name}`);
12
13
  const projectExternal = await dependencies.getExternalsFromReferences(tsConfigPath, [
@@ -30,11 +31,16 @@ async function vite_commonjs_config(name, tsConfigPath, entry) {
30
31
  root: "src",
31
32
  copy: "**/*.css"
32
33
  }),
34
+ vitePluginCopy({
35
+ srcDir: "src",
36
+ destDir: "dist",
37
+ include: ["**/*.json"]
38
+ }),
33
39
  tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }),
34
40
  vitePluginCloseAndCopy()
35
41
  ],
36
42
  build: {
37
- emptyOutDir: true,
43
+ emptyOutDir: false,
38
44
  ssr: true,
39
45
  target: "node18",
40
46
  outDir: "dist/cjs",
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ const node_module = require("node:module");
3
+ const path = require("node:path");
4
+ const vite = require("vite");
5
+ const noBundlePlugin = require("vite-plugin-no-bundle");
6
+ const tsconfigPaths = require("vite-tsconfig-paths");
7
+ const dependencies = require("../dependencies.cjs");
8
+ const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
9
+ const vitePluginCopy = require("./vite-plugin-copy.cjs");
10
+ async function vite_esm_config(name, tsConfigPath, entry) {
11
+ console.info(`ViteEsmConfig: ${name}`);
12
+ const projectExternal = await dependencies.getExternalsFromReferences(tsConfigPath, [
13
+ /dev/
14
+ ]);
15
+ const allExternal = [
16
+ ...node_module.builtinModules,
17
+ ...node_module.builtinModules.map((m) => `node:${m}`),
18
+ ...projectExternal
19
+ ];
20
+ return vite.defineConfig({
21
+ ssr: { external: allExternal },
22
+ plugins: [
23
+ // @ts-ignore
24
+ noBundlePlugin({
25
+ root: "src",
26
+ copy: "**/*.css"
27
+ }),
28
+ vitePluginCopy({
29
+ srcDir: "src",
30
+ destDir: "dist",
31
+ include: ["**/*.json"]
32
+ }),
33
+ tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }),
34
+ vitePluginCloseAndCopy()
35
+ ],
36
+ build: {
37
+ emptyOutDir: false,
38
+ ssr: true,
39
+ target: "node18",
40
+ outDir: "dist",
41
+ lib: {
42
+ name,
43
+ formats: ["es"],
44
+ entry: entry || "src/index.ts"
45
+ // required
46
+ },
47
+ rollupOptions: {
48
+ treeshake: false,
49
+ external: allExternal
50
+ }
51
+ }
52
+ });
53
+ }
54
+ module.exports = vite_esm_config;
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ const path = require("node:path");
3
+ const tsconfigPaths = require("vite-tsconfig-paths");
2
4
  const config = require("vitest/config");
3
- function vite_test_config() {
5
+ const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
6
+ const vitePluginSourcemapExclude = require("./vite-plugin-sourcemap-exclude.cjs");
7
+ function vite_test_config(tsConfigPath) {
4
8
  const testTypeEnv = process.env.TEST_TYPE || "";
5
9
  const testTypes = testTypeEnv.trim().split(",");
6
10
  const testTypeGlob = `@(|${testTypes.map((t) => t ? `.${t.trim()}` : "").join("|")})`;
7
11
  console.log(`Filtering tests by type: ${testTypeGlob}`);
12
+ const plugins = [
13
+ vitePluginSourcemapExclude({ excludeNodeModules: true }),
14
+ vitePluginCloseAndCopy()
15
+ ];
16
+ if (tsConfigPath) {
17
+ plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
18
+ }
8
19
  return config.defineConfig({
9
20
  build: {
10
21
  minify: false,
@@ -41,7 +52,8 @@ function vite_test_config() {
41
52
  }
42
53
  },
43
54
  testTimeout: 1e4
44
- }
55
+ },
56
+ plugins
45
57
  });
46
58
  }
47
59
  module.exports = vite_test_config;
@@ -7,127 +7,149 @@ const tsConfigRegex = /\/[A-Za-z.]*\.json$/;
7
7
  const peerDepsRegex = /UNMET\sOPTIONAL\sDEPENDENCY\s+(@*[\w\-/.]+)@/;
8
8
  const depsRegex = /\s+(@*[\w\-/.]+)@/;
9
9
  async function getPackageDir(packageName) {
10
- let pkg = packageName;
11
- if (packageName && !packageName.startsWith("@prosopo/")) {
12
- pkg = `@prosopo/${packageName}`;
10
+ let pkg = packageName;
11
+ if (packageName && !packageName.startsWith("@prosopo/")) {
12
+ pkg = `@prosopo/${packageName}`;
13
+ }
14
+ const pkgCommand = `npm list ${pkg} -ap`;
15
+ console.info(`Running command ${pkgCommand}`);
16
+ const { stdout: packageDir, stderr } = await exec(pkgCommand);
17
+ if (stderr) {
18
+ if (stderr.includes("ERR!")) {
19
+ throw new Error("CONFIG.INVALID_PACKAGE_DIR");
13
20
  }
14
- const pkgCommand = `npm list ${pkg} -ap`;
15
- console.info(`Running command ${pkgCommand}`);
16
- const { stdout: packageDir, stderr } = await exec(pkgCommand);
17
- if (stderr) {
18
- if (stderr.includes("ERR!")) {
19
- throw new Error("CONFIG.INVALID_PACKAGE_DIR");
20
- }
21
- }
22
- return packageDir.trim() || path.resolve();
21
+ }
22
+ return packageDir.trim() || path.resolve();
23
23
  }
24
24
  function getReferenceTsConfigPath(initialTsConfigPath, reference) {
25
- let refTSConfigPath = path.resolve(initialTsConfigPath.replace(tsConfigRegex, ""), reference.path);
26
- if (!refTSConfigPath.endsWith(".json")) {
27
- refTSConfigPath = path.resolve(refTSConfigPath, "tsconfig.json");
28
- }
29
- return refTSConfigPath;
25
+ let refTSConfigPath = path.resolve(
26
+ initialTsConfigPath.replace(tsConfigRegex, ""),
27
+ reference.path
28
+ );
29
+ if (!refTSConfigPath.endsWith(".json")) {
30
+ refTSConfigPath = path.resolve(refTSConfigPath, "tsconfig.json");
31
+ }
32
+ return refTSConfigPath;
30
33
  }
31
- export function getTsConfigs(tsConfigPath, ignorePatterns = [], tsConfigPaths = [], includeInitialTsConfig = true) {
32
- let tsConfigs = [...tsConfigPaths];
33
- const references = JSON.parse(fs.readFileSync(tsConfigPath).toString()).references;
34
- if (!tsConfigs.includes(tsConfigPath)) {
35
- if (references) {
36
- const ignore = ignorePatterns && ignorePatterns.length > 0
37
- ? new RegExp(`${ignorePatterns.join("|")}`)
38
- : undefined;
39
- if (includeInitialTsConfig) {
40
- tsConfigs.push(tsConfigPath);
41
- }
42
- const filteredReferences = references.filter((reference) => ignore ? !ignore.test(reference.path) : false);
43
- for (const reference of filteredReferences) {
44
- const refTSConfigPath = getReferenceTsConfigPath(tsConfigPath, reference);
45
- const newTsConfigs = getTsConfigs(refTSConfigPath, ignorePatterns, tsConfigs);
46
- if (newTsConfigs.length > 0) {
47
- const distinctTsConfigPaths = new Set(tsConfigs.concat(newTsConfigs));
48
- tsConfigs = [...distinctTsConfigPaths];
49
- }
50
- }
34
+ function getTsConfigs(tsConfigPath, ignorePatterns = [], tsConfigPaths = [], includeInitialTsConfig = true) {
35
+ let tsConfigs = [...tsConfigPaths];
36
+ const references = JSON.parse(
37
+ fs.readFileSync(tsConfigPath).toString()
38
+ ).references;
39
+ if (!tsConfigs.includes(tsConfigPath)) {
40
+ if (references) {
41
+ const ignore = ignorePatterns && ignorePatterns.length > 0 ? new RegExp(`${ignorePatterns.join("|")}`) : void 0;
42
+ if (includeInitialTsConfig) {
43
+ tsConfigs.push(tsConfigPath);
44
+ }
45
+ const filteredReferences = references.filter(
46
+ (reference) => ignore ? !ignore.test(reference.path) : false
47
+ );
48
+ for (const reference of filteredReferences) {
49
+ const refTSConfigPath = getReferenceTsConfigPath(
50
+ tsConfigPath,
51
+ reference
52
+ );
53
+ const newTsConfigs = getTsConfigs(
54
+ refTSConfigPath,
55
+ ignorePatterns,
56
+ tsConfigs
57
+ );
58
+ if (newTsConfigs.length > 0) {
59
+ const distinctTsConfigPaths = new Set(tsConfigs.concat(newTsConfigs));
60
+ tsConfigs = [...distinctTsConfigPaths];
51
61
  }
62
+ }
52
63
  }
53
- return tsConfigs;
54
- }
55
- export async function getExternalsFromReferences(tsConfigPath, ignorePatterns = []) {
56
- const tsConfigPaths = getTsConfigs(tsConfigPath, ignorePatterns, [], false);
57
- console.debug({ tsConfigPaths });
58
- const promises = [];
59
- for (const refTsConfigPath of tsConfigPaths) {
60
- const packageJsonPath = path.resolve(refTsConfigPath.replace(tsConfigRegex, ""), "package.json");
61
- promises.push(new Promise((resolve, reject) => {
62
- fs.stat(packageJsonPath, (err) => {
63
- if (err) {
64
- reject(err);
65
- }
66
- fs.readFile(new URL(packageJsonPath, import.meta.url), (err, buffer) => {
67
- if (err) {
68
- reject(err);
69
- }
70
- else {
71
- const packageJson = JSON.parse(buffer.toString());
72
- const pkg = packageJson.name;
73
- resolve(pkg);
74
- }
75
- });
76
- });
77
- }));
78
- }
79
- const externals = await Promise.all(promises);
80
- console.debug({ externals });
81
- return externals;
64
+ }
65
+ return tsConfigs;
82
66
  }
83
- export async function getDependencies(packageName, production) {
84
- let cmd = production
85
- ? "npm ls -a --silent --omit=dev --package-lock-only"
86
- : "npm ls --silent -a --package-lock-only";
87
- if (packageName) {
88
- const packageDir = await getPackageDir(packageName);
89
- cmd = `cd ${packageDir.trim()} && ${cmd}`;
90
- console.info(`Running command ${cmd} in ${packageDir}`);
91
- }
92
- const { stdout, stderr } = await exec(cmd);
93
- if (stderr) {
94
- throw new Error("CONFIG.INVALID_PACKAGE_DIR");
95
- }
96
- const deps = [];
97
- const peerDeps = [];
98
- for (const line of stdout.split("\n")) {
99
- if (line.includes("UNMET OPTIONAL DEPENDENCY")) {
100
- const parts = line.match(peerDepsRegex);
101
- if (parts && parts.length > 1) {
102
- peerDeps.push(parts[1]);
103
- }
104
- }
105
- else {
106
- const parts = line.match(depsRegex);
107
- if (parts && parts.length > 1) {
108
- deps.push(parts[1]);
67
+ async function getExternalsFromReferences(tsConfigPath, ignorePatterns = []) {
68
+ const tsConfigPaths = getTsConfigs(tsConfigPath, ignorePatterns, [], false);
69
+ console.debug({ tsConfigPaths });
70
+ const promises = [];
71
+ for (const refTsConfigPath of tsConfigPaths) {
72
+ const packageJsonPath = path.resolve(
73
+ refTsConfigPath.replace(tsConfigRegex, ""),
74
+ "package.json"
75
+ );
76
+ promises.push(
77
+ new Promise((resolve, reject) => {
78
+ fs.stat(packageJsonPath, (err) => {
79
+ if (err) {
80
+ reject(err);
81
+ }
82
+ fs.readFile(
83
+ new URL(packageJsonPath, import.meta.url),
84
+ (err2, buffer) => {
85
+ if (err2) {
86
+ reject(err2);
87
+ } else {
88
+ const packageJson = JSON.parse(buffer.toString());
89
+ const pkg = packageJson.name;
90
+ resolve(pkg);
91
+ }
109
92
  }
110
- }
93
+ );
94
+ });
95
+ })
96
+ );
97
+ }
98
+ const externals = await Promise.all(promises);
99
+ console.debug({ externals });
100
+ return externals;
101
+ }
102
+ async function getDependencies(packageName, production) {
103
+ let cmd = production ? "npm ls -a --silent --omit=dev --package-lock-only" : "npm ls --silent -a --package-lock-only";
104
+ if (packageName) {
105
+ const packageDir = await getPackageDir(packageName);
106
+ cmd = `cd ${packageDir.trim()} && ${cmd}`;
107
+ console.info(`Running command ${cmd} in ${packageDir}`);
108
+ }
109
+ const { stdout, stderr } = await exec(cmd);
110
+ if (stderr) {
111
+ throw new Error("CONFIG.INVALID_PACKAGE_DIR");
112
+ }
113
+ const deps = [];
114
+ const peerDeps = [];
115
+ for (const line of stdout.split("\n")) {
116
+ if (line.includes("UNMET OPTIONAL DEPENDENCY")) {
117
+ const parts = line.match(peerDepsRegex);
118
+ if (parts && parts.length > 1) {
119
+ peerDeps.push(parts[1]);
120
+ }
121
+ } else {
122
+ const parts = line.match(depsRegex);
123
+ if (parts && parts.length > 1) {
124
+ deps.push(parts[1]);
125
+ }
111
126
  }
112
- return {
113
- dependencies: deps.filter((x, i) => i === deps.indexOf(x)),
114
- optionalPeerDependencies: peerDeps.filter((x, i) => i === peerDeps.indexOf(x)),
115
- };
127
+ }
128
+ return {
129
+ dependencies: deps.filter((x, i) => i === deps.indexOf(x)),
130
+ optionalPeerDependencies: peerDeps.filter(
131
+ (x, i) => i === peerDeps.indexOf(x)
132
+ )
133
+ };
116
134
  }
117
- export function filterDependencies(deps, filters) {
118
- const depsDeduped = deps.filter((x, i) => i === deps.indexOf(x));
119
- const depsWithLength = depsDeduped.filter((dep) => dep.length > 0).sort();
120
- const exclude = new RegExp(`${filters.join("|")}`);
121
- const internal = [];
122
- const external = [];
123
- for (const dep of depsWithLength) {
124
- if (exclude.test(dep)) {
125
- external.push(dep);
126
- }
127
- else {
128
- internal.push(dep);
129
- }
135
+ function filterDependencies(deps, filters) {
136
+ const depsDeduped = deps.filter((x, i) => i === deps.indexOf(x));
137
+ const depsWithLength = depsDeduped.filter((dep) => dep.length > 0).sort();
138
+ const exclude = new RegExp(`${filters.join("|")}`);
139
+ const internal = [];
140
+ const external = [];
141
+ for (const dep of depsWithLength) {
142
+ if (exclude.test(dep)) {
143
+ external.push(dep);
144
+ } else {
145
+ internal.push(dep);
130
146
  }
131
- return { internal, external };
147
+ }
148
+ return { internal, external };
132
149
  }
133
- //# sourceMappingURL=dependencies.js.map
150
+ export {
151
+ filterDependencies,
152
+ getDependencies,
153
+ getExternalsFromReferences,
154
+ getTsConfigs
155
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./vite/index.js";
2
2
  export * from "./dependencies.js";
3
- export * from "./projectInfo.js";
4
3
  export * from "./webpack/index.js";
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,31 @@
1
- export * from "./vite/index.js";
2
- export * from "./dependencies.js";
3
- export * from "./projectInfo.js";
4
- export * from "./webpack/index.js";
5
- //# sourceMappingURL=index.js.map
1
+ import "./vite/index.js";
2
+ import { filterDependencies, getDependencies, getExternalsFromReferences, getTsConfigs } from "./dependencies.js";
3
+ import "./webpack/index.js";
4
+ import { default as default2 } from "./vite/vite-plugin-close-and-copy.js";
5
+ import { default as default3 } from "./vite/vite.test.config.js";
6
+ import { default as default4 } from "./vite/vite-plugin-sourcemap-exclude.js";
7
+ import { default as default5 } from "./vite/vite.frontend.config.js";
8
+ import { default as default6 } from "./vite/vite.backend.config.js";
9
+ import { default as default7 } from "./vite/vite-plugin-fix-absolute-imports.js";
10
+ import { default as default8 } from "./vite/vite.commonjs.config.js";
11
+ import { default as default9 } from "./vite/vite.esm.config.js";
12
+ import { default as default10 } from "./vite/vite-plugin-remove-unused-translations.js";
13
+ import { default as default11 } from "./vite/vite-plugin-copy.js";
14
+ import { tsNoCheckPlugin } from "./vite/TsNoCheckPlugin.js";
15
+ export {
16
+ default6 as ViteBackendConfig,
17
+ default8 as ViteCommonJSConfig,
18
+ default9 as ViteEsmConfig,
19
+ default5 as ViteFrontendConfig,
20
+ default2 as VitePluginCloseAndCopy,
21
+ default11 as VitePluginCopy,
22
+ default7 as VitePluginFixAbsoluteImports,
23
+ default10 as VitePluginRemoveUnusedTranslations,
24
+ default4 as VitePluginSourceMapExclude,
25
+ default3 as ViteTestConfig,
26
+ filterDependencies,
27
+ getDependencies,
28
+ getExternalsFromReferences,
29
+ getTsConfigs,
30
+ tsNoCheckPlugin
31
+ };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -1,14 +1,18 @@
1
- export function tsNoCheckPlugin() {
2
- return {
3
- name: "vite-plugin-ts-nocheck",
4
- generateBundle(_, bundle) {
5
- for (const fileName in bundle) {
6
- const chunk = bundle[fileName];
7
- if (chunk.type === "chunk" && chunk.code) {
8
- chunk.code = `// @ts-nocheck\n${chunk.code}`;
9
- }
10
- }
11
- },
12
- };
1
+ function tsNoCheckPlugin() {
2
+ return {
3
+ name: "vite-plugin-ts-nocheck",
4
+ // biome-ignore lint/suspicious/noExplicitAny: TODO not sure of options/bundle type (same as NodejsPolarsNativeFilePlugin)
5
+ generateBundle(_, bundle) {
6
+ for (const fileName in bundle) {
7
+ const chunk = bundle[fileName];
8
+ if (chunk.type === "chunk" && chunk.code) {
9
+ chunk.code = `// @ts-nocheck
10
+ ${chunk.code}`;
11
+ }
12
+ }
13
+ }
14
+ };
13
15
  }
14
- //# sourceMappingURL=TsNoCheckPlugin.js.map
16
+ export {
17
+ tsNoCheckPlugin
18
+ };
@@ -5,6 +5,8 @@ export { default as ViteFrontendConfig } from "./vite.frontend.config.js";
5
5
  export { default as ViteBackendConfig } from "./vite.backend.config.js";
6
6
  export { default as VitePluginFixAbsoluteImports } from "./vite-plugin-fix-absolute-imports.js";
7
7
  export { default as ViteCommonJSConfig } from "./vite.commonjs.config.js";
8
+ export { default as ViteEsmConfig } from "./vite.esm.config.js";
8
9
  export { default as VitePluginRemoveUnusedTranslations } from "./vite-plugin-remove-unused-translations.js";
9
10
  export * from "./TsNoCheckPlugin.js";
11
+ export { default as VitePluginCopy } from "./vite-plugin-copy.js";
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AAC5G,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AAC5G,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC"}