@keychord/config 0.0.1 → 0.0.2

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.
@@ -8,17 +8,12 @@ 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: {
12
14
  neverBundle: string[];
13
15
  };
14
16
  };
15
- run: {
16
- tasks: {
17
- fix: {
18
- command: string;
19
- };
20
- };
21
- };
22
17
  };
23
18
  //#endregion
24
19
  export { Options, config };
@@ -1,29 +1,21 @@
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",
15
+ dts: options?.dts,
16
+ fixedExtension: false,
18
17
  deps: { neverBundle: ["chord", ...options?.vendor ?? []] }
19
- },
20
- run: { tasks: { fix: { command: `
21
- ${eslintBinPath} **/package.json \
22
- --no-config-lookup \
23
- --fix \
24
- --plugin ${specifier} \
25
- --rule '@keychord/package-json/type: error'
26
- ` } } }
18
+ }
27
19
  };
28
20
  }
29
21
  //#endregion
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@keychord/config",
3
- "version": "0.0.1",
4
- "type": "module",
3
+ "version": "0.0.2",
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 '@keychord/config';
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 'path'
2
- import fs from 'fs'
3
- import virtual from 'vite-plugin-virtual';
4
- import { fileURLToPath } from 'url';
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(), 'src/js');
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,42 @@ export function config(options?: Options) {
20
20
  }
21
21
 
22
22
  if (Object.keys(entry).length === 0) {
23
- entry['noop'] = "virtual:empty";
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
- 'virtual:empty': '',
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
- neverBundle: [
40
- "chord",
41
- ...(options?.vendor ?? [])
42
- ]
41
+ neverBundle: ["chord", ...(options?.vendor ?? [])],
43
42
  },
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
- },
43
+ } satisfies UserConfig["pack"],
44
+ // run: {
45
+ // tasks: {
46
+ // fix: {
47
+ // // 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
48
+ // command: `
49
+ // ${eslintBinPath} **/package.json \
50
+ // --no-config-lookup \
51
+ // --fix \
52
+ // --plugin ${specifier} \
53
+ // --rule '@keychord/package-json/type: error'
54
+ // `,
55
+ // }
56
+ // }
57
+ // },
59
58
  // lint: {
60
59
  // }
61
- }
60
+ };
62
61
  }