@prosopo/config 3.1.3 → 3.1.20
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 +91 -0
- package/dist/cjs/dependencies.cjs +156 -0
- package/dist/cjs/index.cjs +33 -0
- package/dist/cjs/vite/TsNoCheckPlugin.cjs +18 -0
- package/dist/cjs/vite/index.cjs +26 -0
- package/dist/cjs/vite/vite-plugin-close-and-copy.cjs +46 -0
- package/dist/cjs/vite/vite-plugin-copy.cjs +42 -0
- package/dist/cjs/vite/vite-plugin-fix-absolute-imports.cjs +26 -0
- package/dist/cjs/vite/vite-plugin-remove-unused-translations.cjs +81 -0
- package/dist/cjs/vite/vite-plugin-sourcemap-exclude.cjs +17 -0
- package/dist/cjs/vite/vite.backend.config.cjs +99 -0
- package/dist/cjs/vite/vite.commonjs.config.cjs +65 -0
- package/dist/cjs/vite/vite.esm.config.cjs +70 -0
- package/dist/cjs/vite/vite.frontend.config.cjs +203 -0
- package/dist/cjs/vite/vite.test.config.cjs +78 -0
- package/dist/cjs/vite/vite.threads.test.config.cjs +79 -0
- package/dist/cjs/webpack/index.cjs +2 -0
- package/dist/cjs/webpack/webpack.config.cjs +149 -0
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +7 -6
- package/dist/index.js +18 -16
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +18 -16
- package/dist/vite/vite.backend.config.d.ts.map +1 -1
- package/dist/vite/vite.backend.config.js +1 -0
- package/dist/vite/vite.commonjs.config.d.ts.map +1 -1
- package/dist/vite/vite.commonjs.config.js +5 -0
- package/dist/vite/vite.esm.config.d.ts.map +1 -1
- package/dist/vite/vite.esm.config.js +17 -1
- package/dist/vite/vite.frontend.config.d.ts.map +1 -1
- package/dist/vite/vite.frontend.config.js +22 -1
- package/dist/vite/vite.test.config.d.ts.map +1 -1
- package/dist/vite/vite.test.config.js +26 -7
- package/dist/vite/vite.threads.test.config.d.ts +2 -0
- package/dist/vite/vite.threads.test.config.d.ts.map +1 -0
- package/dist/vite/vite.threads.test.config.js +80 -0
- package/package.json +27 -30
- package/vite.cjs.config.ts +22 -0
- package/dist/dependencies.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/vite/NodejsPolarsDirnamePlugin.js +0 -22
- package/dist/vite/NodejsPolarsDirnamePlugin.js.map +0 -1
- package/dist/vite/NodejsPolarsNativeFilePlugin.js +0 -58
- package/dist/vite/NodejsPolarsNativeFilePlugin.js.map +0 -1
- package/dist/vite/TsNoCheckPlugin.js.map +0 -1
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/types.js +0 -2
- package/dist/vite/types.js.map +0 -1
- package/dist/vite/vite-plugin-close-and-copy.js.map +0 -1
- package/dist/vite/vite-plugin-copy.js.map +0 -1
- package/dist/vite/vite-plugin-fix-absolute-imports.js.map +0 -1
- package/dist/vite/vite-plugin-remove-unused-translations.js.map +0 -1
- package/dist/vite/vite-plugin-sourcemap-exclude.js.map +0 -1
- package/dist/vite/vite.backend.config.js.map +0 -1
- package/dist/vite/vite.commonjs.config.js.map +0 -1
- package/dist/vite/vite.esm.config.js.map +0 -1
- package/dist/vite/vite.frontend.config.js.map +0 -1
- package/dist/vite/vite.test.config.js.map +0 -1
- package/dist/webpack/index.js.map +0 -1
- package/dist/webpack/webpack.config.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
esbuild: {
|
|
59
|
+
jsx: "automatic",
|
|
60
|
+
jsxImportSource: "@emotion/react",
|
|
61
|
+
jsxDev: process.env.NODE_ENV === "development"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
module.exports = vite_commonjs_config;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
// Webpack dependencies - should not be bundled by Vite
|
|
20
|
+
"html-webpack-plugin",
|
|
21
|
+
"mini-css-extract-plugin",
|
|
22
|
+
"node-polyfill-webpack-plugin",
|
|
23
|
+
"terser-webpack-plugin",
|
|
24
|
+
"webpack",
|
|
25
|
+
"webpack-dev-server",
|
|
26
|
+
"webpack-json-access-optimizer",
|
|
27
|
+
"babel-loader",
|
|
28
|
+
"css-loader",
|
|
29
|
+
"string-replace-loader"
|
|
30
|
+
];
|
|
31
|
+
return vite.defineConfig({
|
|
32
|
+
ssr: { external: allExternal },
|
|
33
|
+
plugins: [
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
noBundlePlugin({
|
|
36
|
+
root: "src",
|
|
37
|
+
copy: "**/*.css"
|
|
38
|
+
}),
|
|
39
|
+
vitePluginCopy({
|
|
40
|
+
srcDir: "src",
|
|
41
|
+
destDir: "dist",
|
|
42
|
+
include: ["**/*.json"]
|
|
43
|
+
}),
|
|
44
|
+
tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }),
|
|
45
|
+
vitePluginCloseAndCopy()
|
|
46
|
+
],
|
|
47
|
+
build: {
|
|
48
|
+
emptyOutDir: false,
|
|
49
|
+
ssr: true,
|
|
50
|
+
target: "node18",
|
|
51
|
+
outDir: "dist",
|
|
52
|
+
lib: {
|
|
53
|
+
name,
|
|
54
|
+
formats: ["es"],
|
|
55
|
+
entry: entry || "src/index.ts"
|
|
56
|
+
// required
|
|
57
|
+
},
|
|
58
|
+
rollupOptions: {
|
|
59
|
+
treeshake: false,
|
|
60
|
+
external: allExternal
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
esbuild: {
|
|
64
|
+
jsx: "automatic",
|
|
65
|
+
jsxImportSource: "@emotion/react",
|
|
66
|
+
jsxDev: process.env.NODE_ENV === "development"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
module.exports = vite_esm_config;
|
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
jsx: "automatic",
|
|
105
|
+
jsxImportSource: "@emotion/react",
|
|
106
|
+
jsxDev: process.env.NODE_ENV === "development"
|
|
107
|
+
},
|
|
108
|
+
define,
|
|
109
|
+
build: {
|
|
110
|
+
outDir: path.resolve(dir, "dist/bundle"),
|
|
111
|
+
minify: isProduction,
|
|
112
|
+
ssr: false,
|
|
113
|
+
lib: {
|
|
114
|
+
entry: path.resolve(dir, entry),
|
|
115
|
+
name: bundleName,
|
|
116
|
+
fileName: `${bundleName}.bundle.js`,
|
|
117
|
+
formats: ["es"]
|
|
118
|
+
},
|
|
119
|
+
modulePreload: { polyfill: true },
|
|
120
|
+
commonjsOptions: {
|
|
121
|
+
exclude: ["mongodb/*"],
|
|
122
|
+
transformMixedEsModules: true,
|
|
123
|
+
strictRequires: "debug"
|
|
124
|
+
},
|
|
125
|
+
rollupOptions: {
|
|
126
|
+
treeshake: {
|
|
127
|
+
annotations: false,
|
|
128
|
+
propertyReadSideEffects: false,
|
|
129
|
+
tryCatchDeoptimization: false,
|
|
130
|
+
moduleSideEffects: "no-external",
|
|
131
|
+
//true,
|
|
132
|
+
preset: "smallest",
|
|
133
|
+
unknownGlobalSideEffects: false
|
|
134
|
+
},
|
|
135
|
+
experimentalLogSideEffects: false,
|
|
136
|
+
external: rollupExternal,
|
|
137
|
+
watch: false,
|
|
138
|
+
output: {
|
|
139
|
+
dir: path.resolve(dir, "dist/bundle"),
|
|
140
|
+
entryFileNames: `${bundleName}.bundle.js`
|
|
141
|
+
},
|
|
142
|
+
plugins: [
|
|
143
|
+
vitePluginNodePolyfills.nodePolyfills({
|
|
144
|
+
include: ["crypto"]
|
|
145
|
+
}),
|
|
146
|
+
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
147
|
+
css(),
|
|
148
|
+
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
149
|
+
pluginWasm.wasm(),
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
nodeResolve({
|
|
152
|
+
browser: true,
|
|
153
|
+
preferBuiltins: false,
|
|
154
|
+
rootDir: path.resolve(dir, "../../"),
|
|
155
|
+
dedupe: ["react", "react-dom"],
|
|
156
|
+
modulesOnly: true
|
|
157
|
+
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
158
|
+
}),
|
|
159
|
+
// String replacement plugin for fingerprinting code
|
|
160
|
+
{
|
|
161
|
+
name: "string-replace-fingerprint",
|
|
162
|
+
generateBundle(_, bundle) {
|
|
163
|
+
for (const fileName in bundle) {
|
|
164
|
+
const chunk = bundle[fileName];
|
|
165
|
+
if (chunk && chunk.type === "chunk" && "code" in chunk && chunk.code) {
|
|
166
|
+
chunk.code = chunk.code.replace(
|
|
167
|
+
/var request = new XMLHttpRequest\(\);\s*request\.open\("get", "https:\/\/m1\.openfpcdn\.io\/fingerprintjs\/v"\.concat\(version, "\/npm-monitoring"\), true\);\s*request\.send\(\);/g,
|
|
168
|
+
""
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
rollupPluginVisualizer.visualizer({
|
|
175
|
+
open: true,
|
|
176
|
+
template: "treemap",
|
|
177
|
+
//'list',
|
|
178
|
+
gzipSize: true,
|
|
179
|
+
brotliSize: true
|
|
180
|
+
}),
|
|
181
|
+
// I think we can use this plugin to build all packages instead of relying on the tsc step that's
|
|
182
|
+
// currently a precursor in package.json. However, it fails for the following reason:
|
|
183
|
+
// https://github.com/rollup/plugins/issues/243
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
typescript({
|
|
186
|
+
tsconfig: path.resolve("./tsconfig.json"),
|
|
187
|
+
compilerOptions: { rootDir: path.resolve("./src") },
|
|
188
|
+
outDir: path.resolve(dir, "dist/bundle")
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
plugins: [
|
|
194
|
+
// Not sure if we need this plugin or not, it works without it
|
|
195
|
+
// @ts-ignore
|
|
196
|
+
viteReact(),
|
|
197
|
+
// Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
|
|
198
|
+
// mode, in which case we don't want to close the bundler because it will close the server
|
|
199
|
+
command !== "serve" ? vitePluginCloseAndCopy(copyOptions) : void 0
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
module.exports = vite_frontend_config;
|
|
@@ -0,0 +1,78 @@
|
|
|
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 || void 0;
|
|
9
|
+
console.log(`TEST_TYPE environment variable: ${testTypeEnv}`);
|
|
10
|
+
const testTypes = testTypeEnv ? testTypeEnv.trim().split(",") : [];
|
|
11
|
+
const testTypeGlob = testTypes.length > 0 ? `@(${testTypes.map((t) => `.${t}`).join("|")})` : "@(|)";
|
|
12
|
+
console.log(`Filtering tests by type: ${testTypeGlob}`);
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const isRunningFromPackage = cwd.includes("/packages/") && cwd.includes("/src") === false;
|
|
15
|
+
const coverageInclude = isRunningFromPackage ? ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx"] : ["packages/*/src/**", "captcha/packages/*/src/**"];
|
|
16
|
+
const coverageExclude = isRunningFromPackage ? [
|
|
17
|
+
"src/tests/**/*",
|
|
18
|
+
"src/**/*.d.ts",
|
|
19
|
+
"src/**/*.test.ts",
|
|
20
|
+
"src/**/*.spec.ts",
|
|
21
|
+
"src/**/*.test.tsx",
|
|
22
|
+
"src/**/*.spec.tsx"
|
|
23
|
+
] : [
|
|
24
|
+
"**/tests/**/*",
|
|
25
|
+
"**/*.d.ts",
|
|
26
|
+
"**/*.test.*",
|
|
27
|
+
"**/*.spec.*",
|
|
28
|
+
"**/node_modules/**",
|
|
29
|
+
"**/dist/**"
|
|
30
|
+
];
|
|
31
|
+
const include = `src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`;
|
|
32
|
+
const plugins = [
|
|
33
|
+
vitePluginSourcemapExclude({ excludeNodeModules: true }),
|
|
34
|
+
vitePluginCloseAndCopy()
|
|
35
|
+
];
|
|
36
|
+
if (tsConfigPath) {
|
|
37
|
+
plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
|
|
38
|
+
}
|
|
39
|
+
return config.defineConfig({
|
|
40
|
+
build: {
|
|
41
|
+
minify: false,
|
|
42
|
+
sourcemap: false,
|
|
43
|
+
rollupOptions: {
|
|
44
|
+
maxParallelFileOps: 1,
|
|
45
|
+
cache: false,
|
|
46
|
+
output: {
|
|
47
|
+
sourcemap: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
test: {
|
|
52
|
+
//root: getRootDir(),
|
|
53
|
+
reporters: ["basic"],
|
|
54
|
+
include: [include],
|
|
55
|
+
watch: false,
|
|
56
|
+
exclude: ["**/node_modules/**", "**/dist/**"],
|
|
57
|
+
logHeapUsage: true,
|
|
58
|
+
coverage: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
include: coverageInclude,
|
|
61
|
+
exclude: coverageExclude
|
|
62
|
+
},
|
|
63
|
+
typecheck: {
|
|
64
|
+
enabled: true
|
|
65
|
+
},
|
|
66
|
+
pool: "forks",
|
|
67
|
+
// forks is slower than 'threads' but more compatible with low-level libs (e.g. bcrypt)
|
|
68
|
+
poolOptions: {
|
|
69
|
+
forks: {
|
|
70
|
+
isolate: true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
testTimeout: 1e4
|
|
74
|
+
},
|
|
75
|
+
plugins
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
module.exports = vite_test_config;
|
|
@@ -0,0 +1,79 @@
|
|
|
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_threads_test_config(tsConfigPath) {
|
|
8
|
+
const testTypeEnv = process.env.TEST_TYPE || void 0;
|
|
9
|
+
console.log(`TEST_TYPE environment variable: ${testTypeEnv}`);
|
|
10
|
+
const testTypes = testTypeEnv ? testTypeEnv.trim().split(",") : [];
|
|
11
|
+
const testTypeGlob = testTypes.length > 0 ? `@(${testTypes.map((t) => `.${t}`).join("|")})` : "@(|)";
|
|
12
|
+
console.log(`Filtering tests by type: ${testTypeGlob}`);
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const isRunningFromPackage = cwd.includes("/packages/") && cwd.includes("/src") === false;
|
|
15
|
+
const coverageInclude = isRunningFromPackage ? ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx"] : ["packages/*/src/**", "captcha/packages/*/src/**"];
|
|
16
|
+
const coverageExclude = isRunningFromPackage ? [
|
|
17
|
+
"src/tests/**/*",
|
|
18
|
+
"src/**/*.d.ts",
|
|
19
|
+
"src/**/*.test.ts",
|
|
20
|
+
"src/**/*.spec.ts",
|
|
21
|
+
"src/**/*.test.tsx",
|
|
22
|
+
"src/**/*.spec.tsx"
|
|
23
|
+
] : [
|
|
24
|
+
"**/tests/**/*",
|
|
25
|
+
"**/*.d.ts",
|
|
26
|
+
"**/*.test.*",
|
|
27
|
+
"**/*.spec.*",
|
|
28
|
+
"**/node_modules/**",
|
|
29
|
+
"**/dist/**"
|
|
30
|
+
];
|
|
31
|
+
const include = `src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`;
|
|
32
|
+
const plugins = [
|
|
33
|
+
vitePluginSourcemapExclude({ excludeNodeModules: true }),
|
|
34
|
+
vitePluginCloseAndCopy()
|
|
35
|
+
];
|
|
36
|
+
if (tsConfigPath) {
|
|
37
|
+
plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
|
|
38
|
+
}
|
|
39
|
+
return config.defineConfig({
|
|
40
|
+
build: {
|
|
41
|
+
minify: false,
|
|
42
|
+
sourcemap: false,
|
|
43
|
+
rollupOptions: {
|
|
44
|
+
maxParallelFileOps: 1,
|
|
45
|
+
cache: false,
|
|
46
|
+
output: {
|
|
47
|
+
sourcemap: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
test: {
|
|
52
|
+
//root: getRootDir(),
|
|
53
|
+
reporters: ["basic"],
|
|
54
|
+
include: [include],
|
|
55
|
+
watch: false,
|
|
56
|
+
exclude: ["**/node_modules/**", "**/dist/**"],
|
|
57
|
+
logHeapUsage: true,
|
|
58
|
+
coverage: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
include: coverageInclude,
|
|
61
|
+
exclude: coverageExclude
|
|
62
|
+
},
|
|
63
|
+
typecheck: {
|
|
64
|
+
enabled: true
|
|
65
|
+
},
|
|
66
|
+
pool: "threads",
|
|
67
|
+
// use threads for tests that should be run sequentially
|
|
68
|
+
poolOptions: {
|
|
69
|
+
threads: {
|
|
70
|
+
minThreads: 1,
|
|
71
|
+
maxThreads: 1
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
testTimeout: 1e4
|
|
75
|
+
},
|
|
76
|
+
plugins
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
module.exports = vite_threads_test_config;
|
|
@@ -0,0 +1,149 @@
|
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAuEA,wBAAgB,YAAY,CAC3B,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,EAC7B,aAAa,GAAE,MAAM,EAAO,EAC5B,sBAAsB,UAAO,GAC3B,MAAM,EAAE,CA4CV;AAOD,wBAAsB,0BAA0B,CAC/C,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAOD,wBAAsB,eAAe,CACpC,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,wBAAwB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAuEA,wBAAgB,YAAY,CAC3B,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,EAC7B,aAAa,GAAE,MAAM,EAAO,EAC5B,sBAAsB,UAAO,GAC3B,MAAM,EAAE,CA4CV;AAOD,wBAAsB,0BAA0B,CAC/C,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAOD,wBAAsB,eAAe,CACpC,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,wBAAwB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6CzE;AAOD,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,EAAE,GACf;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAe5C"}
|
package/dist/dependencies.js
CHANGED
|
@@ -106,13 +106,12 @@ async function getDependencies(packageName, production) {
|
|
|
106
106
|
cmd = `cd ${packageDir.trim()} && ${cmd}`;
|
|
107
107
|
console.info(`Running command ${cmd} in ${packageDir}`);
|
|
108
108
|
}
|
|
109
|
+
let concat = "";
|
|
109
110
|
const { stdout, stderr } = await exec(cmd);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const peerDeps = [];
|
|
115
|
-
for (const line of stdout.split("\n")) {
|
|
111
|
+
concat = stdout + stderr;
|
|
112
|
+
let deps = [];
|
|
113
|
+
let peerDeps = [];
|
|
114
|
+
for (const line of concat.split("\n")) {
|
|
116
115
|
if (line.includes("UNMET OPTIONAL DEPENDENCY")) {
|
|
117
116
|
const parts = line.match(peerDepsRegex);
|
|
118
117
|
if (parts && parts.length > 1) {
|
|
@@ -125,6 +124,8 @@ async function getDependencies(packageName, production) {
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
}
|
|
127
|
+
deps = [...new Set(deps)];
|
|
128
|
+
peerDeps = [...new Set(peerDeps)];
|
|
128
129
|
return {
|
|
129
130
|
dependencies: deps.filter((x, i) => i === deps.indexOf(x)),
|
|
130
131
|
optionalPeerDependencies: peerDeps.filter(
|