@keychord/config 0.0.0

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/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@keychord/config",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./exports/default.mjs",
7
+ "./package.json": "./package.json"
8
+ },
9
+ "dependencies": {
10
+ "eslint": "^10.1.0",
11
+ "outdent": "^0.8.0",
12
+ "vite-plugin-virtual": "^0.5.0"
13
+ },
14
+ "devDependencies": {
15
+ "@keychord/eslint-plugin-package-json": "^0.0.0",
16
+ "@tsconfig/vite-react": "^7.0.2",
17
+ "@types/node": "^25.5.0",
18
+ "vite-plus": "^0.1.14"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ }
23
+ }
package/readme.md ADDED
@@ -0,0 +1,14 @@
1
+ # @keychord/config
2
+
3
+ ## Usage
4
+
5
+ ```ts
6
+ import { config } from '@keychord/config';
7
+
8
+ export default config({
9
+ dts: false, // set to true to generate `.d.ts` files in js/
10
+ vendor: [
11
+ // an array of chord packages used in this package
12
+ ]
13
+ });
14
+ ```
package/src/default.ts ADDED
@@ -0,0 +1,62 @@
1
+ import path from 'path'
2
+ import fs from 'fs'
3
+ import virtual from 'vite-plugin-virtual';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ export type Options = {
7
+ vendor?: string[];
8
+ dts?: boolean;
9
+ };
10
+
11
+ // Needs to be named `config` or else vite-plus thinks it's its `defineConfig`
12
+ export function config(options?: Options) {
13
+ const srcJsDirpath = path.join(process.cwd(), 'src/js');
14
+ let entry: string | Record<string, string> = {};
15
+
16
+ if (fs.existsSync(srcJsDirpath) && fs.statSync(srcJsDirpath).isDirectory()) {
17
+ for (const filename of fs.readdirSync(srcJsDirpath).filter((file) => file.endsWith(".ts"))) {
18
+ entry[path.parse(filename).name] = path.join(srcJsDirpath, filename);
19
+ }
20
+ }
21
+
22
+ if (Object.keys(entry).length === 0) {
23
+ entry['noop'] = "virtual:empty";
24
+ }
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');
28
+
29
+ return {
30
+ plugins: [
31
+ virtual({
32
+ 'virtual:empty': '',
33
+ }),
34
+ ] as any[],
35
+ pack: {
36
+ entry,
37
+ outDir: "js",
38
+ deps: {
39
+ neverBundle: [
40
+ "chord",
41
+ ...(options?.vendor ?? [])
42
+ ]
43
+ },
44
+ },
45
+ run: {
46
+ tasks: {
47
+ fix: {
48
+ // 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
49
+ command: `
50
+ ${eslintBinPath} **/package.json \
51
+ --no-config-lookup \
52
+ --fix \
53
+ --plugin ${specifier} \
54
+ --rule '@keychord/package-json/type: error'
55
+ `,
56
+ }
57
+ }
58
+ },
59
+ // lint: {
60
+ // }
61
+ }
62
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "@tsconfig/vite-react",
3
+ "include": ["src"]
4
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "vite-plus";
2
+
3
+ export default defineConfig({
4
+ pack: {
5
+ entry: 'src/default.ts',
6
+ dts: true,
7
+ outDir: 'exports',
8
+ exports: {
9
+ devExports: true
10
+ }
11
+ },
12
+ });