@prosopo/config 3.3.4 → 3.3.6

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 +32 -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 -210
  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 +158 -202
  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 +9 -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 +19 -8
  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,211 +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 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
- const openBundleStats = process.env.PROSOPO_BUNDLE_STATS?.trim().toLowerCase() === "true";
23
- process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
24
- console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
25
- const define = {
26
- // used to stop websockets package from breaking
27
- "process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
28
- "process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
29
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
30
- "process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(defaultEnvironment),
31
- "process.env.PROSOPO_SERVER_URL": JSON.stringify(
32
- process.env.PROSOPO_SERVER_URL
33
- ),
34
- "process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
35
- process.env._DEV_ONLY_WATCH_EVENTS
36
- ),
37
- "process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(
38
- process.env.PROSOPO_MONGO_EVENTS_URI
39
- ),
40
- "process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(
41
- process.env.PROSOPO_PACKAGE_VERSION
42
- ),
43
- "process.env.PROSOPO_DOCS_URL": JSON.stringify(
44
- process.env.PROSOPO_DOCS_URL
45
- ),
46
- "process.env.PROSOPO_LOG_LEVEL": JSON.stringify(
47
- process.env.PROSOPO_LOG_LEVEL
48
- ),
49
- // only needed if bundling with a site key
50
- "process.env.PROSOPO_SITE_KEY": JSON.stringify(
51
- process.env.PROSOPO_SITE_KEY
52
- )
53
- };
54
- console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
55
- const { dependencies: deps, optionalPeerDependencies } = await dependencies.getDependencies(packageName, isProduction);
56
- const { external, internal } = dependencies.filterDependencies(deps, [
57
- "pm2",
58
- "nodejs-polars",
59
- "aws",
60
- "webpack",
61
- "vite",
62
- "i18next-fs-backend"
63
- ]);
64
- const allExternal = [
65
- ...node_module.builtinModules,
66
- ...node_module.builtinModules.map((m) => `node:${m}`),
67
- ...external,
68
- ...optionalPeerDependencies
69
- ];
70
- console.debug(
71
- `Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`
72
- );
73
- const proto = RegExp.prototype;
74
- proto.toJSON = RegExp.prototype.toString;
75
- let drop;
76
- let pure = [];
77
- if (isProduction) {
78
- drop = ["debugger"];
79
- pure = ["console.log", "console.warn", "console.info", "console.debug"];
80
- }
81
- const rollupExternal = allExternal;
82
- console.info({ bundleName }, "Bundle name");
83
- return {
84
- server: {
85
- host: "127.0.0.1"
86
- },
87
- mode: mode || "development",
88
- optimizeDeps: {
89
- include: ["node_modules"],
90
- force: true
91
- },
92
- worker: {
93
- format: "es"
94
- },
95
- esbuild: {
96
- platform: "browser",
97
- target: [
98
- "es2020",
99
- "chrome60",
100
- "edge18",
101
- "firefox60",
102
- "node24",
103
- "safari11"
104
- ],
105
- drop,
106
- pure,
107
- legalComments: "none",
108
- jsx: "automatic",
109
- jsxImportSource: "@emotion/react",
110
- jsxDev: process.env.NODE_ENV === "development"
111
- },
112
- define,
113
- build: {
114
- outDir: path.resolve(dir, "dist/bundle"),
115
- minify: isProduction,
116
- ssr: false,
117
- lib: {
118
- entry: path.resolve(dir, entry),
119
- name: bundleName,
120
- fileName: `${bundleName}.bundle.js`,
121
- formats: ["es"]
122
- },
123
- modulePreload: { polyfill: true },
124
- commonjsOptions: {
125
- exclude: ["mongodb/*"],
126
- transformMixedEsModules: true,
127
- strictRequires: "debug"
128
- },
129
- rollupOptions: {
130
- treeshake: {
131
- annotations: false,
132
- propertyReadSideEffects: false,
133
- tryCatchDeoptimization: false,
134
- moduleSideEffects: "no-external",
135
- //true,
136
- preset: "smallest",
137
- unknownGlobalSideEffects: false
138
- },
139
- experimentalLogSideEffects: false,
140
- external: rollupExternal,
141
- watch: false,
142
- output: {
143
- dir: path.resolve(dir, "dist/bundle"),
144
- entryFileNames: `${bundleName}.bundle.js`
145
- },
146
- plugins: [
147
- vitePluginNodePolyfills.nodePolyfills({
148
- include: ["crypto"]
149
- }),
150
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
151
- css(),
152
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
153
- pluginWasm.wasm(),
154
- // @ts-ignore
155
- nodeResolve({
156
- browser: true,
157
- preferBuiltins: false,
158
- rootDir: path.resolve(dir, "../../"),
159
- dedupe: ["react", "react-dom"],
160
- modulesOnly: true
161
- // biome-ignore lint/suspicious/noExplicitAny: has to be any to represent object prototype
162
- }),
163
- // String replacement plugin for fingerprinting code
164
- {
165
- name: "string-replace-fingerprint",
166
- generateBundle(_, bundle) {
167
- for (const fileName in bundle) {
168
- const chunk = bundle[fileName];
169
- if (chunk && chunk.type === "chunk" && "code" in chunk && chunk.code) {
170
- chunk.code = chunk.code.replace(
171
- /var request = new XMLHttpRequest\(\);\s*request\.open\("get", "https:\/\/m1\.openfpcdn\.io\/fingerprintjs\/v"\.concat\(version, "\/npm-monitoring"\), true\);\s*request\.send\(\);/g,
172
- ""
173
- );
174
- }
175
- }
176
- }
177
- },
178
- // Bundle stats page — only wired in (and opened in the
179
- // browser) when PROSOPO_BUNDLE_STATS=true. Defaults off so
180
- // normal builds neither emit the report nor pop a window.
181
- ...openBundleStats ? [
182
- rollupPluginVisualizer.visualizer({
183
- open: true,
184
- template: "treemap",
185
- gzipSize: true,
186
- brotliSize: true
187
- })
188
- ] : [],
189
- // I think we can use this plugin to build all packages instead of relying on the tsc step that's
190
- // currently a precursor in package.json. However, it fails for the following reason:
191
- // https://github.com/rollup/plugins/issues/243
192
- // @ts-ignore
193
- typescript({
194
- tsconfig: path.resolve("./tsconfig.json"),
195
- compilerOptions: { rootDir: path.resolve("./src") },
196
- outDir: path.resolve(dir, "dist/bundle")
197
- })
198
- ]
199
- }
200
- },
201
- plugins: [
202
- // Not sure if we need this plugin or not, it works without it
203
- // @ts-ignore
204
- viteReact(),
205
- // Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
206
- // mode, in which case we don't want to close the bundler because it will close the server
207
- command !== "serve" ? vitePluginCloseAndCopy(copyOptions) : void 0
208
- ]
209
- };
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
+ };
210
172
  }
211
- 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;