@prosopo/config 3.4.1 → 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 +9 -11
- package/.turbo/turbo-build$colon$tsc.log +4 -7
- package/.turbo/turbo-build.log +10 -15
- package/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/dist/cjs/dependencies.cjs +86 -46
- package/dist/cjs/vite/testFileGlobs.cjs +31 -0
- package/dist/cjs/vite/vite.frontend.config.cjs +7 -0
- package/dist/cjs/vite/vite.test.config.cjs +9 -8
- package/dist/cjs/vite/vite.threads.test.config.cjs +9 -8
- 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/configs.test.js +6 -19
- package/dist/vite/configs.test.js.map +1 -1
- package/dist/vite/testFileGlobs.d.ts +8 -0
- package/dist/vite/testFileGlobs.d.ts.map +1 -0
- package/dist/vite/testFileGlobs.js +29 -0
- package/dist/vite/testFileGlobs.js.map +1 -0
- package/dist/vite/testFileGlobs.test.d.ts +2 -0
- package/dist/vite/testFileGlobs.test.d.ts.map +1 -0
- package/dist/vite/testFileGlobs.test.js +113 -0
- package/dist/vite/testFileGlobs.test.js.map +1 -0
- 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/vite/vite.test.config.d.ts.map +1 -1
- package/dist/vite/vite.test.config.js +9 -8
- package/dist/vite/vite.test.config.js.map +1 -1
- package/dist/vite/vite.threads.test.config.d.ts.map +1 -1
- package/dist/vite/vite.threads.test.config.js +9 -8
- package/dist/vite/vite.threads.test.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 -235
- 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/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 -121
- package/src/vite/vite.threads.test.config.ts +0 -106
- 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
package/package.json
CHANGED
|
@@ -1,104 +1,107 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
2
|
+
"name": "@prosopo/config",
|
|
3
|
+
"version": "3.4.3",
|
|
4
|
+
"description": "Prosopo config library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^24"
|
|
8
|
+
},
|
|
9
|
+
"author": "Prosopo Limited",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
13
|
+
"@rollup/plugin-typescript": "11.1.6",
|
|
14
|
+
"@rollup/plugin-wasm": "6.2.2",
|
|
15
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
16
|
+
"esbuild": "0.28.2",
|
|
17
|
+
"fast-glob": "3.3.3",
|
|
18
|
+
"html-webpack-plugin": "5.6.8",
|
|
19
|
+
"mini-css-extract-plugin": "2.10.2",
|
|
20
|
+
"node-polyfill-webpack-plugin": "4.1.0",
|
|
21
|
+
"rollup": "4.63.1",
|
|
22
|
+
"rollup-plugin-import-css": "4.2.1",
|
|
23
|
+
"rollup-plugin-visualizer": "5.12.0",
|
|
24
|
+
"terser-webpack-plugin": "5.6.1",
|
|
25
|
+
"vite-plugin-no-bundle": "4.0.0",
|
|
26
|
+
"vite-tsconfig-paths": "6.1.1",
|
|
27
|
+
"yaml": "2.9.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "7.29.7",
|
|
31
|
+
"@babel/plugin-proposal-import-attributes-to-assertions": "7.29.7",
|
|
32
|
+
"@babel/plugin-syntax-import-attributes": "7.29.7",
|
|
33
|
+
"@babel/plugin-transform-class-properties": "7.27.1",
|
|
34
|
+
"@babel/plugin-transform-object-rest-spread": "8.0.1",
|
|
35
|
+
"@babel/plugin-transform-react-jsx": "8.0.1",
|
|
36
|
+
"@babel/plugin-transform-runtime": "7.28.5",
|
|
37
|
+
"@babel/preset-env": "8.0.5",
|
|
38
|
+
"@babel/preset-typescript": "7.28.5",
|
|
39
|
+
"@babel/runtime": "7.29.7",
|
|
40
|
+
"@rollup/plugin-alias": "6.0.0",
|
|
41
|
+
"@rollup/plugin-babel": "7.1.0",
|
|
42
|
+
"@rollup/plugin-dynamic-import-vars": "2.1.5",
|
|
43
|
+
"@rollup/plugin-json": "6.1.0",
|
|
44
|
+
"@types/node": "22.10.2",
|
|
45
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
46
|
+
"babel-loader": "9.2.1",
|
|
47
|
+
"concurrently": "9.0.1",
|
|
48
|
+
"css-loader": "7.1.5",
|
|
49
|
+
"del-cli": "6.0.0",
|
|
50
|
+
"npm-run-all": "4.1.5",
|
|
51
|
+
"regenerator-runtime": "0.14.1",
|
|
52
|
+
"rollup-plugin-cleanup": "3.2.1",
|
|
53
|
+
"string-replace-loader": "3.3.0",
|
|
54
|
+
"tsconfig-paths": "4.2.0",
|
|
55
|
+
"tslib": "2.7.0",
|
|
56
|
+
"tsx": "4.20.6",
|
|
57
|
+
"typescript": "5.6.2",
|
|
58
|
+
"vite": "8.1.5",
|
|
59
|
+
"vite-bundle-visualizer": "1.2.1",
|
|
60
|
+
"vite-plugin-node-polyfills": "0.28.0",
|
|
61
|
+
"vite-tsconfig-paths": "6.1.1",
|
|
62
|
+
"vitest": "4.1.11",
|
|
63
|
+
"webpack": "5.110.3",
|
|
64
|
+
"webpack-cli": "7.2.3",
|
|
65
|
+
"webpack-dev-server": "6.0.0",
|
|
66
|
+
"zod": "3.23.8"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/prosopo/captcha.git",
|
|
71
|
+
"directory": "dev/config"
|
|
72
|
+
},
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/prosopo/captcha/issues"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"registry": "https://registry.npmjs.org"
|
|
79
|
+
},
|
|
80
|
+
"sideEffects": false,
|
|
81
|
+
"main": "dist/index.js",
|
|
82
|
+
"types": "dist/index.d.ts",
|
|
83
|
+
"exports": {
|
|
84
|
+
".": {
|
|
85
|
+
"types": "./dist/index.d.ts",
|
|
86
|
+
"import": "./dist/index.js",
|
|
87
|
+
"require": "./dist/cjs/index.cjs"
|
|
88
|
+
},
|
|
89
|
+
"./webpack": {
|
|
90
|
+
"import": "./dist/webpack/index.js",
|
|
91
|
+
"require": "./dist/webpack/cjs/index.cjs"
|
|
92
|
+
},
|
|
93
|
+
"./webpack/webpack.config": {
|
|
94
|
+
"import": "./dist/webpack/webpack.config.js",
|
|
95
|
+
"require": "./dist/cjs/webpack/webpack.config.cjs"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"scripts": {
|
|
99
|
+
"build": "pnpm run build:cross-env --mode ${NODE_ENV:-development}",
|
|
100
|
+
"build:cross-env": "vite build --config vite.esm.config.ts",
|
|
101
|
+
"build:tsc": "tsc --build --verbose",
|
|
102
|
+
"build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
|
|
103
|
+
"clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
|
|
104
|
+
"typecheck": "tsc --project tsconfig.types.json",
|
|
105
|
+
"test": "NODE_ENV=${NODE_ENV:-test}; pnpm exec vitest run --config ./vite.test.config.ts --mode $NODE_ENV"
|
|
106
|
+
}
|
|
107
|
+
}
|
package/src/dependencies.test.ts
DELETED
|
@@ -1,249 +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 os from "node:os";
|
|
17
|
-
import path from "node:path";
|
|
18
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
19
|
-
import {
|
|
20
|
-
filterDependencies,
|
|
21
|
-
getExternalsFromReferences,
|
|
22
|
-
getTsConfigs,
|
|
23
|
-
} from "./dependencies.js";
|
|
24
|
-
|
|
25
|
-
let root: string;
|
|
26
|
-
|
|
27
|
-
/** Write a tsconfig, and optionally a sibling package.json, under `root`. */
|
|
28
|
-
const writeProject = (
|
|
29
|
-
dir: string,
|
|
30
|
-
references: string[],
|
|
31
|
-
packageName?: string,
|
|
32
|
-
): string => {
|
|
33
|
-
const absolute = path.join(root, dir);
|
|
34
|
-
fs.mkdirSync(absolute, { recursive: true });
|
|
35
|
-
const tsConfigPath = path.join(absolute, "tsconfig.json");
|
|
36
|
-
fs.writeFileSync(
|
|
37
|
-
tsConfigPath,
|
|
38
|
-
JSON.stringify({ references: references.map((p) => ({ path: p })) }),
|
|
39
|
-
);
|
|
40
|
-
if (packageName) {
|
|
41
|
-
fs.writeFileSync(
|
|
42
|
-
path.join(absolute, "package.json"),
|
|
43
|
-
JSON.stringify({ name: packageName }),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return tsConfigPath;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
root = fs.mkdtempSync(path.join(os.tmpdir(), "prosopo-config-test-"));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
afterEach(() => {
|
|
54
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("getTsConfigs", () => {
|
|
58
|
-
it("returns just the starting config when it has no references", () => {
|
|
59
|
-
const entry = writeProject("a", []);
|
|
60
|
-
expect(getTsConfigs(entry)).toEqual([entry]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("returns nothing when the starting config is excluded and has no references", () => {
|
|
64
|
-
const entry = writeProject("a", []);
|
|
65
|
-
expect(getTsConfigs(entry, [], [], false)).toEqual([]);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("walks references transitively", () => {
|
|
69
|
-
const c = writeProject("c", []);
|
|
70
|
-
const b = writeProject("b", ["../c"]);
|
|
71
|
-
const a = writeProject("a", ["../b"]);
|
|
72
|
-
|
|
73
|
-
expect(getTsConfigs(a, [/nothing-matches/], []).sort()).toEqual(
|
|
74
|
-
[a, b, c].sort(),
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("skips references matching an ignore pattern, and everything under them", () => {
|
|
79
|
-
writeProject("keep", []);
|
|
80
|
-
writeProject("skip", []);
|
|
81
|
-
const a = writeProject("a", ["../keep/", "../skip/"]);
|
|
82
|
-
|
|
83
|
-
expect(getTsConfigs(a, [/skip/], [])).toEqual([
|
|
84
|
-
a,
|
|
85
|
-
path.join(root, "keep", "tsconfig.json"),
|
|
86
|
-
]);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("builds the ignore expression from the stringified patterns, delimiters included", () => {
|
|
90
|
-
// `ignorePatterns.join("|")` calls `toString()` on each RegExp, so the
|
|
91
|
-
// enclosing slashes end up in the pattern. `/skip/` therefore matches
|
|
92
|
-
// the *path segment* "/skip/" rather than the bare word, which is why
|
|
93
|
-
// callers pass directory-shaped patterns.
|
|
94
|
-
writeProject("skip", []);
|
|
95
|
-
const a = writeProject("a", ["../skip"]);
|
|
96
|
-
|
|
97
|
-
// No trailing slash on the reference, so "/skip/" does not match and
|
|
98
|
-
// the reference is followed after all.
|
|
99
|
-
expect(getTsConfigs(a, [/skip/], [])).toHaveLength(2);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("drops every reference when no ignore pattern is given", () => {
|
|
103
|
-
writeProject("b", []);
|
|
104
|
-
const a = writeProject("a", ["../b"]);
|
|
105
|
-
expect(getTsConfigs(a)).toEqual([a]);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("appends tsconfig.json to a reference that names a directory", () => {
|
|
109
|
-
writeProject("b", []);
|
|
110
|
-
const a = writeProject("a", ["../b"]);
|
|
111
|
-
expect(getTsConfigs(a, [/\.\./], [])).toContain(
|
|
112
|
-
path.join(root, "b", "tsconfig.json"),
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("honours a reference that names a config file explicitly", () => {
|
|
117
|
-
fs.mkdirSync(path.join(root, "b"), { recursive: true });
|
|
118
|
-
const explicit = path.join(root, "b", "tsconfig.build.json");
|
|
119
|
-
fs.writeFileSync(explicit, JSON.stringify({ references: [] }));
|
|
120
|
-
const a = writeProject("a", ["../b/tsconfig.build.json"]);
|
|
121
|
-
|
|
122
|
-
expect(getTsConfigs(a, [/\.\./], [])).toContain(explicit);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("does not loop forever on a reference cycle", () => {
|
|
126
|
-
// A cycle in the project graph would otherwise recurse until the stack
|
|
127
|
-
// blew, which is a build hang rather than a readable error.
|
|
128
|
-
const a = path.join(root, "a", "tsconfig.json");
|
|
129
|
-
const b = path.join(root, "b", "tsconfig.json");
|
|
130
|
-
writeProject("a", ["../b"]);
|
|
131
|
-
writeProject("b", ["../a"]);
|
|
132
|
-
|
|
133
|
-
expect(getTsConfigs(a, [/\.\./], []).sort()).toEqual([a, b].sort());
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("visits a diamond dependency only once", () => {
|
|
137
|
-
writeProject("d", []);
|
|
138
|
-
writeProject("b", ["../d"]);
|
|
139
|
-
writeProject("c", ["../d"]);
|
|
140
|
-
const a = writeProject("a", ["../b", "../c"]);
|
|
141
|
-
|
|
142
|
-
const result = getTsConfigs(a, [/\.\./], []);
|
|
143
|
-
expect(new Set(result).size).toBe(result.length);
|
|
144
|
-
expect(result).toHaveLength(4);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("keeps configs that were already accumulated", () => {
|
|
148
|
-
const existing = "/already/seen/tsconfig.json";
|
|
149
|
-
const a = writeProject("a", []);
|
|
150
|
-
expect(getTsConfigs(a, [], [existing])).toEqual([existing, a]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("returns the accumulator untouched when the config was already seen", () => {
|
|
154
|
-
const a = writeProject("a", []);
|
|
155
|
-
expect(getTsConfigs(a, [], [a])).toEqual([a]);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("throws for a config path that does not exist", () => {
|
|
159
|
-
expect(() => getTsConfigs(path.join(root, "missing.json"))).toThrow();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("throws for a config that is not valid JSON", () => {
|
|
163
|
-
const broken = path.join(root, "broken.json");
|
|
164
|
-
fs.writeFileSync(broken, "{ not json");
|
|
165
|
-
expect(() => getTsConfigs(broken)).toThrow();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe("getExternalsFromReferences", () => {
|
|
170
|
-
it("returns the package name of every referenced project", async () => {
|
|
171
|
-
writeProject("b", [], "@prosopo/b");
|
|
172
|
-
writeProject("c", [], "@prosopo/c");
|
|
173
|
-
const a = writeProject("a", ["../b", "../c"], "@prosopo/a");
|
|
174
|
-
|
|
175
|
-
// The starting project is excluded, so a package never externalises
|
|
176
|
-
// itself.
|
|
177
|
-
await expect(getExternalsFromReferences(a, [/\.\./])).resolves.toEqual([
|
|
178
|
-
"@prosopo/b",
|
|
179
|
-
"@prosopo/c",
|
|
180
|
-
]);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("returns nothing when there are no followed references", async () => {
|
|
184
|
-
const a = writeProject("a", [], "@prosopo/a");
|
|
185
|
-
await expect(getExternalsFromReferences(a)).resolves.toEqual([]);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("rejects when a referenced project has no package.json", async () => {
|
|
189
|
-
writeProject("b", []);
|
|
190
|
-
const a = writeProject("a", ["../b"], "@prosopo/a");
|
|
191
|
-
await expect(getExternalsFromReferences(a, [/\.\./])).rejects.toBeDefined();
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe("filterDependencies", () => {
|
|
196
|
-
it("splits on the filter patterns, sorted", () => {
|
|
197
|
-
expect(
|
|
198
|
-
filterDependencies(["zod", "@prosopo/util", "axios"], ["@prosopo"]),
|
|
199
|
-
).toEqual({
|
|
200
|
-
internal: ["axios", "zod"],
|
|
201
|
-
external: ["@prosopo/util"],
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("treats the filters as alternatives in a single expression", () => {
|
|
206
|
-
expect(
|
|
207
|
-
filterDependencies(["a-one", "b-two", "c-three"], ["one", "two"]),
|
|
208
|
-
).toEqual({ internal: ["c-three"], external: ["a-one", "b-two"] });
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("deduplicates before splitting", () => {
|
|
212
|
-
expect(
|
|
213
|
-
filterDependencies(["zod", "zod", "zod"], ["nope"]).internal,
|
|
214
|
-
).toEqual(["zod"]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("drops empty strings", () => {
|
|
218
|
-
// `npm ls` output can yield blank captures; an empty external pattern
|
|
219
|
-
// would otherwise match everything downstream.
|
|
220
|
-
expect(filterDependencies(["", "zod", ""], ["nope"])).toEqual({
|
|
221
|
-
internal: ["zod"],
|
|
222
|
-
external: [],
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("returns two empty lists for no dependencies", () => {
|
|
227
|
-
expect(filterDependencies([], ["@prosopo"])).toEqual({
|
|
228
|
-
internal: [],
|
|
229
|
-
external: [],
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it("puts everything in external when a filter matches all", () => {
|
|
234
|
-
expect(filterDependencies(["a", "b"], [""]).external).toEqual(["a", "b"]);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it("puts everything in internal when no filter is supplied", () => {
|
|
238
|
-
// An empty filter list joins to an empty pattern, which matches
|
|
239
|
-
// everything — so this is the same all-external case, documented so
|
|
240
|
-
// the surprise is not discovered during a build.
|
|
241
|
-
expect(filterDependencies(["a", "b"], []).external).toEqual(["a", "b"]);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it("does not mutate the input", () => {
|
|
245
|
-
const deps = ["zod", "axios"];
|
|
246
|
-
filterDependencies(deps, ["zod"]);
|
|
247
|
-
expect(deps).toEqual(["zod", "axios"]);
|
|
248
|
-
});
|
|
249
|
-
});
|