c12 2.0.2 → 2.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/dist/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const loader = require('./shared/c12.D1gWAjF7.cjs');
3
+ const loader = require('./shared/c12.CMG3XLfD.cjs');
4
4
  const perfectDebounce = require('perfect-debounce');
5
5
  const pathe = require('pathe');
6
- const ohash = require('ohash');
7
6
  require('node:fs');
8
7
  require('node:fs/promises');
9
8
  require('node:os');
@@ -50,6 +49,7 @@ async function watchConfig(options) {
50
49
  )
51
50
  ];
52
51
  const watch = await import('chokidar').then((r) => r.watch || r.default || r);
52
+ const { diff } = await import('ohash/utils');
53
53
  const _fswatcher = watch(watchingFiles, {
54
54
  ignoreInitial: true,
55
55
  ...options.chokidarOptions
@@ -71,7 +71,7 @@ async function watchConfig(options) {
71
71
  const changeCtx = {
72
72
  newConfig,
73
73
  oldConfig,
74
- getDiff: () => ohash.diff(oldConfig.config, config.config)
74
+ getDiff: () => diff(oldConfig.config, config.config)
75
75
  };
76
76
  if (options.acceptHMR) {
77
77
  const changeHandled = await options.acceptHMR(changeCtx);
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Jiti, JitiOptions } from 'jiti';
2
2
  import { DownloadTemplateOptions } from 'giget';
3
3
  import { ChokidarOptions } from 'chokidar';
4
- import { diff } from 'ohash';
4
+ import { diff } from 'ohash/utils';
5
5
 
6
6
  interface DotenvOptions {
7
7
  /**
@@ -123,6 +123,7 @@ declare function createDefineConfig<T extends UserInputConfig = UserInputConfig,
123
123
  declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts", ".json", ".jsonc", ".json5", ".yaml", ".yml", ".toml"];
124
124
  declare function loadConfig<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta>(options: LoadConfigOptions<T, MT>): Promise<ResolvedConfig<T, MT>>;
125
125
 
126
+ type DiffEntries = ReturnType<typeof diff>;
126
127
  type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
127
128
  watchingFiles: string[];
128
129
  unwatch: () => Promise<void>;
@@ -135,7 +136,7 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
135
136
  path: string;
136
137
  }) => void | Promise<void>;
137
138
  acceptHMR?: (context: {
138
- getDiff: () => ReturnType<typeof diff>;
139
+ getDiff: () => DiffEntries;
139
140
  newConfig: ResolvedConfig<T, MT>;
140
141
  oldConfig: ResolvedConfig<T, MT>;
141
142
  }) => void | boolean | Promise<void | boolean>;
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.UwygHULp.mjs';
2
- export { a as loadDotenv, s as setupDotenv } from './shared/c12.UwygHULp.mjs';
1
+ import { l as loadConfig, S as SUPPORTED_EXTENSIONS } from './shared/c12.PQMoYrit.mjs';
2
+ export { a as loadDotenv, s as setupDotenv } from './shared/c12.PQMoYrit.mjs';
3
3
  import { debounce } from 'perfect-debounce';
4
4
  import { resolve } from 'pathe';
5
- import { diff } from 'ohash';
6
5
  import 'node:fs';
7
6
  import 'node:fs/promises';
8
7
  import 'node:os';
@@ -49,6 +48,7 @@ async function watchConfig(options) {
49
48
  )
50
49
  ];
51
50
  const watch = await import('chokidar').then((r) => r.watch || r.default || r);
51
+ const { diff } = await import('ohash/utils');
52
52
  const _fswatcher = watch(watchingFiles, {
53
53
  ignoreInitial: true,
54
54
  ...options.chokidarOptions
@@ -8,7 +8,6 @@ const jiti = require('jiti');
8
8
  const mlly = require('mlly');
9
9
  const rc9 = require('rc9');
10
10
  const defu = require('defu');
11
- const ohash = require('ohash');
12
11
  const pkgTypes = require('pkg-types');
13
12
  const dotenv = require('dotenv');
14
13
 
@@ -306,7 +305,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
306
305
  const _merger = options.merger || defu.defu;
307
306
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
308
307
  const { downloadTemplate } = await import('giget');
309
- const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + ohash.hash(source);
308
+ const { digest } = await import('ohash');
309
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
310
310
  let cloneDir;
311
311
  const localNodeModules = pathe.resolve(options.cwd, "node_modules");
312
312
  const parentDir = pathe.dirname(options.cwd);
@@ -6,7 +6,6 @@ import { createJiti } from 'jiti';
6
6
  import { fileURLToPath } from 'mlly';
7
7
  import * as rc9 from 'rc9';
8
8
  import { defu } from 'defu';
9
- import { hash } from 'ohash';
10
9
  import { findWorkspaceDir, readPackageJSON } from 'pkg-types';
11
10
  import * as dotenv from 'dotenv';
12
11
 
@@ -289,7 +288,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
289
288
  const _merger = options.merger || defu;
290
289
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
291
290
  const { downloadTemplate } = await import('giget');
292
- const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + hash(source);
291
+ const { digest } = await import('ohash');
292
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
293
293
  let cloneDir;
294
294
  const localNodeModules = resolve(options.cwd, "node_modules");
295
295
  const parentDir = dirname(options.cwd);
package/dist/update.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const mlly = require('mlly');
4
- const loader = require('./shared/c12.D1gWAjF7.cjs');
4
+ const loader = require('./shared/c12.CMG3XLfD.cjs');
5
5
  const pathe = require('pathe');
6
6
  const promises = require('node:fs/promises');
7
7
  const node_path = require('node:path');
@@ -10,7 +10,6 @@ require('node:os');
10
10
  require('jiti');
11
11
  require('rc9');
12
12
  require('defu');
13
- require('ohash');
14
13
  require('pkg-types');
15
14
  require('dotenv');
16
15
 
package/dist/update.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolvePath } from 'mlly';
2
- import { S as SUPPORTED_EXTENSIONS } from './shared/c12.UwygHULp.mjs';
2
+ import { S as SUPPORTED_EXTENSIONS } from './shared/c12.PQMoYrit.mjs';
3
3
  import { join } from 'pathe';
4
4
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
5
5
  import { dirname, extname } from 'node:path';
@@ -8,7 +8,6 @@ import 'node:os';
8
8
  import 'jiti';
9
9
  import 'rc9';
10
10
  import 'defu';
11
- import 'ohash';
12
11
  import 'pkg-types';
13
12
  import 'dotenv';
14
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c12",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Smart Config Loader",
5
5
  "repository": "unjs/c12",
6
6
  "license": "MIT",
@@ -8,14 +8,24 @@
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
14
19
  },
15
20
  "./update": {
16
- "import": "./dist/update.mjs",
17
- "require": "./dist/update.cjs",
18
- "types": "./dist/update.d.ts"
21
+ "import": {
22
+ "types": "./dist/update.d.mts",
23
+ "default": "./dist/update.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/update.d.cts",
27
+ "default": "./dist/update.cjs"
28
+ }
19
29
  }
20
30
  },
21
31
  "main": "./dist/index.cjs",
@@ -43,25 +53,25 @@
43
53
  "giget": "^1.2.4",
44
54
  "jiti": "^2.4.2",
45
55
  "mlly": "^1.7.4",
46
- "ohash": "^1.1.4",
47
- "pathe": "^2.0.2",
56
+ "ohash": "^2.0.4",
57
+ "pathe": "^2.0.3",
48
58
  "perfect-debounce": "^1.0.0",
49
59
  "pkg-types": "^1.3.1",
50
60
  "rc9": "^2.1.2"
51
61
  },
52
62
  "devDependencies": {
53
- "@types/node": "^22.13.1",
54
- "@vitest/coverage-v8": "^3.0.5",
63
+ "@types/node": "^22.13.4",
64
+ "@vitest/coverage-v8": "^3.0.6",
55
65
  "automd": "^0.3.12",
56
66
  "changelogen": "^0.5.7",
57
- "eslint": "^9.20.0",
67
+ "eslint": "^9.20.1",
58
68
  "eslint-config-unjs": "^0.4.2",
59
69
  "expect-type": "^1.1.0",
60
70
  "magicast": "^0.3.5",
61
- "prettier": "^3.5.0",
71
+ "prettier": "^3.5.1",
62
72
  "typescript": "^5.7.3",
63
73
  "unbuild": "^3.3.1",
64
- "vitest": "^3.0.5"
74
+ "vitest": "^3.0.6"
65
75
  },
66
76
  "peerDependencies": {
67
77
  "magicast": "^0.3.5"
@@ -71,5 +81,5 @@
71
81
  "optional": true
72
82
  }
73
83
  },
74
- "packageManager": "pnpm@10.3.0"
84
+ "packageManager": "pnpm@10.4.1"
75
85
  }