Skip to content

Commit 8d4b17a

Browse files
committed
refactor: use the actual implementation type in optimization.ts instead of hand-copying
Re-export from the source module so its type stays the single source of truth.
1 parent 8e30f50 commit 8d4b17a

2 files changed

Lines changed: 15 additions & 42 deletions

File tree

rollup.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,19 @@ export default {
2727
{ src: 'src/index.d.ts', dest: 'dist' },
2828
],
2929
}),
30+
copy({
31+
// 'writeBundle' runs after @rollup/plugin-typescript has flushed its
32+
// declaration files to dist/types, so there's something to copy from.
33+
// A separate plugin instance (vs. adding this target above, which runs
34+
// on the default 'buildEnd' hook) keeps it from firing before the
35+
// declarations exist.
36+
hook: 'writeBundle',
37+
targets: [
38+
// src/index.d.ts re-exports from './main/optimization', which must
39+
// resolve relative to dist/index.d.ts — mirror the generated
40+
// declaration there instead of leaving it under dist/types/src/main.
41+
{ src: 'dist/types/src/main/optimization.d.ts', dest: 'dist/main' },
42+
],
43+
}),
3044
],
3145
};

src/index.d.ts

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,4 @@ export function validateLocales(
6464
requiredLocales: string[],
6565
): void;
6666

67-
/**
68-
* Manages a local on-disk cache of optimization configuration files.
69-
*/
70-
export const localOptimizationConfig: {
71-
/**
72-
* Downloads `percent.json` from the remote server and saves it to `configPath`.
73-
* Creates `configPath` if it does not exist.
74-
*
75-
* @param configPath - Directory where `percent.json` will be written.
76-
*/
77-
downloadPercentJson(configPath: string): Promise<void>;
78-
79-
/**
80-
* Reads the local `percent.json`, downloads any missing `stats.json` files
81-
* for each listed filter, and saves them to disk.
82-
* Existing `stats.json` files are not overwritten (preserves user edits).
83-
*
84-
* When `filterIds` is a non-empty array only those filters are processed;
85-
* pass an empty array to process all filters listed in `percent.json`.
86-
*
87-
* @param {string} configPath - Directory containing `percent.json`.
88-
* @param {number[]} filterIds - Filter IDs to process; empty array processes all.
89-
*/
90-
downloadStatsFromPercentJson(configPath: string, filterIds: number[]): Promise<void>;
91-
92-
/**
93-
* Configures `getFilterOptimizationConfig` to read stats from local files under
94-
* `configPath` instead of fetching from the remote server.
95-
* Stats are loaded lazily on demand during compilation.
96-
*
97-
* @param {string} configPath - Directory containing `percent.json` and
98-
* `filters/<filterId>/stats.json`.
99-
*/
100-
useLocalConfig(configPath: string): void;
101-
102-
/**
103-
* Removes the cache directory and clears in-memory state.
104-
*
105-
* @param configPath - Directory to remove.
106-
*/
107-
reset(configPath: string): Promise<void>;
108-
};
67+
export { localOptimizationConfig } from './main/optimization';

0 commit comments

Comments
 (0)