mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
87c43562d3
Move the package's public entry points into a dedicated src/sdk/ folder so the
public surface lives in one clearly-owned place, per plans/perfect-shape.md §5.5
("sdk/ = re-export barrels only") and the §3 target DAG. Follows the #951/#960
pattern (behaviorless path codemod; rslib entry KEYS unchanged so dist output
paths — and therefore package.json `exports` — stay byte-identical).
Barrel structure (all 11 public subpaths now resolve through src/sdk/):
- 9 already-thin barrels moved verbatim (git rename, internal import paths
re-depthed by one ../): index, artifacts, metro, batch, remote-config,
install-source, android-adb, contracts, selectors.
- io and finders keep their implementation at src root (real logic + internal
importers); src/sdk/io.ts and src/sdk/finders.ts re-export them (export *).
package.json exports/main/types: UNCHANGED. Each rslib entry key is preserved
(index, io, ...), so dist output stays dist/src/<name>.{js,d.ts} and the
published subpaths + files do not move. No exports rewrite was needed.
Repoints:
- rslib.config.ts: 11 entry sources -> src/sdk/*.ts (keys unchanged).
- 7 public *-test imports -> src/sdk/*.
- 3 internal src importers of the selectors barrel (find.ts, selector-read.ts,
resolution.ts) split to import impl directly (utils/selectors-parse.ts +
daemon/selectors.ts) — removes internal dependence on the public barrel.
- .fallowrc.json entrypoints + vitest coverage exclude (src/sdk/** glob).
Published-surface verification (npm pack --dry-run before/after):
- exports map identical; 146 packed files identical EXCEPT one internal
code-split chunk renumbered (dist/src/9836.js -> 893.js, byte-identical
content).
- All 11 public .d.ts byte-identical; 10/11 public .js byte-identical;
selectors.js differs only by that internal chunk reference. Same symbols.
Gates: tsc 0 · rslib build 0 · oxfmt/oxlint clean · fallow audit (31 files) clean
· vitest unit 2883 pass.
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { defineConfig } from '@rslib/core';
|
|
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'),
|
|
) as { version: string };
|
|
|
|
export default defineConfig({
|
|
lib: [
|
|
{
|
|
format: 'esm',
|
|
syntax: 'es2022',
|
|
dts: {
|
|
bundle: true,
|
|
tsgo: true,
|
|
},
|
|
shims: {
|
|
esm: {
|
|
__filename: true,
|
|
},
|
|
},
|
|
source: {
|
|
entry: {
|
|
index: 'src/sdk/index.ts',
|
|
io: 'src/sdk/io.ts',
|
|
artifacts: 'src/sdk/artifacts.ts',
|
|
batch: 'src/sdk/batch.ts',
|
|
metro: 'src/sdk/metro.ts',
|
|
'remote-config': 'src/sdk/remote-config.ts',
|
|
'install-source': 'src/sdk/install-source.ts',
|
|
'android-adb': 'src/sdk/android-adb.ts',
|
|
contracts: 'src/sdk/contracts.ts',
|
|
selectors: 'src/sdk/selectors.ts',
|
|
finders: 'src/sdk/finders.ts',
|
|
'internal/bin': 'src/bin.ts',
|
|
'internal/companion-tunnel': 'src/client/companion-tunnel.ts',
|
|
'internal/daemon': 'src/daemon.ts',
|
|
'internal/png-worker': 'src/utils/png-worker.ts',
|
|
'internal/update-check-entry': 'src/utils/update-check-entry.ts',
|
|
},
|
|
tsconfigPath: 'tsconfig.lib.json',
|
|
define: {
|
|
__AGENT_DEVICE_VERSION__: JSON.stringify(packageJson.version),
|
|
},
|
|
},
|
|
output: {
|
|
distPath: {
|
|
root: path.join('dist', 'src'),
|
|
},
|
|
minify: true,
|
|
},
|
|
},
|
|
],
|
|
});
|