@prosopo/config 3.4.2 → 3.4.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/.turbo/turbo-build$colon$cjs.log +5 -8
- package/.turbo/turbo-build$colon$tsc.log +4 -7
- package/.turbo/turbo-build.log +6 -12
- package/CHANGELOG.md +13 -0
- package/LICENSE +201 -0
- package/dist/cjs/dependencies.cjs +86 -46
- package/dist/cjs/vite/vite.frontend.config.cjs +7 -0
- package/dist/cjs/webpack/webpack.config.cjs +8 -8
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +85 -44
- package/dist/dependencies.js.map +1 -1
- package/dist/getDependencies.test.js +151 -125
- package/dist/getDependencies.test.js.map +1 -1
- package/dist/vite/vite.frontend.config.d.ts.map +1 -1
- package/dist/vite/vite.frontend.config.js +8 -1
- package/dist/vite/vite.frontend.config.js.map +1 -1
- package/dist/webpack/webpack.config.d.ts +2 -0
- package/dist/webpack/webpack.config.d.ts.map +1 -1
- package/dist/webpack/webpack.config.js +8 -8
- package/dist/webpack/webpack.config.js.map +1 -1
- package/package.json +106 -103
- package/src/dependencies.test.ts +0 -249
- package/src/dependencies.ts +0 -259
- package/src/getDependencies.test.ts +0 -385
- package/src/index.ts +0 -16
- package/src/vite/CopyAssetsPlugin.ts +0 -49
- package/src/vite/NodejsPolarsDirnamePlugin.ts +0 -50
- package/src/vite/NodejsPolarsNativeFilePlugin.ts +0 -105
- package/src/vite/TsNoCheckPlugin.ts +0 -31
- package/src/vite/bundleConfigs.test.ts +0 -461
- package/src/vite/configs.test.ts +0 -223
- package/src/vite/index.ts +0 -30
- package/src/vite/modifyExportsFiles.test.ts +0 -56
- package/src/vite/plugins.test.ts +0 -365
- package/src/vite/testFileGlobs.test.ts +0 -162
- package/src/vite/testFileGlobs.ts +0 -57
- package/src/vite/translations.test.ts +0 -164
- package/src/vite/types.ts +0 -13
- package/src/vite/vite-plugin-close-and-copy.ts +0 -76
- package/src/vite/vite-plugin-copy.ts +0 -67
- package/src/vite/vite-plugin-externalize-obfuscator-deadcode.ts +0 -43
- package/src/vite/vite-plugin-fix-absolute-imports.ts +0 -40
- package/src/vite/vite-plugin-modify-exports-files.ts +0 -64
- package/src/vite/vite-plugin-remove-unused-translations.ts +0 -128
- package/src/vite/vite-plugin-sourcemap-exclude.ts +0 -36
- package/src/vite/vite.backend.config.ts +0 -172
- package/src/vite/vite.commonjs.config.ts +0 -98
- package/src/vite/vite.esm.config.ts +0 -99
- package/src/vite/vite.frontend.config.ts +0 -340
- package/src/vite/vite.test.config.ts +0 -115
- package/src/vite/vite.threads.test.config.ts +0 -100
- package/src/webpack/index.ts +0 -14
- package/src/webpack/webpack.config.ts +0 -159
- package/tsconfig.cjs.json +0 -9
- package/tsconfig.json +0 -17
- package/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.types.json +0 -9
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
import { builtinModules } from "node:module";
|
|
16
|
-
import path from "node:path";
|
|
17
|
-
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
18
|
-
import typescript from "@rollup/plugin-typescript";
|
|
19
|
-
import { wasm } from "@rollup/plugin-wasm";
|
|
20
|
-
import { default as viteReact } from "@vitejs/plugin-react";
|
|
21
|
-
import type { Drop } from "esbuild";
|
|
22
|
-
import type { ExternalOption } from "rollup";
|
|
23
|
-
import css from "rollup-plugin-import-css";
|
|
24
|
-
import { visualizer } from "rollup-plugin-visualizer";
|
|
25
|
-
import type { UserConfig } from "vite";
|
|
26
|
-
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
27
|
-
import { filterDependencies, getDependencies } from "../dependencies.js";
|
|
28
|
-
import { VitePluginCloseAndCopy } from "./index.js";
|
|
29
|
-
import type { ClosePluginOptions } from "./vite-plugin-close-and-copy.js";
|
|
30
|
-
import VitePluginExternalizeObfuscatorDeadCode from "./vite-plugin-externalize-obfuscator-deadcode.js";
|
|
31
|
-
|
|
32
|
-
export default async function (
|
|
33
|
-
packageName: string,
|
|
34
|
-
bundleName: string,
|
|
35
|
-
dir: string,
|
|
36
|
-
entry: string,
|
|
37
|
-
command?: string,
|
|
38
|
-
mode?: string,
|
|
39
|
-
copyOptions?: ClosePluginOptions,
|
|
40
|
-
tsConfigPaths?: string[],
|
|
41
|
-
workspaceRoot?: string,
|
|
42
|
-
): Promise<UserConfig> {
|
|
43
|
-
// Only development and production modes are allowed
|
|
44
|
-
if (mode !== "production") {
|
|
45
|
-
mode = "development";
|
|
46
|
-
}
|
|
47
|
-
// We don't have a default environment of, for example, `test` so we use the `mode` as the default
|
|
48
|
-
const allowedEnvironments = ["development", "staging", "production"];
|
|
49
|
-
const defaultEnvironment =
|
|
50
|
-
process.env.NODE_ENV && allowedEnvironments.includes(process.env.NODE_ENV)
|
|
51
|
-
? process.env.NODE_ENV
|
|
52
|
-
: mode;
|
|
53
|
-
|
|
54
|
-
console.info(`Running at ${dir} in ${mode} mode`);
|
|
55
|
-
const isProduction = mode === "production";
|
|
56
|
-
// Rollup bundle stats (rollup-plugin-visualizer treemap). Off by default —
|
|
57
|
-
// set PROSOPO_BUNDLE_STATS=true to generate the stats page and open it in
|
|
58
|
-
// the browser once the bundle has been built.
|
|
59
|
-
const openBundleStats =
|
|
60
|
-
process.env.PROSOPO_BUNDLE_STATS?.trim().toLowerCase() === "true";
|
|
61
|
-
// NODE_ENV must be wrapped in quotes.
|
|
62
|
-
// If NODE_ENV ends up out of sync (one set to development and the other set to production), it causes
|
|
63
|
-
// issues like this: https://github.com/hashicorp/next-mdx-remote/pull/323
|
|
64
|
-
process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
|
|
65
|
-
console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
|
|
66
|
-
|
|
67
|
-
// Set the env vars that we want to be available in the browser
|
|
68
|
-
const define = {
|
|
69
|
-
// used to stop websockets package from breaking
|
|
70
|
-
"process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
|
|
71
|
-
"process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
|
|
72
|
-
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
|
73
|
-
"process.env.PROSOPO_DEFAULT_ENVIRONMENT":
|
|
74
|
-
JSON.stringify(defaultEnvironment),
|
|
75
|
-
"process.env.PROSOPO_SERVER_URL": JSON.stringify(
|
|
76
|
-
process.env.PROSOPO_SERVER_URL,
|
|
77
|
-
),
|
|
78
|
-
// Lets a development widget reach a provider that is not on the machine
|
|
79
|
-
// serving the page — a phone or simulator testing over the LAN would
|
|
80
|
-
// otherwise resolve the default `localhost` to itself.
|
|
81
|
-
"process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT": JSON.stringify(
|
|
82
|
-
process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT,
|
|
83
|
-
),
|
|
84
|
-
// Points a self-hosted build at its own providers regardless of
|
|
85
|
-
// environment, so a production bundle no longer has to masquerade as a
|
|
86
|
-
// development build to be redirected.
|
|
87
|
-
"process.env.PROSOPO_PROVIDER_LIST": JSON.stringify(
|
|
88
|
-
process.env.PROSOPO_PROVIDER_LIST,
|
|
89
|
-
),
|
|
90
|
-
"process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
|
|
91
|
-
process.env._DEV_ONLY_WATCH_EVENTS,
|
|
92
|
-
),
|
|
93
|
-
"process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(
|
|
94
|
-
process.env.PROSOPO_MONGO_EVENTS_URI,
|
|
95
|
-
),
|
|
96
|
-
"process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(
|
|
97
|
-
process.env.PROSOPO_PACKAGE_VERSION,
|
|
98
|
-
),
|
|
99
|
-
"process.env.PROSOPO_DOCS_URL": JSON.stringify(
|
|
100
|
-
process.env.PROSOPO_DOCS_URL,
|
|
101
|
-
),
|
|
102
|
-
"process.env.PROSOPO_LOG_LEVEL": JSON.stringify(
|
|
103
|
-
process.env.PROSOPO_LOG_LEVEL,
|
|
104
|
-
),
|
|
105
|
-
// only needed if bundling with a site key
|
|
106
|
-
"process.env.PROSOPO_SITE_KEY": JSON.stringify(
|
|
107
|
-
process.env.PROSOPO_SITE_KEY,
|
|
108
|
-
),
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
|
|
112
|
-
|
|
113
|
-
// Get all dependencies of the current package
|
|
114
|
-
const { dependencies: deps, optionalPeerDependencies } =
|
|
115
|
-
await getDependencies(packageName, isProduction);
|
|
116
|
-
|
|
117
|
-
// Get rid of any dependencies we don't want to bundle.
|
|
118
|
-
// The two i18next entries are server-only: the fs backend reads locale JSON
|
|
119
|
-
// off disk and the middleware is Express request handling. Neither can run
|
|
120
|
-
// in a browser — `i18nBackend.ts` also imports `node:path`, which is already
|
|
121
|
-
// external — so they are pure weight in a frontend bundle. The other
|
|
122
|
-
// i18next-* packages (http-backend, browser-languagedetector,
|
|
123
|
-
// chained-backend, resources-to-backend) ARE used in the browser and must
|
|
124
|
-
// stay bundled; these filters are substring matches, so they catch only
|
|
125
|
-
// themselves.
|
|
126
|
-
const { external, internal } = filterDependencies(deps, [
|
|
127
|
-
"pm2",
|
|
128
|
-
"nodejs-polars",
|
|
129
|
-
"aws",
|
|
130
|
-
"webpack",
|
|
131
|
-
"vite",
|
|
132
|
-
"i18next-fs-backend",
|
|
133
|
-
"i18next-http-middleware",
|
|
134
|
-
]);
|
|
135
|
-
|
|
136
|
-
// `external` only ever matches a specifier exactly, so listing a package by
|
|
137
|
-
// name does nothing for a subpath import of it. `i18next-fs-backend` has
|
|
138
|
-
// been on the exclusion list above for a long time, but `i18nBackend.ts`
|
|
139
|
-
// imports `i18next-fs-backend/cjs` (see i18next/i18next-fs-backend#57) —
|
|
140
|
-
// a different string — so it was bundled anyway, dragging its YAML, JSON5
|
|
141
|
-
// and JSONC parsers into the browser artifact.
|
|
142
|
-
//
|
|
143
|
-
// Listed literally rather than by matching `pkg/*` against the whole
|
|
144
|
-
// exclusion list: that broader rule also catches
|
|
145
|
-
// `vite-plugin-node-polyfills/shims/process` (the `vite` filter is a
|
|
146
|
-
// substring match, so it selects the plugin package too). That specifier is
|
|
147
|
-
// injected into the served and IIFE bundles as a bare import, and
|
|
148
|
-
// externalising it leaves the browser unable to resolve it — the widget dies
|
|
149
|
-
// on load with "Failed to resolve module specifier".
|
|
150
|
-
const serverOnlySubpaths = ["i18next-fs-backend/cjs"];
|
|
151
|
-
|
|
152
|
-
// Add the node builtins (path, fs, os, etc.) to the external list
|
|
153
|
-
const allExternal = [
|
|
154
|
-
...builtinModules,
|
|
155
|
-
...builtinModules.map((m) => `node:${m}`),
|
|
156
|
-
...external,
|
|
157
|
-
...optionalPeerDependencies,
|
|
158
|
-
...serverOnlySubpaths,
|
|
159
|
-
];
|
|
160
|
-
console.debug(
|
|
161
|
-
`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`,
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
// Required to print RegExp in console (e.g. alias keys)
|
|
165
|
-
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
166
|
-
const proto = RegExp.prototype as any;
|
|
167
|
-
proto.toJSON = RegExp.prototype.toString;
|
|
168
|
-
|
|
169
|
-
// drop console logs if in production mode
|
|
170
|
-
let drop: undefined | Drop[];
|
|
171
|
-
let pure: string[] = [];
|
|
172
|
-
if (isProduction) {
|
|
173
|
-
drop = ["debugger"];
|
|
174
|
-
pure = ["console.log", "console.warn", "console.info", "console.debug"];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const rollupExternal: ExternalOption = allExternal;
|
|
178
|
-
|
|
179
|
-
console.info({ bundleName }, "Bundle name");
|
|
180
|
-
return {
|
|
181
|
-
server: {
|
|
182
|
-
host: "127.0.0.1",
|
|
183
|
-
},
|
|
184
|
-
mode: mode || "development",
|
|
185
|
-
optimizeDeps: {
|
|
186
|
-
include: ["node_modules"],
|
|
187
|
-
force: true,
|
|
188
|
-
},
|
|
189
|
-
worker: {
|
|
190
|
-
format: "es",
|
|
191
|
-
},
|
|
192
|
-
esbuild: {
|
|
193
|
-
platform: "browser",
|
|
194
|
-
target: [
|
|
195
|
-
"es2020",
|
|
196
|
-
"chrome60",
|
|
197
|
-
"edge18",
|
|
198
|
-
"firefox60",
|
|
199
|
-
"node24",
|
|
200
|
-
"safari11",
|
|
201
|
-
],
|
|
202
|
-
drop,
|
|
203
|
-
pure,
|
|
204
|
-
legalComments: "none",
|
|
205
|
-
jsx: "automatic",
|
|
206
|
-
jsxImportSource: "@emotion/react",
|
|
207
|
-
jsxDev: process.env.NODE_ENV === "development",
|
|
208
|
-
},
|
|
209
|
-
define,
|
|
210
|
-
|
|
211
|
-
build: {
|
|
212
|
-
outDir: path.resolve(dir, "dist/bundle"),
|
|
213
|
-
minify: isProduction,
|
|
214
|
-
ssr: false,
|
|
215
|
-
lib: {
|
|
216
|
-
entry: path.resolve(dir, entry),
|
|
217
|
-
name: bundleName,
|
|
218
|
-
fileName: `${bundleName}.bundle.js`,
|
|
219
|
-
formats: ["es"],
|
|
220
|
-
},
|
|
221
|
-
modulePreload: { polyfill: true },
|
|
222
|
-
commonjsOptions: {
|
|
223
|
-
exclude: ["mongodb/*"],
|
|
224
|
-
transformMixedEsModules: true,
|
|
225
|
-
strictRequires: "debug",
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
rollupOptions: {
|
|
229
|
-
treeshake: {
|
|
230
|
-
// Respect /*#__PURE__*/ annotations. Ignoring them retained
|
|
231
|
-
// dead library calls that every consumer then shipped;
|
|
232
|
-
// honouring them cuts ~17KB gzip off the widget bundle with
|
|
233
|
-
// a byte-identical detector.
|
|
234
|
-
annotations: true,
|
|
235
|
-
propertyReadSideEffects: false,
|
|
236
|
-
// Measured alternatives, both rejected:
|
|
237
|
-
// moduleSideEffects: false -> widget 8KB gzip LARGER
|
|
238
|
-
// propertyWriteSideEffects: false -> detector dies on load
|
|
239
|
-
// ("Maximum call stack
|
|
240
|
-
// size exceeded")
|
|
241
|
-
moduleSideEffects: "no-external",
|
|
242
|
-
unknownGlobalSideEffects: false,
|
|
243
|
-
},
|
|
244
|
-
external: rollupExternal,
|
|
245
|
-
watch: false,
|
|
246
|
-
|
|
247
|
-
output: {
|
|
248
|
-
dir: path.resolve(dir, "dist/bundle"),
|
|
249
|
-
entryFileNames: `${bundleName}.bundle.js`,
|
|
250
|
-
// For a lib + es build, Vite downgrades `build.minify: true` to
|
|
251
|
-
// `{ compress, mangle, codegen: false }`, which leaves the output
|
|
252
|
-
// pretty-printed. Set it here to get whitespace removal too;
|
|
253
|
-
// output options win over the build-level default.
|
|
254
|
-
...(isProduction
|
|
255
|
-
? {
|
|
256
|
-
minify: {
|
|
257
|
-
compress: true,
|
|
258
|
-
mangle: true,
|
|
259
|
-
codegen: true,
|
|
260
|
-
},
|
|
261
|
-
}
|
|
262
|
-
: {}),
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
plugins: [
|
|
266
|
-
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
267
|
-
css() as any,
|
|
268
|
-
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
269
|
-
wasm() as any,
|
|
270
|
-
// @ts-ignore
|
|
271
|
-
nodeResolve({
|
|
272
|
-
browser: true,
|
|
273
|
-
preferBuiltins: false,
|
|
274
|
-
rootDir: path.resolve(dir, "../../"),
|
|
275
|
-
dedupe: ["react", "react-dom"],
|
|
276
|
-
modulesOnly: true,
|
|
277
|
-
// biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
|
|
278
|
-
}) as any,
|
|
279
|
-
// String replacement plugin for fingerprinting code
|
|
280
|
-
{
|
|
281
|
-
name: "string-replace-fingerprint",
|
|
282
|
-
generateBundle(_, bundle) {
|
|
283
|
-
for (const fileName in bundle) {
|
|
284
|
-
const chunk = bundle[fileName];
|
|
285
|
-
if (
|
|
286
|
-
chunk &&
|
|
287
|
-
chunk.type === "chunk" &&
|
|
288
|
-
"code" in chunk &&
|
|
289
|
-
chunk.code
|
|
290
|
-
) {
|
|
291
|
-
chunk.code = chunk.code.replace(
|
|
292
|
-
/var request = new XMLHttpRequest\(\);\s*request\.open\("get", "https:\/\/m1\.openfpcdn\.io\/fingerprintjs\/v"\.concat\(version, "\/npm-monitoring"\), true\);\s*request\.send\(\);/g,
|
|
293
|
-
"",
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
// Bundle stats page — only wired in (and opened in the
|
|
300
|
-
// browser) when PROSOPO_BUNDLE_STATS=true. Defaults off so
|
|
301
|
-
// normal builds neither emit the report nor pop a window.
|
|
302
|
-
...(openBundleStats
|
|
303
|
-
? [
|
|
304
|
-
visualizer({
|
|
305
|
-
open: true,
|
|
306
|
-
template: "treemap",
|
|
307
|
-
gzipSize: true,
|
|
308
|
-
brotliSize: true,
|
|
309
|
-
}),
|
|
310
|
-
]
|
|
311
|
-
: []),
|
|
312
|
-
// I think we can use this plugin to build all packages instead of relying on the tsc step that's
|
|
313
|
-
// currently a precursor in package.json. However, it fails for the following reason:
|
|
314
|
-
// https://github.com/rollup/plugins/issues/243
|
|
315
|
-
// @ts-ignore
|
|
316
|
-
typescript({
|
|
317
|
-
tsconfig: path.resolve("./tsconfig.json"),
|
|
318
|
-
compilerOptions: { rootDir: path.resolve("./src") },
|
|
319
|
-
outDir: path.resolve(dir, "dist/bundle"),
|
|
320
|
-
}),
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
plugins: [
|
|
325
|
-
VitePluginExternalizeObfuscatorDeadCode(),
|
|
326
|
-
// node polyfills must be a top-level Vite plugin (not inside
|
|
327
|
-
// build.rollupOptions.plugins) so its inject sub-plugin initialises
|
|
328
|
-
// before transform runs under Rolldown/Vite 8.
|
|
329
|
-
nodePolyfills({
|
|
330
|
-
include: ["crypto"],
|
|
331
|
-
}),
|
|
332
|
-
// Not sure if we need this plugin or not, it works without it
|
|
333
|
-
// @ts-ignore
|
|
334
|
-
viteReact(),
|
|
335
|
-
// Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
|
|
336
|
-
// mode, in which case we don't want to close the bundler because it will close the server
|
|
337
|
-
command !== "serve" ? VitePluginCloseAndCopy(copyOptions) : undefined,
|
|
338
|
-
],
|
|
339
|
-
};
|
|
340
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
import fs from "node:fs";
|
|
16
|
-
import path from "node:path";
|
|
17
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
18
|
-
import { defineConfig } from "vitest/config";
|
|
19
|
-
import { testFileGlobs } from "./testFileGlobs.js";
|
|
20
|
-
import VitePluginCloseAndCopy from "./vite-plugin-close-and-copy.js";
|
|
21
|
-
import VitePluginSourcemapExclude from "./vite-plugin-sourcemap-exclude.js";
|
|
22
|
-
|
|
23
|
-
export default function (tsConfigPath?: string) {
|
|
24
|
-
const testFiles = testFileGlobs(process.env.TEST_TYPE);
|
|
25
|
-
console.log(
|
|
26
|
-
`TEST_TYPE=${process.env.TEST_TYPE ?? ""} include=${testFiles.include.join(",")} exclude=${testFiles.exclude.join(",")}`,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// Determine coverage include paths based on current working directory.
|
|
30
|
-
//
|
|
31
|
-
// Detected by looking for a package alongside the cwd rather than by
|
|
32
|
-
// matching "/packages/" in the path: workspaces also live in dev/, demos/
|
|
33
|
-
// and integration/, and those were falling through to the repo-root globs
|
|
34
|
-
// below, which match `packages/*/src/**` only — so they reported 0/0
|
|
35
|
-
// coverage no matter what their tests exercised. Neither repo root has a
|
|
36
|
-
// `src` directory, so this cannot misfire in the other direction.
|
|
37
|
-
const cwd = process.cwd();
|
|
38
|
-
const isRunningFromPackage =
|
|
39
|
-
fs.existsSync(path.join(cwd, "package.json")) &&
|
|
40
|
-
fs.existsSync(path.join(cwd, "src"));
|
|
41
|
-
|
|
42
|
-
// If running from a package directory, include local src files
|
|
43
|
-
// If running from repo root, include all package src files
|
|
44
|
-
const coverageInclude = isRunningFromPackage
|
|
45
|
-
? ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx"]
|
|
46
|
-
: ["packages/*/src/**", "captcha/packages/*/src/**"];
|
|
47
|
-
|
|
48
|
-
const coverageExclude = isRunningFromPackage
|
|
49
|
-
? [
|
|
50
|
-
"src/tests/**/*",
|
|
51
|
-
"src/**/*.d.ts",
|
|
52
|
-
"src/**/*.test.ts",
|
|
53
|
-
"src/**/*.spec.ts",
|
|
54
|
-
"src/**/*.test.tsx",
|
|
55
|
-
"src/**/*.spec.tsx",
|
|
56
|
-
// Type-test files are compiled by the typecheck pass, never
|
|
57
|
-
// executed, so they can only ever report 0% and drag the real
|
|
58
|
-
// figure down. `*.d.ts` above does not match `*.test-d.ts`.
|
|
59
|
-
"src/**/*.test-d.ts",
|
|
60
|
-
"src/**/*.test-d.tsx",
|
|
61
|
-
]
|
|
62
|
-
: [
|
|
63
|
-
"**/tests/**/*",
|
|
64
|
-
"**/*.d.ts",
|
|
65
|
-
"**/*.test.*",
|
|
66
|
-
"**/*.spec.*",
|
|
67
|
-
"**/node_modules/**",
|
|
68
|
-
"**/dist/**",
|
|
69
|
-
];
|
|
70
|
-
const plugins = [
|
|
71
|
-
VitePluginSourcemapExclude({ excludeNodeModules: true }),
|
|
72
|
-
VitePluginCloseAndCopy(),
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
if (tsConfigPath) {
|
|
76
|
-
plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return defineConfig({
|
|
80
|
-
build: {
|
|
81
|
-
minify: false,
|
|
82
|
-
sourcemap: false,
|
|
83
|
-
rollupOptions: {
|
|
84
|
-
output: {
|
|
85
|
-
sourcemap: false,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
test: {
|
|
90
|
-
//root: getRootDir(),
|
|
91
|
-
// vitest 4 removed the "basic" reporter; the default reporter with
|
|
92
|
-
// summary disabled reproduces its terse output.
|
|
93
|
-
reporters: [["default", { summary: false }]],
|
|
94
|
-
include: testFiles.include,
|
|
95
|
-
watch: false,
|
|
96
|
-
exclude: ["**/node_modules/**", "**/dist/**", ...testFiles.exclude],
|
|
97
|
-
logHeapUsage: true,
|
|
98
|
-
coverage: {
|
|
99
|
-
enabled: true,
|
|
100
|
-
include: coverageInclude,
|
|
101
|
-
exclude: coverageExclude,
|
|
102
|
-
},
|
|
103
|
-
typecheck: {
|
|
104
|
-
enabled: true,
|
|
105
|
-
},
|
|
106
|
-
pool: "forks", // forks is slower than 'threads' but more compatible with low-level libs (e.g. bcrypt)
|
|
107
|
-
isolate: true,
|
|
108
|
-
sequence: {
|
|
109
|
-
shuffle: true,
|
|
110
|
-
},
|
|
111
|
-
testTimeout: 10000,
|
|
112
|
-
},
|
|
113
|
-
plugins: plugins,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
17
|
-
import { defineConfig } from "vitest/config";
|
|
18
|
-
import { testFileGlobs } from "./testFileGlobs.js";
|
|
19
|
-
import VitePluginCloseAndCopy from "./vite-plugin-close-and-copy.js";
|
|
20
|
-
import VitePluginSourcemapExclude from "./vite-plugin-sourcemap-exclude.js";
|
|
21
|
-
|
|
22
|
-
export default function (tsConfigPath?: string) {
|
|
23
|
-
const testFiles = testFileGlobs(process.env.TEST_TYPE);
|
|
24
|
-
console.log(
|
|
25
|
-
`TEST_TYPE=${process.env.TEST_TYPE ?? ""} include=${testFiles.include.join(",")} exclude=${testFiles.exclude.join(",")}`,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Determine coverage include paths based on current working directory
|
|
29
|
-
const cwd = process.cwd();
|
|
30
|
-
const isRunningFromPackage =
|
|
31
|
-
cwd.includes("/packages/") && cwd.includes("/src") === false;
|
|
32
|
-
|
|
33
|
-
// If running from a package directory, include local src files
|
|
34
|
-
// If running from repo root, include all package src files
|
|
35
|
-
const coverageInclude = isRunningFromPackage
|
|
36
|
-
? ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx"]
|
|
37
|
-
: ["packages/*/src/**", "captcha/packages/*/src/**"];
|
|
38
|
-
|
|
39
|
-
const coverageExclude = isRunningFromPackage
|
|
40
|
-
? [
|
|
41
|
-
"src/tests/**/*",
|
|
42
|
-
"src/**/*.d.ts",
|
|
43
|
-
"src/**/*.test.ts",
|
|
44
|
-
"src/**/*.spec.ts",
|
|
45
|
-
"src/**/*.test.tsx",
|
|
46
|
-
"src/**/*.spec.tsx",
|
|
47
|
-
]
|
|
48
|
-
: [
|
|
49
|
-
"**/tests/**/*",
|
|
50
|
-
"**/*.d.ts",
|
|
51
|
-
"**/*.test.*",
|
|
52
|
-
"**/*.spec.*",
|
|
53
|
-
"**/node_modules/**",
|
|
54
|
-
"**/dist/**",
|
|
55
|
-
];
|
|
56
|
-
const plugins = [
|
|
57
|
-
VitePluginSourcemapExclude({ excludeNodeModules: true }),
|
|
58
|
-
VitePluginCloseAndCopy(),
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
if (tsConfigPath) {
|
|
62
|
-
plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return defineConfig({
|
|
66
|
-
build: {
|
|
67
|
-
minify: false,
|
|
68
|
-
sourcemap: false,
|
|
69
|
-
rollupOptions: {
|
|
70
|
-
output: {
|
|
71
|
-
sourcemap: false,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
test: {
|
|
76
|
-
//root: getRootDir(),
|
|
77
|
-
// vitest 4 removed the "basic" reporter; the default reporter with
|
|
78
|
-
// summary disabled reproduces its terse output.
|
|
79
|
-
reporters: [["default", { summary: false }]],
|
|
80
|
-
include: testFiles.include,
|
|
81
|
-
watch: false,
|
|
82
|
-
exclude: ["**/node_modules/**", "**/dist/**", ...testFiles.exclude],
|
|
83
|
-
logHeapUsage: true,
|
|
84
|
-
coverage: {
|
|
85
|
-
enabled: true,
|
|
86
|
-
include: coverageInclude,
|
|
87
|
-
exclude: coverageExclude,
|
|
88
|
-
},
|
|
89
|
-
typecheck: {
|
|
90
|
-
enabled: true,
|
|
91
|
-
},
|
|
92
|
-
pool: "threads", // use threads for tests that should be run sequentially
|
|
93
|
-
// vitest 4 removed poolOptions; sequential execution is now expressed via
|
|
94
|
-
// fileParallelism instead of min/maxThreads.
|
|
95
|
-
fileParallelism: false,
|
|
96
|
-
testTimeout: 10000,
|
|
97
|
-
},
|
|
98
|
-
plugins: plugins,
|
|
99
|
-
});
|
|
100
|
-
}
|
package/src/webpack/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
export * from "./webpack.config.js";
|