@keychord/config 0.0.2 → 0.0.4
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/exports/default.d.mts +15 -5
- package/exports/default.mjs +24 -11
- package/package.json +10 -9
- package/src/default.ts +25 -18
package/exports/default.d.mts
CHANGED
|
@@ -4,16 +4,26 @@ type Options = {
|
|
|
4
4
|
dts?: boolean;
|
|
5
5
|
};
|
|
6
6
|
declare function config(options?: Options): {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
pack: ({
|
|
8
|
+
entry: string;
|
|
9
|
+
clean: boolean;
|
|
10
10
|
outDir: string;
|
|
11
11
|
dts: boolean | undefined;
|
|
12
|
-
fixedExtension:
|
|
12
|
+
fixedExtension: boolean;
|
|
13
13
|
deps: {
|
|
14
|
+
onlyBundle: never;
|
|
15
|
+
alwaysBundle: RegExp[];
|
|
14
16
|
neverBundle: string[];
|
|
15
17
|
};
|
|
16
|
-
}
|
|
18
|
+
} | {
|
|
19
|
+
entry: string;
|
|
20
|
+
copy: {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
}[] | undefined;
|
|
24
|
+
outDir: string;
|
|
25
|
+
fixedExtension: false;
|
|
26
|
+
})[];
|
|
17
27
|
};
|
|
18
28
|
//#endregion
|
|
19
29
|
export { Options, config };
|
package/exports/default.mjs
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import virtual from "vite-plugin-virtual";
|
|
4
3
|
//#region src/default.ts
|
|
5
4
|
function config(options) {
|
|
6
5
|
const srcJsDirpath = path.join(process.cwd(), "src/js");
|
|
7
6
|
let entry = {};
|
|
8
7
|
if (fs.existsSync(srcJsDirpath) && fs.statSync(srcJsDirpath).isDirectory()) for (const filename of fs.readdirSync(srcJsDirpath).filter((file) => file.endsWith(".ts"))) entry[path.parse(filename).name] = path.join(srcJsDirpath, filename);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
return { pack: [{
|
|
9
|
+
entry: "package.json",
|
|
10
|
+
copy: options?.vendor?.flatMap((packageName) => {
|
|
11
|
+
return [{
|
|
12
|
+
from: `node_modules/${packageName}/js`,
|
|
13
|
+
to: `js/${packageName}`
|
|
14
|
+
}, {
|
|
15
|
+
from: `node_modules/${packageName}/chords`,
|
|
16
|
+
to: `chords/${packageName}`
|
|
17
|
+
}];
|
|
18
|
+
}),
|
|
19
|
+
outDir: "js",
|
|
20
|
+
fixedExtension: false
|
|
21
|
+
}, ...Object.values(entry).map((entry) => ({
|
|
22
|
+
entry,
|
|
23
|
+
clean: false,
|
|
24
|
+
outDir: "js",
|
|
25
|
+
dts: options?.dts,
|
|
26
|
+
fixedExtension: false,
|
|
27
|
+
deps: {
|
|
28
|
+
onlyBundle: false,
|
|
29
|
+
alwaysBundle: [/.*/],
|
|
30
|
+
neverBundle: ["chord", ...options?.vendor ?? []]
|
|
18
31
|
}
|
|
19
|
-
};
|
|
32
|
+
}))] };
|
|
20
33
|
}
|
|
21
34
|
//#endregion
|
|
22
35
|
export { config };
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keychord/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"exports"
|
|
7
7
|
],
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./
|
|
10
|
+
".": "./src/default.ts",
|
|
11
11
|
"./package.json": "./package.json"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
"access": "public",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./exports/default.mjs",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
}
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@keychord/eslint-plugin-package-json": "^0.0.0",
|
|
22
22
|
"@tsconfig/vite-react": "^7.0.2",
|
|
23
23
|
"@types/node": "^25.5.0",
|
|
24
24
|
"vite-plus": "^0.1.14"
|
|
25
|
-
}
|
|
26
|
-
|
|
25
|
+
},
|
|
26
|
+
"packageManager": "pnpm@10.33.0"
|
|
27
|
+
}
|
package/src/default.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import virtual from "vite-plugin-virtual";
|
|
4
3
|
import type { UserConfig } from "vite-plus";
|
|
5
4
|
|
|
6
5
|
export type Options = {
|
|
@@ -19,28 +18,36 @@ export function config(options?: Options) {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
if (Object.keys(entry).length === 0) {
|
|
23
|
-
entry["noop"] = "virtual:empty";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
// const specifier = fileURLToPath(import.meta.resolve('@keychord/eslint-plugin-package-json'))
|
|
27
22
|
// const eslintBinPath = path.join(fileURLToPath(import.meta.resolve('eslint/package.json')), '../bin/eslint.js');
|
|
28
23
|
|
|
29
24
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
neverBundle: ["chord", ...(options?.vendor ?? [])],
|
|
25
|
+
pack: [
|
|
26
|
+
{
|
|
27
|
+
entry: 'package.json',
|
|
28
|
+
copy: options?.vendor?.flatMap(packageName => {
|
|
29
|
+
return [
|
|
30
|
+
{ from: `node_modules/${packageName}/js`, to: `js/${packageName}` },
|
|
31
|
+
{ from: `node_modules/${packageName}/chords`, to: `chords/${packageName}` }
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
outDir: 'js',
|
|
35
|
+
fixedExtension: false,
|
|
42
36
|
},
|
|
43
|
-
|
|
37
|
+
...Object.values(entry).map(entry => ({
|
|
38
|
+
entry,
|
|
39
|
+
clean: false,
|
|
40
|
+
outDir: 'js',
|
|
41
|
+
dts: options?.dts,
|
|
42
|
+
fixedExtension: false,
|
|
43
|
+
deps: {
|
|
44
|
+
// This is needed to remove the warning from console output, but tsdown types don't like for some reason so we cast it to never
|
|
45
|
+
onlyBundle: false as never,
|
|
46
|
+
alwaysBundle: [/.*/],
|
|
47
|
+
neverBundle: ["chord", ...(options?.vendor ?? [])],
|
|
48
|
+
},
|
|
49
|
+
}))
|
|
50
|
+
] satisfies UserConfig["pack"],
|
|
44
51
|
// run: {
|
|
45
52
|
// tasks: {
|
|
46
53
|
// fix: {
|