@prosopo/config 3.1.2 → 3.1.3
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/CHANGELOG.md +10 -0
- package/package.json +3 -5
- package/dist/cjs/dependencies.cjs +0 -155
- package/dist/cjs/index.cjs +0 -31
- package/dist/cjs/vite/TsNoCheckPlugin.cjs +0 -18
- package/dist/cjs/vite/index.cjs +0 -24
- package/dist/cjs/vite/vite-plugin-close-and-copy.cjs +0 -46
- package/dist/cjs/vite/vite-plugin-copy.cjs +0 -42
- package/dist/cjs/vite/vite-plugin-fix-absolute-imports.cjs +0 -26
- package/dist/cjs/vite/vite-plugin-remove-unused-translations.cjs +0 -81
- package/dist/cjs/vite/vite-plugin-sourcemap-exclude.cjs +0 -17
- package/dist/cjs/vite/vite.backend.config.cjs +0 -98
- package/dist/cjs/vite/vite.commonjs.config.cjs +0 -60
- package/dist/cjs/vite/vite.esm.config.cjs +0 -54
- package/dist/cjs/vite/vite.frontend.config.cjs +0 -182
- package/dist/cjs/vite/vite.test.config.cjs +0 -59
- package/dist/cjs/webpack/index.cjs +0 -2
- package/dist/cjs/webpack/webpack.config.cjs +0 -149
- package/vite.cjs.config.ts +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @prosopo/config
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- 828066d: remove empty test npm scripts, add missing npm test scripts
|
|
7
|
+
- 91bbe87: configure typecheck before bundle for vue packages
|
|
8
|
+
- 3ef4fd2: remove cjs config
|
|
9
|
+
- 91bbe87: make typecheck script always recompile
|
|
10
|
+
- 346e092: NODE_ENV default to "development"
|
|
11
|
+
- 5d36e05: remove tsc --force
|
|
12
|
+
|
|
3
13
|
## 3.1.2
|
|
4
14
|
### Patch Changes
|
|
5
15
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/config",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Prosopo config library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "NODE_ENV=${NODE_ENV:-
|
|
7
|
+
"build": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
|
|
8
8
|
"build:tsc": "tsc --build --verbose",
|
|
9
|
-
"build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
|
|
10
9
|
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
|
|
11
|
-
"typecheck": "tsc --build --declaration --emitDeclarationOnly
|
|
12
|
-
"test": "echo no tests"
|
|
10
|
+
"typecheck": "tsc --build --declaration --emitDeclarationOnly"
|
|
13
11
|
},
|
|
14
12
|
"engines": {
|
|
15
13
|
"node": "20",
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const child_process = require("node:child_process");
|
|
4
|
-
const fs = require("node:fs");
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
const util = require("node:util");
|
|
7
|
-
const exec = util.promisify(child_process.exec);
|
|
8
|
-
const tsConfigRegex = /\/[A-Za-z.]*\.json$/;
|
|
9
|
-
const peerDepsRegex = /UNMET\sOPTIONAL\sDEPENDENCY\s+(@*[\w\-/.]+)@/;
|
|
10
|
-
const depsRegex = /\s+(@*[\w\-/.]+)@/;
|
|
11
|
-
async function getPackageDir(packageName) {
|
|
12
|
-
let pkg = packageName;
|
|
13
|
-
if (packageName && !packageName.startsWith("@prosopo/")) {
|
|
14
|
-
pkg = `@prosopo/${packageName}`;
|
|
15
|
-
}
|
|
16
|
-
const pkgCommand = `npm list ${pkg} -ap`;
|
|
17
|
-
console.info(`Running command ${pkgCommand}`);
|
|
18
|
-
const { stdout: packageDir, stderr } = await exec(pkgCommand);
|
|
19
|
-
if (stderr) {
|
|
20
|
-
if (stderr.includes("ERR!")) {
|
|
21
|
-
throw new Error("CONFIG.INVALID_PACKAGE_DIR");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return packageDir.trim() || path.resolve();
|
|
25
|
-
}
|
|
26
|
-
function getReferenceTsConfigPath(initialTsConfigPath, reference) {
|
|
27
|
-
let refTSConfigPath = path.resolve(
|
|
28
|
-
initialTsConfigPath.replace(tsConfigRegex, ""),
|
|
29
|
-
reference.path
|
|
30
|
-
);
|
|
31
|
-
if (!refTSConfigPath.endsWith(".json")) {
|
|
32
|
-
refTSConfigPath = path.resolve(refTSConfigPath, "tsconfig.json");
|
|
33
|
-
}
|
|
34
|
-
return refTSConfigPath;
|
|
35
|
-
}
|
|
36
|
-
function getTsConfigs(tsConfigPath, ignorePatterns = [], tsConfigPaths = [], includeInitialTsConfig = true) {
|
|
37
|
-
let tsConfigs = [...tsConfigPaths];
|
|
38
|
-
const references = JSON.parse(
|
|
39
|
-
fs.readFileSync(tsConfigPath).toString()
|
|
40
|
-
).references;
|
|
41
|
-
if (!tsConfigs.includes(tsConfigPath)) {
|
|
42
|
-
if (references) {
|
|
43
|
-
const ignore = ignorePatterns && ignorePatterns.length > 0 ? new RegExp(`${ignorePatterns.join("|")}`) : void 0;
|
|
44
|
-
if (includeInitialTsConfig) {
|
|
45
|
-
tsConfigs.push(tsConfigPath);
|
|
46
|
-
}
|
|
47
|
-
const filteredReferences = references.filter(
|
|
48
|
-
(reference) => ignore ? !ignore.test(reference.path) : false
|
|
49
|
-
);
|
|
50
|
-
for (const reference of filteredReferences) {
|
|
51
|
-
const refTSConfigPath = getReferenceTsConfigPath(
|
|
52
|
-
tsConfigPath,
|
|
53
|
-
reference
|
|
54
|
-
);
|
|
55
|
-
const newTsConfigs = getTsConfigs(
|
|
56
|
-
refTSConfigPath,
|
|
57
|
-
ignorePatterns,
|
|
58
|
-
tsConfigs
|
|
59
|
-
);
|
|
60
|
-
if (newTsConfigs.length > 0) {
|
|
61
|
-
const distinctTsConfigPaths = new Set(tsConfigs.concat(newTsConfigs));
|
|
62
|
-
tsConfigs = [...distinctTsConfigPaths];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return tsConfigs;
|
|
68
|
-
}
|
|
69
|
-
async function getExternalsFromReferences(tsConfigPath, ignorePatterns = []) {
|
|
70
|
-
const tsConfigPaths = getTsConfigs(tsConfigPath, ignorePatterns, [], false);
|
|
71
|
-
console.debug({ tsConfigPaths });
|
|
72
|
-
const promises = [];
|
|
73
|
-
for (const refTsConfigPath of tsConfigPaths) {
|
|
74
|
-
const packageJsonPath = path.resolve(
|
|
75
|
-
refTsConfigPath.replace(tsConfigRegex, ""),
|
|
76
|
-
"package.json"
|
|
77
|
-
);
|
|
78
|
-
promises.push(
|
|
79
|
-
new Promise((resolve, reject) => {
|
|
80
|
-
fs.stat(packageJsonPath, (err) => {
|
|
81
|
-
if (err) {
|
|
82
|
-
reject(err);
|
|
83
|
-
}
|
|
84
|
-
fs.readFile(
|
|
85
|
-
new URL(packageJsonPath, module),
|
|
86
|
-
(err2, buffer) => {
|
|
87
|
-
if (err2) {
|
|
88
|
-
reject(err2);
|
|
89
|
-
} else {
|
|
90
|
-
const packageJson = JSON.parse(buffer.toString());
|
|
91
|
-
const pkg = packageJson.name;
|
|
92
|
-
resolve(pkg);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
})
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
const externals = await Promise.all(promises);
|
|
101
|
-
console.debug({ externals });
|
|
102
|
-
return externals;
|
|
103
|
-
}
|
|
104
|
-
async function getDependencies(packageName, production) {
|
|
105
|
-
let cmd = production ? "npm ls -a --silent --omit=dev --package-lock-only" : "npm ls --silent -a --package-lock-only";
|
|
106
|
-
if (packageName) {
|
|
107
|
-
const packageDir = await getPackageDir(packageName);
|
|
108
|
-
cmd = `cd ${packageDir.trim()} && ${cmd}`;
|
|
109
|
-
console.info(`Running command ${cmd} in ${packageDir}`);
|
|
110
|
-
}
|
|
111
|
-
const { stdout, stderr } = await exec(cmd);
|
|
112
|
-
if (stderr) {
|
|
113
|
-
throw new Error("CONFIG.INVALID_PACKAGE_DIR");
|
|
114
|
-
}
|
|
115
|
-
const deps = [];
|
|
116
|
-
const peerDeps = [];
|
|
117
|
-
for (const line of stdout.split("\n")) {
|
|
118
|
-
if (line.includes("UNMET OPTIONAL DEPENDENCY")) {
|
|
119
|
-
const parts = line.match(peerDepsRegex);
|
|
120
|
-
if (parts && parts.length > 1) {
|
|
121
|
-
peerDeps.push(parts[1]);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
const parts = line.match(depsRegex);
|
|
125
|
-
if (parts && parts.length > 1) {
|
|
126
|
-
deps.push(parts[1]);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
dependencies: deps.filter((x, i) => i === deps.indexOf(x)),
|
|
132
|
-
optionalPeerDependencies: peerDeps.filter(
|
|
133
|
-
(x, i) => i === peerDeps.indexOf(x)
|
|
134
|
-
)
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function filterDependencies(deps, filters) {
|
|
138
|
-
const depsDeduped = deps.filter((x, i) => i === deps.indexOf(x));
|
|
139
|
-
const depsWithLength = depsDeduped.filter((dep) => dep.length > 0).sort();
|
|
140
|
-
const exclude = new RegExp(`${filters.join("|")}`);
|
|
141
|
-
const internal = [];
|
|
142
|
-
const external = [];
|
|
143
|
-
for (const dep of depsWithLength) {
|
|
144
|
-
if (exclude.test(dep)) {
|
|
145
|
-
external.push(dep);
|
|
146
|
-
} else {
|
|
147
|
-
internal.push(dep);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return { internal, external };
|
|
151
|
-
}
|
|
152
|
-
exports.filterDependencies = filterDependencies;
|
|
153
|
-
exports.getDependencies = getDependencies;
|
|
154
|
-
exports.getExternalsFromReferences = getExternalsFromReferences;
|
|
155
|
-
exports.getTsConfigs = getTsConfigs;
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./vite/index.cjs");
|
|
4
|
-
const dependencies = require("./dependencies.cjs");
|
|
5
|
-
require("./webpack/index.cjs");
|
|
6
|
-
const vitePluginCloseAndCopy = require("./vite/vite-plugin-close-and-copy.cjs");
|
|
7
|
-
const vite_test_config = require("./vite/vite.test.config.cjs");
|
|
8
|
-
const vitePluginSourcemapExclude = require("./vite/vite-plugin-sourcemap-exclude.cjs");
|
|
9
|
-
const vite_frontend_config = require("./vite/vite.frontend.config.cjs");
|
|
10
|
-
const vite_backend_config = require("./vite/vite.backend.config.cjs");
|
|
11
|
-
const vitePluginFixAbsoluteImports = require("./vite/vite-plugin-fix-absolute-imports.cjs");
|
|
12
|
-
const vite_commonjs_config = require("./vite/vite.commonjs.config.cjs");
|
|
13
|
-
const vite_esm_config = require("./vite/vite.esm.config.cjs");
|
|
14
|
-
const vitePluginRemoveUnusedTranslations = require("./vite/vite-plugin-remove-unused-translations.cjs");
|
|
15
|
-
const vitePluginCopy = require("./vite/vite-plugin-copy.cjs");
|
|
16
|
-
const TsNoCheckPlugin = require("./vite/TsNoCheckPlugin.cjs");
|
|
17
|
-
exports.filterDependencies = dependencies.filterDependencies;
|
|
18
|
-
exports.getDependencies = dependencies.getDependencies;
|
|
19
|
-
exports.getExternalsFromReferences = dependencies.getExternalsFromReferences;
|
|
20
|
-
exports.getTsConfigs = dependencies.getTsConfigs;
|
|
21
|
-
exports.VitePluginCloseAndCopy = vitePluginCloseAndCopy;
|
|
22
|
-
exports.ViteTestConfig = vite_test_config;
|
|
23
|
-
exports.VitePluginSourceMapExclude = vitePluginSourcemapExclude;
|
|
24
|
-
exports.ViteFrontendConfig = vite_frontend_config;
|
|
25
|
-
exports.ViteBackendConfig = vite_backend_config;
|
|
26
|
-
exports.VitePluginFixAbsoluteImports = vitePluginFixAbsoluteImports;
|
|
27
|
-
exports.ViteCommonJSConfig = vite_commonjs_config;
|
|
28
|
-
exports.ViteEsmConfig = vite_esm_config;
|
|
29
|
-
exports.VitePluginRemoveUnusedTranslations = vitePluginRemoveUnusedTranslations.default;
|
|
30
|
-
exports.VitePluginCopy = vitePluginCopy;
|
|
31
|
-
exports.tsNoCheckPlugin = TsNoCheckPlugin.tsNoCheckPlugin;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function tsNoCheckPlugin() {
|
|
4
|
-
return {
|
|
5
|
-
name: "vite-plugin-ts-nocheck",
|
|
6
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO not sure of options/bundle type (same as NodejsPolarsNativeFilePlugin)
|
|
7
|
-
generateBundle(_, bundle) {
|
|
8
|
-
for (const fileName in bundle) {
|
|
9
|
-
const chunk = bundle[fileName];
|
|
10
|
-
if (chunk.type === "chunk" && chunk.code) {
|
|
11
|
-
chunk.code = `// @ts-nocheck
|
|
12
|
-
${chunk.code}`;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.tsNoCheckPlugin = tsNoCheckPlugin;
|
package/dist/cjs/vite/index.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
4
|
-
const vite_test_config = require("./vite.test.config.cjs");
|
|
5
|
-
const vitePluginSourcemapExclude = require("./vite-plugin-sourcemap-exclude.cjs");
|
|
6
|
-
const vite_frontend_config = require("./vite.frontend.config.cjs");
|
|
7
|
-
const vite_backend_config = require("./vite.backend.config.cjs");
|
|
8
|
-
const vitePluginFixAbsoluteImports = require("./vite-plugin-fix-absolute-imports.cjs");
|
|
9
|
-
const vite_commonjs_config = require("./vite.commonjs.config.cjs");
|
|
10
|
-
const vite_esm_config = require("./vite.esm.config.cjs");
|
|
11
|
-
const vitePluginRemoveUnusedTranslations = require("./vite-plugin-remove-unused-translations.cjs");
|
|
12
|
-
const TsNoCheckPlugin = require("./TsNoCheckPlugin.cjs");
|
|
13
|
-
const vitePluginCopy = require("./vite-plugin-copy.cjs");
|
|
14
|
-
exports.VitePluginCloseAndCopy = vitePluginCloseAndCopy;
|
|
15
|
-
exports.ViteTestConfig = vite_test_config;
|
|
16
|
-
exports.VitePluginSourceMapExclude = vitePluginSourcemapExclude;
|
|
17
|
-
exports.ViteFrontendConfig = vite_frontend_config;
|
|
18
|
-
exports.ViteBackendConfig = vite_backend_config;
|
|
19
|
-
exports.VitePluginFixAbsoluteImports = vitePluginFixAbsoluteImports;
|
|
20
|
-
exports.ViteCommonJSConfig = vite_commonjs_config;
|
|
21
|
-
exports.ViteEsmConfig = vite_esm_config;
|
|
22
|
-
exports.VitePluginRemoveUnusedTranslations = vitePluginRemoveUnusedTranslations.default;
|
|
23
|
-
exports.tsNoCheckPlugin = TsNoCheckPlugin.tsNoCheckPlugin;
|
|
24
|
-
exports.VitePluginCopy = vitePluginCopy;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fs = require("node:fs");
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
function VitePluginCloseAndCopy(options) {
|
|
5
|
-
const __dirname = path.resolve();
|
|
6
|
-
return {
|
|
7
|
-
name: "close-plugin",
|
|
8
|
-
// required, will show up in warnings and errors
|
|
9
|
-
buildStart() {
|
|
10
|
-
console.info("Bundle build started");
|
|
11
|
-
},
|
|
12
|
-
buildEnd(error) {
|
|
13
|
-
console.info("Build end");
|
|
14
|
-
if (error) {
|
|
15
|
-
console.log(error);
|
|
16
|
-
console.error(error);
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
closeBundle() {
|
|
20
|
-
if (options) {
|
|
21
|
-
for (const destDir of options.destDir) {
|
|
22
|
-
clearOutputDirJS(__dirname, destDir);
|
|
23
|
-
console.info(`Bundle cleared from ${options.destDir}`);
|
|
24
|
-
copyBundle(__dirname, options.srcDir, destDir);
|
|
25
|
-
console.info(`Bundle copied to ${options.destDir}`);
|
|
26
|
-
}
|
|
27
|
-
console.info("Bundle closed");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const clearOutputDirJS = (__dirname, destDir) => fs.readdirSync(path.resolve(__dirname, destDir)).filter((file) => file.endsWith("js")).map((file) => {
|
|
33
|
-
fs.rmSync(path.resolve(__dirname, destDir, file));
|
|
34
|
-
});
|
|
35
|
-
const copyBundle = (__dirname, srcDir, destDir) => {
|
|
36
|
-
console.info(
|
|
37
|
-
"Copying",
|
|
38
|
-
path.resolve(__dirname, srcDir),
|
|
39
|
-
"to",
|
|
40
|
-
path.resolve(__dirname, destDir)
|
|
41
|
-
);
|
|
42
|
-
fs.cpSync(path.resolve(__dirname, srcDir), path.resolve(__dirname, destDir), {
|
|
43
|
-
recursive: true
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
module.exports = VitePluginCloseAndCopy;
|
|
@@ -1,42 +0,0 @@
|
|
|
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,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const node_module = require("node:module");
|
|
3
|
-
function VitePluginFixAbsoluteImports() {
|
|
4
|
-
return {
|
|
5
|
-
name: "fix-absolute-imports",
|
|
6
|
-
transform(code, id) {
|
|
7
|
-
for (const module2 of node_module.builtinModules) {
|
|
8
|
-
const moduleImportRegex = new RegExp(
|
|
9
|
-
`from "(${module2}(/.*)*/.*.js)";`,
|
|
10
|
-
"g"
|
|
11
|
-
);
|
|
12
|
-
const matches = code.match(moduleImportRegex);
|
|
13
|
-
if (matches) {
|
|
14
|
-
for (const match of matches) {
|
|
15
|
-
code = code.replace(match, `from "${module2}";`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
code
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
enforce: "post"
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
module.exports = VitePluginFixAbsoluteImports;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const fs = require("node:fs/promises");
|
|
4
|
-
const fg = require("fast-glob");
|
|
5
|
-
const used = /* @__PURE__ */ new Set();
|
|
6
|
-
const flatten = (obj, prefix = "") => {
|
|
7
|
-
const flattenedObj = {};
|
|
8
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
9
|
-
if (value instanceof Object) {
|
|
10
|
-
Object.assign(flattenedObj, flatten(value, `${prefix + key}.`));
|
|
11
|
-
} else {
|
|
12
|
-
flattenedObj[prefix + key] = value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return flattenedObj;
|
|
16
|
-
};
|
|
17
|
-
const unflatten = (obj) => {
|
|
18
|
-
const result = {};
|
|
19
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
20
|
-
const keys = key.split(".");
|
|
21
|
-
keys.reduce((acc, k, i) => {
|
|
22
|
-
if (i === keys.length - 1) {
|
|
23
|
-
acc[k] = value;
|
|
24
|
-
} else {
|
|
25
|
-
if (!acc[k]) {
|
|
26
|
-
acc[k] = Number.isNaN(Number(keys[i + 1])) ? {} : [];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return acc[k];
|
|
30
|
-
}, result);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
function VitePluginRemoveUnusedTranslations(translationKeys, jsonPattern) {
|
|
35
|
-
return {
|
|
36
|
-
name: "remove-unused-translations",
|
|
37
|
-
transform(code) {
|
|
38
|
-
for (const key of translationKeys) {
|
|
39
|
-
if (code.includes(key) && !used.has(key)) {
|
|
40
|
-
console.info(`Found key: ${key}`);
|
|
41
|
-
used.add(key);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { code };
|
|
45
|
-
},
|
|
46
|
-
enforce: "post",
|
|
47
|
-
async writeBundle() {
|
|
48
|
-
const jsonFiles = await fg(jsonPattern, { absolute: true });
|
|
49
|
-
console.info(`Found ${jsonFiles.length} JSON files at ${jsonPattern}`);
|
|
50
|
-
const filePromises = [];
|
|
51
|
-
for (const filePath of jsonFiles) {
|
|
52
|
-
try {
|
|
53
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
54
|
-
const jsonData = JSON.parse(content);
|
|
55
|
-
const jsonDataFlattened = flatten(jsonData);
|
|
56
|
-
const filteredData = Object.fromEntries(
|
|
57
|
-
Object.entries(jsonDataFlattened).filter(([key]) => used.has(key))
|
|
58
|
-
);
|
|
59
|
-
const unflattened = unflatten(filteredData);
|
|
60
|
-
filePromises.push(
|
|
61
|
-
fs.writeFile(
|
|
62
|
-
filePath,
|
|
63
|
-
JSON.stringify(unflattened, null, 2),
|
|
64
|
-
"utf-8"
|
|
65
|
-
).then(() => {
|
|
66
|
-
console.info(`Updated ${filePath}`);
|
|
67
|
-
}).catch((e) => {
|
|
68
|
-
console.error(`Failed to update ${filePath}:`, e);
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error(`Failed to process ${filePath}:`, error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
await Promise.all(filePromises);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
exports.default = VitePluginRemoveUnusedTranslations;
|
|
80
|
-
exports.flatten = flatten;
|
|
81
|
-
exports.unflatten = unflatten;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function VitePluginSourcemapExclude(opts) {
|
|
3
|
-
return {
|
|
4
|
-
name: "sourcemap-exclude",
|
|
5
|
-
transform(code, id) {
|
|
6
|
-
if (opts?.excludeNodeModules && id.includes("node_modules")) {
|
|
7
|
-
return {
|
|
8
|
-
code,
|
|
9
|
-
// https://github.com/rollup/rollup/blob/master/docs/plugin-development/index.md#source-code-transformations
|
|
10
|
-
map: { mappings: "" }
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
module.exports = VitePluginSourcemapExclude;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const node_module = require("node:module");
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
const nodeResolve = require("@rollup/plugin-node-resolve");
|
|
5
|
-
const pluginWasm = require("@rollup/plugin-wasm");
|
|
6
|
-
const css = require("rollup-plugin-import-css");
|
|
7
|
-
const dependencies = require("../dependencies.cjs");
|
|
8
|
-
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
9
|
-
const vitePluginFixAbsoluteImports = require("./vite-plugin-fix-absolute-imports.cjs");
|
|
10
|
-
async function vite_backend_config(packageName, packageVersion, bundleName, packageDir, entry, command, mode, outputDir) {
|
|
11
|
-
const isProduction = mode === "production";
|
|
12
|
-
const { dependencies: deps, optionalPeerDependencies } = await dependencies.getDependencies(packageName, true);
|
|
13
|
-
const outDir = outputDir ? path.resolve(outputDir) : path.resolve(packageDir, "dist/bundle");
|
|
14
|
-
const { external, internal } = dependencies.filterDependencies(deps, [
|
|
15
|
-
"aws",
|
|
16
|
-
"webpack",
|
|
17
|
-
"vite",
|
|
18
|
-
"biome"
|
|
19
|
-
]);
|
|
20
|
-
const allExternal = [
|
|
21
|
-
...node_module.builtinModules,
|
|
22
|
-
...node_module.builtinModules.map((m) => `node:${m}`),
|
|
23
|
-
...external,
|
|
24
|
-
...optionalPeerDependencies
|
|
25
|
-
];
|
|
26
|
-
console.info(
|
|
27
|
-
`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`
|
|
28
|
-
);
|
|
29
|
-
const define = {
|
|
30
|
-
"process.env.WS_NO_BUFFER_UTIL": "true",
|
|
31
|
-
"process.env.WS_NO_UTF_8_VALIDATE": "true",
|
|
32
|
-
"process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(packageVersion),
|
|
33
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || mode),
|
|
34
|
-
...process.env.PROSOPO_DEFAULT_ENVIRONMENT && {
|
|
35
|
-
"process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(
|
|
36
|
-
process.env.PROSOPO_DEFAULT_ENVIRONMENT
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
console.info(`Defined vars ${JSON.stringify(define, null, 2)}`);
|
|
41
|
-
let entriesAbsolute;
|
|
42
|
-
if (typeof entry === "string") {
|
|
43
|
-
entriesAbsolute = [path.resolve(packageDir, entry)];
|
|
44
|
-
} else {
|
|
45
|
-
entriesAbsolute = entry.map((e) => path.resolve(packageDir, e));
|
|
46
|
-
}
|
|
47
|
-
const drop = mode === "production" ? ["console", "debugger"] : void 0;
|
|
48
|
-
return {
|
|
49
|
-
ssr: {
|
|
50
|
-
noExternal: internal,
|
|
51
|
-
external: allExternal
|
|
52
|
-
},
|
|
53
|
-
optimizeDeps: {
|
|
54
|
-
include: ["linked-dep", "node_modules"],
|
|
55
|
-
esbuildOptions: {
|
|
56
|
-
loader: {
|
|
57
|
-
".node": "file"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
esbuild: {
|
|
62
|
-
platform: "node",
|
|
63
|
-
target: "node18",
|
|
64
|
-
// drop,
|
|
65
|
-
legalComments: "none"
|
|
66
|
-
},
|
|
67
|
-
define,
|
|
68
|
-
build: {
|
|
69
|
-
outDir,
|
|
70
|
-
minify: isProduction,
|
|
71
|
-
ssr: true,
|
|
72
|
-
target: "node18",
|
|
73
|
-
lib: {
|
|
74
|
-
entry: entriesAbsolute,
|
|
75
|
-
name: bundleName,
|
|
76
|
-
fileName: `${bundleName}.[name].bundle.js`,
|
|
77
|
-
formats: ["es"]
|
|
78
|
-
},
|
|
79
|
-
modulePreload: { polyfill: false },
|
|
80
|
-
rollupOptions: {
|
|
81
|
-
treeshake: "smallest",
|
|
82
|
-
external: allExternal,
|
|
83
|
-
watch: false,
|
|
84
|
-
output: {
|
|
85
|
-
entryFileNames: `${bundleName}.[name].bundle.js`
|
|
86
|
-
},
|
|
87
|
-
plugins: [css(), pluginWasm.wasm(), nodeResolve.nodeResolve()]
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
plugins: [
|
|
91
|
-
// plugin to replace stuff like import blah from string_encoder/lib/string_encoder.js with import blah from string_encoder
|
|
92
|
-
vitePluginFixAbsoluteImports(),
|
|
93
|
-
// plugin to close the bundle after build if not in serve mode
|
|
94
|
-
command !== "serve" ? vitePluginCloseAndCopy() : void 0
|
|
95
|
-
]
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
module.exports = vite_backend_config;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const node_module = require("node:module");
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
const replace = require("@rollup/plugin-replace");
|
|
5
|
-
const vite = require("vite");
|
|
6
|
-
const noBundlePlugin = require("vite-plugin-no-bundle");
|
|
7
|
-
const tsconfigPaths = require("vite-tsconfig-paths");
|
|
8
|
-
const dependencies = require("../dependencies.cjs");
|
|
9
|
-
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
10
|
-
const vitePluginCopy = require("./vite-plugin-copy.cjs");
|
|
11
|
-
async function vite_commonjs_config(name, tsConfigPath, entry) {
|
|
12
|
-
console.info(`ViteCommonJSConfig: ${name}`);
|
|
13
|
-
const projectExternal = await dependencies.getExternalsFromReferences(tsConfigPath, [
|
|
14
|
-
/dev/
|
|
15
|
-
]);
|
|
16
|
-
const allExternal = [
|
|
17
|
-
...node_module.builtinModules,
|
|
18
|
-
...node_module.builtinModules.map((m) => `node:${m}`),
|
|
19
|
-
...projectExternal
|
|
20
|
-
];
|
|
21
|
-
return vite.defineConfig({
|
|
22
|
-
ssr: { external: allExternal },
|
|
23
|
-
plugins: [
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
replace({
|
|
26
|
-
"module": "module"
|
|
27
|
-
// Replaces ESM checks with CommonJS equivalent
|
|
28
|
-
}),
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
noBundlePlugin({
|
|
31
|
-
root: "src",
|
|
32
|
-
copy: "**/*.css"
|
|
33
|
-
}),
|
|
34
|
-
vitePluginCopy({
|
|
35
|
-
srcDir: "src",
|
|
36
|
-
destDir: "dist",
|
|
37
|
-
include: ["**/*.json"]
|
|
38
|
-
}),
|
|
39
|
-
tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }),
|
|
40
|
-
vitePluginCloseAndCopy()
|
|
41
|
-
],
|
|
42
|
-
build: {
|
|
43
|
-
emptyOutDir: false,
|
|
44
|
-
ssr: true,
|
|
45
|
-
target: "node18",
|
|
46
|
-
outDir: "dist/cjs",
|
|
47
|
-
lib: {
|
|
48
|
-
name,
|
|
49
|
-
formats: ["cjs"],
|
|
50
|
-
entry: entry || "src/index.ts"
|
|
51
|
-
// required
|
|
52
|
-
},
|
|
53
|
-
rollupOptions: {
|
|
54
|
-
treeshake: false,
|
|
55
|
-
external: allExternal
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
module.exports = vite_commonjs_config;
|
|
@@ -1,54 +0,0 @@
|
|
|
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,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const node_module = require("node:module");
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
const nodeResolve = require("@rollup/plugin-node-resolve");
|
|
5
|
-
const typescript = require("@rollup/plugin-typescript");
|
|
6
|
-
const pluginWasm = require("@rollup/plugin-wasm");
|
|
7
|
-
const viteReact = require("@vitejs/plugin-react");
|
|
8
|
-
const css = require("rollup-plugin-import-css");
|
|
9
|
-
const rollupPluginVisualizer = require("rollup-plugin-visualizer");
|
|
10
|
-
const vitePluginNodePolyfills = require("vite-plugin-node-polyfills");
|
|
11
|
-
const dependencies = require("../dependencies.cjs");
|
|
12
|
-
require("./index.cjs");
|
|
13
|
-
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
14
|
-
async function vite_frontend_config(packageName, bundleName, dir, entry, command, mode, copyOptions, tsConfigPaths, workspaceRoot) {
|
|
15
|
-
if (mode !== "production") {
|
|
16
|
-
mode = "development";
|
|
17
|
-
}
|
|
18
|
-
const allowedEnvironments = ["development", "staging", "production"];
|
|
19
|
-
const defaultEnvironment = process.env.NODE_ENV && allowedEnvironments.includes(process.env.NODE_ENV) ? process.env.NODE_ENV : mode;
|
|
20
|
-
console.info(`Running at ${dir} in ${mode} mode`);
|
|
21
|
-
const isProduction = mode === "production";
|
|
22
|
-
process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
|
|
23
|
-
console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
|
|
24
|
-
const define = {
|
|
25
|
-
// used to stop websockets package from breaking
|
|
26
|
-
"process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
|
|
27
|
-
"process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
|
|
28
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
|
29
|
-
"process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(defaultEnvironment),
|
|
30
|
-
"process.env.PROSOPO_SERVER_URL": JSON.stringify(
|
|
31
|
-
process.env.PROSOPO_SERVER_URL
|
|
32
|
-
),
|
|
33
|
-
"process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
|
|
34
|
-
process.env._DEV_ONLY_WATCH_EVENTS
|
|
35
|
-
),
|
|
36
|
-
"process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(
|
|
37
|
-
process.env.PROSOPO_MONGO_EVENTS_URI
|
|
38
|
-
),
|
|
39
|
-
"process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(
|
|
40
|
-
process.env.PROSOPO_PACKAGE_VERSION
|
|
41
|
-
),
|
|
42
|
-
"process.env.PROSOPO_DOCS_URL": JSON.stringify(
|
|
43
|
-
process.env.PROSOPO_DOCS_URL
|
|
44
|
-
),
|
|
45
|
-
"process.env.PROSOPO_LOG_LEVEL": JSON.stringify(
|
|
46
|
-
process.env.PROSOPO_LOG_LEVEL
|
|
47
|
-
),
|
|
48
|
-
// only needed if bundling with a site key
|
|
49
|
-
"process.env.PROSOPO_SITE_KEY": JSON.stringify(
|
|
50
|
-
process.env.PROSOPO_SITE_KEY
|
|
51
|
-
)
|
|
52
|
-
};
|
|
53
|
-
console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
|
|
54
|
-
const { dependencies: deps, optionalPeerDependencies } = await dependencies.getDependencies(packageName, isProduction);
|
|
55
|
-
const { external, internal } = dependencies.filterDependencies(deps, [
|
|
56
|
-
"pm2",
|
|
57
|
-
"nodejs-polars",
|
|
58
|
-
"aws",
|
|
59
|
-
"webpack",
|
|
60
|
-
"vite",
|
|
61
|
-
"i18next-fs-backend"
|
|
62
|
-
]);
|
|
63
|
-
const allExternal = [
|
|
64
|
-
...node_module.builtinModules,
|
|
65
|
-
...node_module.builtinModules.map((m) => `node:${m}`),
|
|
66
|
-
...external,
|
|
67
|
-
...optionalPeerDependencies
|
|
68
|
-
];
|
|
69
|
-
console.debug(
|
|
70
|
-
`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`
|
|
71
|
-
);
|
|
72
|
-
const proto = RegExp.prototype;
|
|
73
|
-
proto.toJSON = RegExp.prototype.toString;
|
|
74
|
-
let drop;
|
|
75
|
-
let pure = [];
|
|
76
|
-
if (isProduction) {
|
|
77
|
-
drop = ["debugger"];
|
|
78
|
-
pure = ["console.log", "console.warn", "console.info", "console.debug"];
|
|
79
|
-
}
|
|
80
|
-
const rollupExternal = allExternal;
|
|
81
|
-
console.info({ bundleName }, "Bundle name");
|
|
82
|
-
return {
|
|
83
|
-
server: {
|
|
84
|
-
host: "127.0.0.1"
|
|
85
|
-
},
|
|
86
|
-
mode: mode || "development",
|
|
87
|
-
optimizeDeps: {
|
|
88
|
-
include: ["node_modules"],
|
|
89
|
-
force: true
|
|
90
|
-
},
|
|
91
|
-
esbuild: {
|
|
92
|
-
platform: "browser",
|
|
93
|
-
target: [
|
|
94
|
-
"es2020",
|
|
95
|
-
"chrome60",
|
|
96
|
-
"edge18",
|
|
97
|
-
"firefox60",
|
|
98
|
-
"node22",
|
|
99
|
-
"safari11"
|
|
100
|
-
],
|
|
101
|
-
drop,
|
|
102
|
-
pure,
|
|
103
|
-
legalComments: "none"
|
|
104
|
-
},
|
|
105
|
-
define,
|
|
106
|
-
build: {
|
|
107
|
-
outDir: path.resolve(dir, "dist/bundle"),
|
|
108
|
-
minify: isProduction,
|
|
109
|
-
ssr: false,
|
|
110
|
-
lib: {
|
|
111
|
-
entry: path.resolve(dir, entry),
|
|
112
|
-
name: bundleName,
|
|
113
|
-
fileName: `${bundleName}.bundle.js`,
|
|
114
|
-
formats: ["es"]
|
|
115
|
-
},
|
|
116
|
-
modulePreload: { polyfill: true },
|
|
117
|
-
commonjsOptions: {
|
|
118
|
-
exclude: ["mongodb/*"],
|
|
119
|
-
transformMixedEsModules: true,
|
|
120
|
-
strictRequires: "debug"
|
|
121
|
-
},
|
|
122
|
-
rollupOptions: {
|
|
123
|
-
treeshake: {
|
|
124
|
-
annotations: false,
|
|
125
|
-
propertyReadSideEffects: false,
|
|
126
|
-
tryCatchDeoptimization: false,
|
|
127
|
-
moduleSideEffects: "no-external",
|
|
128
|
-
//true,
|
|
129
|
-
preset: "smallest",
|
|
130
|
-
unknownGlobalSideEffects: false
|
|
131
|
-
},
|
|
132
|
-
experimentalLogSideEffects: false,
|
|
133
|
-
external: rollupExternal,
|
|
134
|
-
watch: false,
|
|
135
|
-
output: {
|
|
136
|
-
dir: path.resolve(dir, "dist/bundle"),
|
|
137
|
-
entryFileNames: `${bundleName}.bundle.js`
|
|
138
|
-
},
|
|
139
|
-
plugins: [
|
|
140
|
-
vitePluginNodePolyfills.nodePolyfills({
|
|
141
|
-
include: ["crypto"]
|
|
142
|
-
}),
|
|
143
|
-
css(),
|
|
144
|
-
pluginWasm.wasm(),
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
nodeResolve({
|
|
147
|
-
browser: true,
|
|
148
|
-
preferBuiltins: false,
|
|
149
|
-
rootDir: path.resolve(dir, "../../"),
|
|
150
|
-
dedupe: ["react", "react-dom"],
|
|
151
|
-
modulesOnly: true
|
|
152
|
-
}),
|
|
153
|
-
rollupPluginVisualizer.visualizer({
|
|
154
|
-
open: true,
|
|
155
|
-
template: "treemap",
|
|
156
|
-
//'list',
|
|
157
|
-
gzipSize: true,
|
|
158
|
-
brotliSize: true
|
|
159
|
-
}),
|
|
160
|
-
// I think we can use this plugin to build all packages instead of relying on the tsc step that's
|
|
161
|
-
// currently a precursor in package.json. However, it fails for the following reason:
|
|
162
|
-
// https://github.com/rollup/plugins/issues/243
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
typescript({
|
|
165
|
-
tsconfig: path.resolve("./tsconfig.json"),
|
|
166
|
-
compilerOptions: { rootDir: path.resolve("./src") },
|
|
167
|
-
outDir: path.resolve(dir, "dist/bundle")
|
|
168
|
-
})
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
plugins: [
|
|
173
|
-
// Not sure if we need this plugin or not, it works without it
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
viteReact(),
|
|
176
|
-
// Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
|
|
177
|
-
// mode, in which case we don't want to close the bundler because it will close the server
|
|
178
|
-
command !== "serve" ? vitePluginCloseAndCopy(copyOptions) : void 0
|
|
179
|
-
]
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
module.exports = vite_frontend_config;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const path = require("node:path");
|
|
3
|
-
const tsconfigPaths = require("vite-tsconfig-paths");
|
|
4
|
-
const config = require("vitest/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) {
|
|
8
|
-
const testTypeEnv = process.env.TEST_TYPE || "";
|
|
9
|
-
const testTypes = testTypeEnv.trim().split(",");
|
|
10
|
-
const testTypeGlob = `@(|${testTypes.map((t) => t ? `.${t.trim()}` : "").join("|")})`;
|
|
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
|
-
}
|
|
19
|
-
return config.defineConfig({
|
|
20
|
-
build: {
|
|
21
|
-
minify: false,
|
|
22
|
-
sourcemap: false,
|
|
23
|
-
rollupOptions: {
|
|
24
|
-
maxParallelFileOps: 1,
|
|
25
|
-
cache: false,
|
|
26
|
-
output: {
|
|
27
|
-
sourcemap: false
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
test: {
|
|
32
|
-
//root: getRootDir(),
|
|
33
|
-
reporters: ["basic"],
|
|
34
|
-
include: [
|
|
35
|
-
`src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`
|
|
36
|
-
],
|
|
37
|
-
watch: false,
|
|
38
|
-
exclude: ["**/node_modules/**", "**/dist/**"],
|
|
39
|
-
logHeapUsage: true,
|
|
40
|
-
coverage: {
|
|
41
|
-
enabled: true,
|
|
42
|
-
include: ["packages/*/src/**"]
|
|
43
|
-
},
|
|
44
|
-
typecheck: {
|
|
45
|
-
enabled: true
|
|
46
|
-
},
|
|
47
|
-
pool: "forks",
|
|
48
|
-
// forks is slower than 'threads' but more compatible with low-level libs (e.g. bcrypt)
|
|
49
|
-
poolOptions: {
|
|
50
|
-
forks: {
|
|
51
|
-
isolate: true
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
testTimeout: 1e4
|
|
55
|
-
},
|
|
56
|
-
plugins
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
module.exports = vite_test_config;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
const fs = require("node:fs");
|
|
25
|
-
const path = require("node:path");
|
|
26
|
-
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
27
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
28
|
-
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
29
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
30
|
-
const moduleDirs = [path.resolve("./node_modules")];
|
|
31
|
-
function resolveEntryFile() {
|
|
32
|
-
const defaultEntry = "./src/index.tsx";
|
|
33
|
-
const supportedEntries = [defaultEntry, "./src/index.ts"];
|
|
34
|
-
return supportedEntries.find((entry) => fs.existsSync(path.resolve(entry))) || defaultEntry;
|
|
35
|
-
}
|
|
36
|
-
const webpack_config = (mode) => {
|
|
37
|
-
const isProduction = mode === "production";
|
|
38
|
-
const libraryName = "react_app";
|
|
39
|
-
return {
|
|
40
|
-
resolve: {
|
|
41
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".cjs"],
|
|
42
|
-
extensionAlias: {
|
|
43
|
-
".js": [".js", ".jsx", ".ts", ".tsx"]
|
|
44
|
-
},
|
|
45
|
-
modules: moduleDirs,
|
|
46
|
-
fullySpecified: false,
|
|
47
|
-
alias: {
|
|
48
|
-
"@polkadot/x-textdecoder": path.resolve(
|
|
49
|
-
"../../node_modules/@polkadot/util/node_modules/@polkadot/x-textdecoder"
|
|
50
|
-
),
|
|
51
|
-
"@polkadot/x-textencoder": path.resolve(
|
|
52
|
-
"../../node_modules/@polkadot/util/node_modules/@polkadot/x-textencoder"
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
externals: {
|
|
57
|
-
"node:url": "commonjs url",
|
|
58
|
-
url: "commonjs url",
|
|
59
|
-
"node:path": "commonjs path",
|
|
60
|
-
"node:fs": "commonjs fs"
|
|
61
|
-
},
|
|
62
|
-
entry: resolveEntryFile(),
|
|
63
|
-
output: {
|
|
64
|
-
filename: `${libraryName}.[name].bundle.js`,
|
|
65
|
-
path: path.resolve("./dist"),
|
|
66
|
-
publicPath: "/"
|
|
67
|
-
},
|
|
68
|
-
module: {
|
|
69
|
-
rules: [
|
|
70
|
-
// instead of using .babelrc, we can use babel-loader options
|
|
71
|
-
{
|
|
72
|
-
test: /\.(m?js|jsx|tsx|ts)$/,
|
|
73
|
-
exclude: /node_modules/,
|
|
74
|
-
use: {
|
|
75
|
-
loader: "babel-loader",
|
|
76
|
-
options: {
|
|
77
|
-
plugins: [
|
|
78
|
-
"@babel/plugin-transform-runtime",
|
|
79
|
-
"@babel/transform-class-properties",
|
|
80
|
-
"@babel/transform-object-rest-spread",
|
|
81
|
-
"@babel/plugin-transform-react-jsx",
|
|
82
|
-
[
|
|
83
|
-
"@babel/plugin-syntax-import-attributes",
|
|
84
|
-
{ deprecatedAssertSyntax: true }
|
|
85
|
-
]
|
|
86
|
-
],
|
|
87
|
-
presets: ["@babel/preset-env", "@babel/preset-typescript"]
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
include: /node_modules|src/,
|
|
93
|
-
test: /\.css$/,
|
|
94
|
-
resolve: {
|
|
95
|
-
fullySpecified: false
|
|
96
|
-
},
|
|
97
|
-
sideEffects: true,
|
|
98
|
-
use: [
|
|
99
|
-
MiniCssExtractPlugin.loader,
|
|
100
|
-
{
|
|
101
|
-
loader: require.resolve("css-loader"),
|
|
102
|
-
options: {
|
|
103
|
-
url: false
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
test: /locale\.json$/,
|
|
110
|
-
// match JSON files to optimize
|
|
111
|
-
loader: "webpack-json-access-optimizer"
|
|
112
|
-
},
|
|
113
|
-
// Fix for module
|
|
114
|
-
{
|
|
115
|
-
test: /packageInfo.js$/,
|
|
116
|
-
loader: "string-replace-loader",
|
|
117
|
-
options: {
|
|
118
|
-
search: /import\.meta && import\.meta\.url/g,
|
|
119
|
-
replace: "false"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
},
|
|
124
|
-
plugins: [
|
|
125
|
-
new NodePolyfillPlugin(),
|
|
126
|
-
new HtmlWebpackPlugin({
|
|
127
|
-
template: "./src/index.html"
|
|
128
|
-
}),
|
|
129
|
-
new MiniCssExtractPlugin({
|
|
130
|
-
filename: "extr.[contenthash].css"
|
|
131
|
-
})
|
|
132
|
-
],
|
|
133
|
-
optimization: {
|
|
134
|
-
noEmitOnErrors: true,
|
|
135
|
-
minimize: isProduction,
|
|
136
|
-
minimizer: isProduction ? [
|
|
137
|
-
new TerserPlugin({
|
|
138
|
-
terserOptions: {
|
|
139
|
-
compress: {
|
|
140
|
-
drop_console: true
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
] : [],
|
|
145
|
-
usedExports: true
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
module.exports = webpack_config;
|
package/vite.cjs.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
import ViteCommonJSConfig from "./src/vite/vite.commonjs.config.js";
|
|
16
|
-
|
|
17
|
-
export default function () {
|
|
18
|
-
return ViteCommonJSConfig(
|
|
19
|
-
path.basename("."),
|
|
20
|
-
path.resolve("./tsconfig.json"),
|
|
21
|
-
);
|
|
22
|
-
}
|