@prosopo/config 3.3.3 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +27 -24
  2. package/.turbo/turbo-build$colon$tsc.log +4 -4
  3. package/.turbo/turbo-build.log +28 -24
  4. package/CHANGELOG.md +37 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  7. package/dist/cjs/dependencies.cjs +130 -137
  8. package/dist/cjs/index.cjs +31 -32
  9. package/dist/cjs/vite/TsNoCheckPlugin.cjs +11 -15
  10. package/dist/cjs/vite/index.cjs +26 -26
  11. package/dist/cjs/vite/vite-plugin-close-and-copy.cjs +42 -42
  12. package/dist/cjs/vite/vite-plugin-copy.cjs +39 -38
  13. package/dist/cjs/vite/vite-plugin-externalize-obfuscator-deadcode.cjs +25 -0
  14. package/dist/cjs/vite/vite-plugin-fix-absolute-imports.cjs +16 -24
  15. package/dist/cjs/vite/vite-plugin-remove-unused-translations.cjs +53 -74
  16. package/dist/cjs/vite/vite-plugin-sourcemap-exclude.cjs +12 -15
  17. package/dist/cjs/vite/vite.backend.config.cjs +87 -104
  18. package/dist/cjs/vite/vite.commonjs.config.cjs +69 -74
  19. package/dist/cjs/vite/vite.esm.config.cjs +71 -70
  20. package/dist/cjs/vite/vite.frontend.config.cjs +173 -203
  21. package/dist/cjs/vite/vite.test.config.cjs +70 -80
  22. package/dist/cjs/vite/vite.threads.test.config.cjs +67 -78
  23. package/dist/cjs/webpack/index.cjs +0 -2
  24. package/dist/cjs/webpack/webpack.config.cjs +108 -146
  25. package/dist/dependencies.d.ts.map +1 -1
  26. package/dist/dependencies.js +123 -138
  27. package/dist/dependencies.js.map +1 -1
  28. package/dist/index.js +14 -31
  29. package/dist/vite/TsNoCheckPlugin.js +12 -16
  30. package/dist/vite/index.d.ts +1 -0
  31. package/dist/vite/index.d.ts.map +1 -1
  32. package/dist/vite/index.js +13 -25
  33. package/dist/vite/index.js.map +1 -1
  34. package/dist/vite/vite-plugin-close-and-copy.js +37 -41
  35. package/dist/vite/vite-plugin-copy.js +32 -36
  36. package/dist/vite/vite-plugin-externalize-obfuscator-deadcode.d.ts +3 -0
  37. package/dist/vite/vite-plugin-externalize-obfuscator-deadcode.d.ts.map +1 -0
  38. package/dist/vite/vite-plugin-externalize-obfuscator-deadcode.js +25 -0
  39. package/dist/vite/vite-plugin-externalize-obfuscator-deadcode.js.map +1 -0
  40. package/dist/vite/vite-plugin-fix-absolute-imports.js +15 -24
  41. package/dist/vite/vite-plugin-remove-unused-translations.js +50 -76
  42. package/dist/vite/vite-plugin-sourcemap-exclude.js +12 -16
  43. package/dist/vite/vite.backend.config.d.ts.map +1 -1
  44. package/dist/vite/vite.backend.config.js +80 -101
  45. package/dist/vite/vite.backend.config.js.map +1 -1
  46. package/dist/vite/vite.commonjs.config.d.ts.map +1 -1
  47. package/dist/vite/vite.commonjs.config.js +61 -71
  48. package/dist/vite/vite.commonjs.config.js.map +1 -1
  49. package/dist/vite/vite.esm.config.d.ts.map +1 -1
  50. package/dist/vite/vite.esm.config.js +63 -67
  51. package/dist/vite/vite.esm.config.js.map +1 -1
  52. package/dist/vite/vite.frontend.config.d.ts.map +1 -1
  53. package/dist/vite/vite.frontend.config.js +159 -196
  54. package/dist/vite/vite.frontend.config.js.map +1 -1
  55. package/dist/vite/vite.test.config.d.ts.map +1 -1
  56. package/dist/vite/vite.test.config.js +63 -78
  57. package/dist/vite/vite.test.config.js.map +1 -1
  58. package/dist/vite/vite.threads.test.config.d.ts.map +1 -1
  59. package/dist/vite/vite.threads.test.config.js +61 -76
  60. package/dist/vite/vite.threads.test.config.js.map +1 -1
  61. package/dist/webpack/index.js +1 -1
  62. package/dist/webpack/webpack.config.d.ts +2 -0
  63. package/dist/webpack/webpack.config.d.ts.map +1 -1
  64. package/dist/webpack/webpack.config.js +96 -119
  65. package/dist/webpack/webpack.config.js.map +1 -1
  66. package/package.json +10 -9
  67. package/src/dependencies.ts +15 -2
  68. package/src/vite/index.ts +1 -0
  69. package/src/vite/vite-plugin-externalize-obfuscator-deadcode.ts +43 -0
  70. package/src/vite/vite.backend.config.ts +19 -2
  71. package/src/vite/vite.commonjs.config.ts +2 -0
  72. package/src/vite/vite.esm.config.ts +12 -0
  73. package/src/vite/vite.frontend.config.ts +38 -14
  74. package/src/vite/vite.test.config.ts +15 -10
  75. package/src/vite/vite.threads.test.config.ts +6 -9
  76. package/src/webpack/webpack.config.ts +8 -1
  77. package/tsconfig.tsbuildinfo +1 -1
  78. package/vite.cjs.config.ts +4 -0
  79. package/vite.esm.config.ts +9 -1
  80. package/.turbo/turbo-typecheck.log +0 -4
@@ -1,204 +1,174 @@
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 vitePluginNodePolyfills = require("vite-plugin-node-polyfills");
10
- const dependencies = require("../dependencies.cjs");
11
- require("./index.cjs");
12
- const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
13
- async function vite_frontend_config(packageName, bundleName, dir, entry, command, mode, copyOptions, tsConfigPaths, workspaceRoot) {
14
- if (mode !== "production") {
15
- mode = "development";
16
- }
17
- const allowedEnvironments = ["development", "staging", "production"];
18
- const defaultEnvironment = process.env.NODE_ENV && allowedEnvironments.includes(process.env.NODE_ENV) ? process.env.NODE_ENV : mode;
19
- console.info(`Running at ${dir} in ${mode} mode`);
20
- const isProduction = mode === "production";
21
- process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
22
- console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
23
- const define = {
24
- // used to stop websockets package from breaking
25
- "process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
26
- "process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
27
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
28
- "process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(defaultEnvironment),
29
- "process.env.PROSOPO_SERVER_URL": JSON.stringify(
30
- process.env.PROSOPO_SERVER_URL
31
- ),
32
- "process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
33
- process.env._DEV_ONLY_WATCH_EVENTS
34
- ),
35
- "process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(
36
- process.env.PROSOPO_MONGO_EVENTS_URI
37
- ),
38
- "process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(
39
- process.env.PROSOPO_PACKAGE_VERSION
40
- ),
41
- "process.env.PROSOPO_DOCS_URL": JSON.stringify(
42
- process.env.PROSOPO_DOCS_URL
43
- ),
44
- "process.env.PROSOPO_LOG_LEVEL": JSON.stringify(
45
- process.env.PROSOPO_LOG_LEVEL
46
- ),
47
- // only needed if bundling with a site key
48
- "process.env.PROSOPO_SITE_KEY": JSON.stringify(
49
- process.env.PROSOPO_SITE_KEY
50
- )
51
- };
52
- console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
53
- const { dependencies: deps, optionalPeerDependencies } = await dependencies.getDependencies(packageName, isProduction);
54
- const { external, internal } = dependencies.filterDependencies(deps, [
55
- "pm2",
56
- "nodejs-polars",
57
- "aws",
58
- "webpack",
59
- "vite",
60
- "i18next-fs-backend"
61
- ]);
62
- const allExternal = [
63
- ...node_module.builtinModules,
64
- ...node_module.builtinModules.map((m) => `node:${m}`),
65
- ...external,
66
- ...optionalPeerDependencies
67
- ];
68
- console.debug(
69
- `Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`
70
- );
71
- const proto = RegExp.prototype;
72
- proto.toJSON = RegExp.prototype.toString;
73
- let drop;
74
- let pure = [];
75
- if (isProduction) {
76
- drop = ["debugger"];
77
- pure = ["console.log", "console.warn", "console.info", "console.debug"];
78
- }
79
- const rollupExternal = allExternal;
80
- console.info({ bundleName }, "Bundle name");
81
- return {
82
- server: {
83
- host: "127.0.0.1"
84
- },
85
- mode: mode || "development",
86
- optimizeDeps: {
87
- include: ["node_modules"],
88
- force: true
89
- },
90
- worker: {
91
- format: "es"
92
- },
93
- esbuild: {
94
- platform: "browser",
95
- target: [
96
- "es2020",
97
- "chrome60",
98
- "edge18",
99
- "firefox60",
100
- "node24",
101
- "safari11"
102
- ],
103
- drop,
104
- pure,
105
- legalComments: "none",
106
- jsx: "automatic",
107
- jsxImportSource: "@emotion/react",
108
- jsxDev: process.env.NODE_ENV === "development"
109
- },
110
- define,
111
- build: {
112
- outDir: path.resolve(dir, "dist/bundle"),
113
- minify: isProduction,
114
- ssr: false,
115
- lib: {
116
- entry: path.resolve(dir, entry),
117
- name: bundleName,
118
- fileName: `${bundleName}.bundle.js`,
119
- formats: ["es"]
120
- },
121
- modulePreload: { polyfill: true },
122
- commonjsOptions: {
123
- exclude: ["mongodb/*"],
124
- transformMixedEsModules: true,
125
- strictRequires: "debug"
126
- },
127
- rollupOptions: {
128
- treeshake: {
129
- annotations: false,
130
- propertyReadSideEffects: false,
131
- tryCatchDeoptimization: false,
132
- moduleSideEffects: "no-external",
133
- //true,
134
- preset: "smallest",
135
- unknownGlobalSideEffects: false
136
- },
137
- experimentalLogSideEffects: false,
138
- external: rollupExternal,
139
- watch: false,
140
- output: {
141
- dir: path.resolve(dir, "dist/bundle"),
142
- entryFileNames: `${bundleName}.bundle.js`
143
- },
144
- plugins: [
145
- vitePluginNodePolyfills.nodePolyfills({
146
- include: ["crypto"]
147
- }),
148
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
149
- css(),
150
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
151
- pluginWasm.wasm(),
152
- // @ts-ignore
153
- nodeResolve({
154
- browser: true,
155
- preferBuiltins: false,
156
- rootDir: path.resolve(dir, "../../"),
157
- dedupe: ["react", "react-dom"],
158
- modulesOnly: true
159
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
160
- }),
161
- // String replacement plugin for fingerprinting code
162
- {
163
- name: "string-replace-fingerprint",
164
- generateBundle(_, bundle) {
165
- for (const fileName in bundle) {
166
- const chunk = bundle[fileName];
167
- if (chunk && chunk.type === "chunk" && "code" in chunk && chunk.code) {
168
- chunk.code = chunk.code.replace(
169
- /var request = new XMLHttpRequest\(\);\s*request\.open\("get", "https:\/\/m1\.openfpcdn\.io\/fingerprintjs\/v"\.concat\(version, "\/npm-monitoring"\), true\);\s*request\.send\(\);/g,
170
- ""
171
- );
172
- }
173
- }
174
- }
175
- },
176
- // visualizer({
177
- // open: true,
178
- // template: "treemap", //'list',
179
- // gzipSize: true,
180
- // brotliSize: true,
181
- // }),
182
- // I think we can use this plugin to build all packages instead of relying on the tsc step that's
183
- // currently a precursor in package.json. However, it fails for the following reason:
184
- // https://github.com/rollup/plugins/issues/243
185
- // @ts-ignore
186
- typescript({
187
- tsconfig: path.resolve("./tsconfig.json"),
188
- compilerOptions: { rootDir: path.resolve("./src") },
189
- outDir: path.resolve(dir, "dist/bundle")
190
- })
191
- ]
192
- }
193
- },
194
- plugins: [
195
- // Not sure if we need this plugin or not, it works without it
196
- // @ts-ignore
197
- viteReact(),
198
- // Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
199
- // mode, in which case we don't want to close the bundler because it will close the server
200
- command !== "serve" ? vitePluginCloseAndCopy(copyOptions) : void 0
201
- ]
202
- };
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_vite_plugin_close_and_copy = require("./vite-plugin-close-and-copy.cjs");
3
+ const require_vite_plugin_externalize_obfuscator_deadcode = require("./vite-plugin-externalize-obfuscator-deadcode.cjs");
4
+ const require_dependencies = require("../dependencies.cjs");
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path, 1);
7
+ let node_module = require("node:module");
8
+ let _rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
9
+ _rollup_plugin_node_resolve = require_runtime.__toESM(_rollup_plugin_node_resolve, 1);
10
+ let _rollup_plugin_typescript = require("@rollup/plugin-typescript");
11
+ _rollup_plugin_typescript = require_runtime.__toESM(_rollup_plugin_typescript, 1);
12
+ let _rollup_plugin_wasm = require("@rollup/plugin-wasm");
13
+ let _vitejs_plugin_react = require("@vitejs/plugin-react");
14
+ _vitejs_plugin_react = require_runtime.__toESM(_vitejs_plugin_react, 1);
15
+ let rollup_plugin_import_css = require("rollup-plugin-import-css");
16
+ rollup_plugin_import_css = require_runtime.__toESM(rollup_plugin_import_css, 1);
17
+ let rollup_plugin_visualizer = require("rollup-plugin-visualizer");
18
+ let vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
19
+ //#region src/vite/vite.frontend.config.ts
20
+ async function vite_frontend_config_default(packageName, bundleName, dir, entry, command, mode, copyOptions, tsConfigPaths, workspaceRoot) {
21
+ if (mode !== "production") mode = "development";
22
+ const defaultEnvironment = process.env.NODE_ENV && [
23
+ "development",
24
+ "staging",
25
+ "production"
26
+ ].includes(process.env.NODE_ENV) ? process.env.NODE_ENV : mode;
27
+ console.info(`Running at ${dir} in ${mode} mode`);
28
+ const isProduction = mode === "production";
29
+ const openBundleStats = process.env.PROSOPO_BUNDLE_STATS?.trim().toLowerCase() === "true";
30
+ process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
31
+ console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
32
+ const define = {
33
+ "process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
34
+ "process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
35
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
36
+ "process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(defaultEnvironment),
37
+ "process.env.PROSOPO_SERVER_URL": JSON.stringify(process.env.PROSOPO_SERVER_URL),
38
+ "process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(process.env._DEV_ONLY_WATCH_EVENTS),
39
+ "process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(process.env.PROSOPO_MONGO_EVENTS_URI),
40
+ "process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(process.env.PROSOPO_PACKAGE_VERSION),
41
+ "process.env.PROSOPO_DOCS_URL": JSON.stringify(process.env.PROSOPO_DOCS_URL),
42
+ "process.env.PROSOPO_LOG_LEVEL": JSON.stringify(process.env.PROSOPO_LOG_LEVEL),
43
+ "process.env.PROSOPO_SITE_KEY": JSON.stringify(process.env.PROSOPO_SITE_KEY)
44
+ };
45
+ console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
46
+ const { dependencies: deps, optionalPeerDependencies } = await require_dependencies.getDependencies(packageName, isProduction);
47
+ const { external, internal } = require_dependencies.filterDependencies(deps, [
48
+ "pm2",
49
+ "nodejs-polars",
50
+ "aws",
51
+ "webpack",
52
+ "vite",
53
+ "i18next-fs-backend"
54
+ ]);
55
+ const allExternal = [
56
+ ...node_module.builtinModules,
57
+ ...node_module.builtinModules.map((m) => `node:${m}`),
58
+ ...external,
59
+ ...optionalPeerDependencies
60
+ ];
61
+ console.debug(`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`);
62
+ const proto = RegExp.prototype;
63
+ proto.toJSON = RegExp.prototype.toString;
64
+ let drop;
65
+ let pure = [];
66
+ if (isProduction) {
67
+ drop = ["debugger"];
68
+ pure = [
69
+ "console.log",
70
+ "console.warn",
71
+ "console.info",
72
+ "console.debug"
73
+ ];
74
+ }
75
+ const rollupExternal = allExternal;
76
+ console.info({ bundleName }, "Bundle name");
77
+ return {
78
+ server: { host: "127.0.0.1" },
79
+ mode: mode || "development",
80
+ optimizeDeps: {
81
+ include: ["node_modules"],
82
+ force: true
83
+ },
84
+ worker: { format: "es" },
85
+ esbuild: {
86
+ platform: "browser",
87
+ target: [
88
+ "es2020",
89
+ "chrome60",
90
+ "edge18",
91
+ "firefox60",
92
+ "node24",
93
+ "safari11"
94
+ ],
95
+ drop,
96
+ pure,
97
+ legalComments: "none",
98
+ jsx: "automatic",
99
+ jsxImportSource: "@emotion/react",
100
+ jsxDev: process.env.NODE_ENV === "development"
101
+ },
102
+ define,
103
+ build: {
104
+ outDir: node_path.default.resolve(dir, "dist/bundle"),
105
+ minify: isProduction,
106
+ ssr: false,
107
+ lib: {
108
+ entry: node_path.default.resolve(dir, entry),
109
+ name: bundleName,
110
+ fileName: `${bundleName}.bundle.js`,
111
+ formats: ["es"]
112
+ },
113
+ modulePreload: { polyfill: true },
114
+ commonjsOptions: {
115
+ exclude: ["mongodb/*"],
116
+ transformMixedEsModules: true,
117
+ strictRequires: "debug"
118
+ },
119
+ rollupOptions: {
120
+ treeshake: {
121
+ annotations: true,
122
+ propertyReadSideEffects: false,
123
+ moduleSideEffects: "no-external",
124
+ unknownGlobalSideEffects: false
125
+ },
126
+ external: rollupExternal,
127
+ watch: false,
128
+ output: {
129
+ dir: node_path.default.resolve(dir, "dist/bundle"),
130
+ entryFileNames: `${bundleName}.bundle.js`
131
+ },
132
+ plugins: [
133
+ (0, rollup_plugin_import_css.default)(),
134
+ (0, _rollup_plugin_wasm.wasm)(),
135
+ (0, _rollup_plugin_node_resolve.default)({
136
+ browser: true,
137
+ preferBuiltins: false,
138
+ rootDir: node_path.default.resolve(dir, "../../"),
139
+ dedupe: ["react", "react-dom"],
140
+ modulesOnly: true
141
+ }),
142
+ {
143
+ name: "string-replace-fingerprint",
144
+ generateBundle(_, bundle) {
145
+ for (const fileName in bundle) {
146
+ const chunk = bundle[fileName];
147
+ if (chunk && chunk.type === "chunk" && "code" in chunk && chunk.code) chunk.code = chunk.code.replace(/var request = new XMLHttpRequest\(\);\s*request\.open\("get", "https:\/\/m1\.openfpcdn\.io\/fingerprintjs\/v"\.concat\(version, "\/npm-monitoring"\), true\);\s*request\.send\(\);/g, "");
148
+ }
149
+ }
150
+ },
151
+ ...openBundleStats ? [(0, rollup_plugin_visualizer.visualizer)({
152
+ open: true,
153
+ template: "treemap",
154
+ gzipSize: true,
155
+ brotliSize: true
156
+ })] : [],
157
+ (0, _rollup_plugin_typescript.default)({
158
+ tsconfig: node_path.default.resolve("./tsconfig.json"),
159
+ compilerOptions: { rootDir: node_path.default.resolve("./src") },
160
+ outDir: node_path.default.resolve(dir, "dist/bundle")
161
+ })
162
+ ]
163
+ }
164
+ },
165
+ plugins: [
166
+ require_vite_plugin_externalize_obfuscator_deadcode.default(),
167
+ (0, vite_plugin_node_polyfills.nodePolyfills)({ include: ["crypto"] }),
168
+ (0, _vitejs_plugin_react.default)(),
169
+ command !== "serve" ? require_vite_plugin_close_and_copy.default(copyOptions) : void 0
170
+ ]
171
+ };
203
172
  }
204
- module.exports = vite_frontend_config;
173
+ //#endregion
174
+ exports.default = vite_frontend_config_default;
@@ -1,81 +1,71 @@
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
- sequence: {
74
- shuffle: true
75
- },
76
- testTimeout: 1e4
77
- },
78
- plugins
79
- });
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_vite_plugin_close_and_copy = require("./vite-plugin-close-and-copy.cjs");
3
+ const require_vite_plugin_sourcemap_exclude = require("./vite-plugin-sourcemap-exclude.cjs");
4
+ let node_fs = require("node:fs");
5
+ node_fs = require_runtime.__toESM(node_fs, 1);
6
+ let node_path = require("node:path");
7
+ node_path = require_runtime.__toESM(node_path, 1);
8
+ let vite_tsconfig_paths = require("vite-tsconfig-paths");
9
+ vite_tsconfig_paths = require_runtime.__toESM(vite_tsconfig_paths, 1);
10
+ let vitest_config = require("vitest/config");
11
+ //#region src/vite/vite.test.config.ts
12
+ function vite_test_config_default(tsConfigPath) {
13
+ const testTypeEnv = process.env.TEST_TYPE || void 0;
14
+ console.log(`TEST_TYPE environment variable: ${testTypeEnv}`);
15
+ const testTypes = testTypeEnv ? testTypeEnv.trim().split(",") : [];
16
+ const testTypeGlob = testTypes.length > 0 ? `@(${testTypes.map((t) => `.${t}`).join("|")})` : "@(|)";
17
+ console.log(`Filtering tests by type: ${testTypeGlob}`);
18
+ const cwd = process.cwd();
19
+ const isRunningFromPackage = node_fs.default.existsSync(node_path.default.join(cwd, "package.json")) && node_fs.default.existsSync(node_path.default.join(cwd, "src"));
20
+ const coverageInclude = isRunningFromPackage ? [
21
+ "src/**/*.ts",
22
+ "src/**/*.js",
23
+ "src/**/*.tsx",
24
+ "src/**/*.jsx"
25
+ ] : ["packages/*/src/**", "captcha/packages/*/src/**"];
26
+ const coverageExclude = isRunningFromPackage ? [
27
+ "src/tests/**/*",
28
+ "src/**/*.d.ts",
29
+ "src/**/*.test.ts",
30
+ "src/**/*.spec.ts",
31
+ "src/**/*.test.tsx",
32
+ "src/**/*.spec.tsx"
33
+ ] : [
34
+ "**/tests/**/*",
35
+ "**/*.d.ts",
36
+ "**/*.test.*",
37
+ "**/*.spec.*",
38
+ "**/node_modules/**",
39
+ "**/dist/**"
40
+ ];
41
+ const include = `src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`;
42
+ const plugins = [require_vite_plugin_sourcemap_exclude.default({ excludeNodeModules: true }), require_vite_plugin_close_and_copy.default()];
43
+ if (tsConfigPath) plugins.push((0, vite_tsconfig_paths.default)({ projects: [node_path.default.resolve(tsConfigPath)] }));
44
+ return (0, vitest_config.defineConfig)({
45
+ build: {
46
+ minify: false,
47
+ sourcemap: false,
48
+ rollupOptions: { output: { sourcemap: false } }
49
+ },
50
+ test: {
51
+ reporters: [["default", { summary: false }]],
52
+ include: [include],
53
+ watch: false,
54
+ exclude: ["**/node_modules/**", "**/dist/**"],
55
+ logHeapUsage: true,
56
+ coverage: {
57
+ enabled: true,
58
+ include: coverageInclude,
59
+ exclude: coverageExclude
60
+ },
61
+ typecheck: { enabled: true },
62
+ pool: "forks",
63
+ isolate: true,
64
+ sequence: { shuffle: true },
65
+ testTimeout: 1e4
66
+ },
67
+ plugins
68
+ });
80
69
  }
81
- module.exports = vite_test_config;
70
+ //#endregion
71
+ exports.default = vite_test_config_default;