@keychord/config 0.0.1 → 0.0.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/exports/default.d.mts +7 -7
- package/exports/default.mjs +16 -12
- package/package.json +5 -6
- package/readme.md +2 -2
- package/src/default.ts +35 -29
package/exports/default.d.mts
CHANGED
|
@@ -8,16 +8,16 @@ declare function config(options?: Options): {
|
|
|
8
8
|
pack: {
|
|
9
9
|
entry: Record<string, string>;
|
|
10
10
|
outDir: string;
|
|
11
|
+
dts: boolean | undefined;
|
|
12
|
+
fixedExtension: false;
|
|
11
13
|
deps: {
|
|
14
|
+
alwaysBundle: RegExp[];
|
|
12
15
|
neverBundle: string[];
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
command: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
17
|
+
copy: {
|
|
18
|
+
from: string;
|
|
19
|
+
to: string;
|
|
20
|
+
}[] | undefined;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
//#endregion
|
package/exports/default.mjs
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import virtual from "vite-plugin-virtual";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
4
|
//#region src/default.ts
|
|
6
5
|
function config(options) {
|
|
7
6
|
const srcJsDirpath = path.join(process.cwd(), "src/js");
|
|
8
7
|
let entry = {};
|
|
9
8
|
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);
|
|
10
9
|
if (Object.keys(entry).length === 0) entry["noop"] = "virtual:empty";
|
|
11
|
-
const specifier = fileURLToPath(import.meta.resolve("@keychord/eslint-plugin-package-json"));
|
|
12
|
-
const eslintBinPath = path.join(fileURLToPath(import.meta.resolve("eslint/package.json")), "../bin/eslint.js");
|
|
13
10
|
return {
|
|
14
11
|
plugins: [virtual({ "virtual:empty": "" })],
|
|
15
12
|
pack: {
|
|
16
13
|
entry,
|
|
17
14
|
outDir: "js",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
dts: options?.dts,
|
|
16
|
+
fixedExtension: false,
|
|
17
|
+
deps: {
|
|
18
|
+
alwaysBundle: [/.*/],
|
|
19
|
+
neverBundle: ["chord", ...options?.vendor ?? []]
|
|
20
|
+
},
|
|
21
|
+
copy: options?.vendor?.flatMap((packageName) => {
|
|
22
|
+
return [{
|
|
23
|
+
from: `node_modules/${packageName}/js`,
|
|
24
|
+
to: `js/${packageName}`
|
|
25
|
+
}, {
|
|
26
|
+
from: `node_modules/${packageName}/chords`,
|
|
27
|
+
to: `chords/${packageName}`
|
|
28
|
+
}];
|
|
29
|
+
})
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
33
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keychord/config",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.3",
|
|
5
4
|
"files": [
|
|
6
5
|
"src",
|
|
7
6
|
"exports"
|
|
8
7
|
],
|
|
8
|
+
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./exports/default.mjs",
|
|
11
11
|
"./package.json": "./package.json"
|
|
12
12
|
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
13
16
|
"dependencies": {
|
|
14
|
-
"eslint": "^10.1.0",
|
|
15
17
|
"outdent": "^0.8.0",
|
|
16
18
|
"vite-plugin-virtual": "^0.5.0"
|
|
17
19
|
},
|
|
@@ -20,8 +22,5 @@
|
|
|
20
22
|
"@tsconfig/vite-react": "^7.0.2",
|
|
21
23
|
"@types/node": "^25.5.0",
|
|
22
24
|
"vite-plus": "^0.1.14"
|
|
23
|
-
},
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
26
25
|
}
|
|
27
26
|
}
|
package/readme.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { config } from
|
|
6
|
+
import { config } from "@keychord/config";
|
|
7
7
|
|
|
8
8
|
export default config({
|
|
9
9
|
dts: false, // set to true to generate `.d.ts` files in js/
|
|
10
10
|
vendor: [
|
|
11
11
|
// an array of chord packages used in this package
|
|
12
|
-
]
|
|
12
|
+
],
|
|
13
13
|
});
|
|
14
14
|
```
|
package/src/default.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import fs from
|
|
3
|
-
import virtual from
|
|
4
|
-
import {
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import virtual from "vite-plugin-virtual";
|
|
4
|
+
import type { UserConfig } from "vite-plus";
|
|
5
5
|
|
|
6
6
|
export type Options = {
|
|
7
7
|
vendor?: string[];
|
|
@@ -10,7 +10,7 @@ export type Options = {
|
|
|
10
10
|
|
|
11
11
|
// Needs to be named `config` or else vite-plus thinks it's its `defineConfig`
|
|
12
12
|
export function config(options?: Options) {
|
|
13
|
-
const srcJsDirpath = path.join(process.cwd(),
|
|
13
|
+
const srcJsDirpath = path.join(process.cwd(), "src/js");
|
|
14
14
|
let entry: string | Record<string, string> = {};
|
|
15
15
|
|
|
16
16
|
if (fs.existsSync(srcJsDirpath) && fs.statSync(srcJsDirpath).isDirectory()) {
|
|
@@ -20,43 +20,49 @@ export function config(options?: Options) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (Object.keys(entry).length === 0) {
|
|
23
|
-
entry[
|
|
23
|
+
entry["noop"] = "virtual:empty";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const specifier = fileURLToPath(import.meta.resolve('@keychord/eslint-plugin-package-json'))
|
|
27
|
-
const eslintBinPath = path.join(fileURLToPath(import.meta.resolve('eslint/package.json')), '../bin/eslint.js');
|
|
26
|
+
// const specifier = fileURLToPath(import.meta.resolve('@keychord/eslint-plugin-package-json'))
|
|
27
|
+
// const eslintBinPath = path.join(fileURLToPath(import.meta.resolve('eslint/package.json')), '../bin/eslint.js');
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
plugins: [
|
|
31
31
|
virtual({
|
|
32
|
-
|
|
32
|
+
"virtual:empty": "",
|
|
33
33
|
}),
|
|
34
34
|
] as any[],
|
|
35
35
|
pack: {
|
|
36
36
|
entry,
|
|
37
37
|
outDir: "js",
|
|
38
|
+
dts: options?.dts,
|
|
39
|
+
fixedExtension: false,
|
|
38
40
|
deps: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...(options?.vendor ?? [])
|
|
42
|
-
]
|
|
41
|
+
alwaysBundle: [/.*/],
|
|
42
|
+
neverBundle: ["chord", ...(options?.vendor ?? [])],
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
copy: options?.vendor?.flatMap(packageName => {
|
|
45
|
+
return [
|
|
46
|
+
{ from: `node_modules/${packageName}/js`, to: `js/${packageName}` },
|
|
47
|
+
{ from: `node_modules/${packageName}/chords`, to: `chords/${packageName}` }
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
} satisfies UserConfig["pack"],
|
|
51
|
+
// run: {
|
|
52
|
+
// tasks: {
|
|
53
|
+
// fix: {
|
|
54
|
+
// // Sadly, oxlint does not support fixing JSON files (see https://oxc.rs/compatibility.html), and oxfmt does not (yet) support plugins, so we fall back to using ESLint
|
|
55
|
+
// command: `
|
|
56
|
+
// ${eslintBinPath} **/package.json \
|
|
57
|
+
// --no-config-lookup \
|
|
58
|
+
// --fix \
|
|
59
|
+
// --plugin ${specifier} \
|
|
60
|
+
// --rule '@keychord/package-json/type: error'
|
|
61
|
+
// `,
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// },
|
|
59
65
|
// lint: {
|
|
60
66
|
// }
|
|
61
|
-
}
|
|
67
|
+
};
|
|
62
68
|
}
|