From 19303da8de3e45f047878df028f01416e1f53e1f Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Wed, 12 Aug 2026 01:42:55 +0800 Subject: [PATCH] fix: no .map fix: no map --- apps/web/.npmignore | 1 + apps/web/package.json | 3 +- .../feedback/message-feedback/package.json | 4 +- packages/goal/goal/package.json | 4 +- packages/interaction/commands/package.json | 3 +- packages/typert/generator/src/workspace.ts | 4 +- .../remote-model/packages/remote/package.json | 3 +- scripts/check-workspace-constraints.ts | 17 +++---- scripts/publication-payload.spec.ts | 28 +++++------ scripts/publication-payload.ts | 48 +++++++++---------- scripts/publish-npm-baseline.ts | 10 ++-- scripts/release/families.ts | 6 +-- 12 files changed, 57 insertions(+), 74 deletions(-) create mode 100644 apps/web/.npmignore diff --git a/apps/web/.npmignore b/apps/web/.npmignore new file mode 100644 index 0000000000..46af539c17 --- /dev/null +++ b/apps/web/.npmignore @@ -0,0 +1 @@ +*.map \ No newline at end of file diff --git a/apps/web/package.json b/apps/web/package.json index 32edacefec..8a6e5e4789 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -16,7 +16,8 @@ "./package.json": "./package.json" }, "files": [ - "dist" + "dist", + "!dist/**/*.map" ], "scripts": { "build": "vite build", diff --git a/packages/feedback/message-feedback/package.json b/packages/feedback/message-feedback/package.json index 53f85868c2..acc7fc8fae 100644 --- a/packages/feedback/message-feedback/package.json +++ b/packages/feedback/message-feedback/package.json @@ -45,9 +45,7 @@ "lib/typert.host.js", "lib/typert.host.d.ts", "lib/typert.remote-client.js", - "lib/typert.remote-client.d.ts", - "lib/typert.remote-client.d.ts.map", - "src" + "lib/typert.remote-client.d.ts" ], "license": "BSD-3-Clause", "peerDependencies": { diff --git a/packages/goal/goal/package.json b/packages/goal/goal/package.json index 8a13ec7ceb..e5e57b6b07 100644 --- a/packages/goal/goal/package.json +++ b/packages/goal/goal/package.json @@ -49,9 +49,7 @@ "lib/typert.host.js", "lib/typert.host.d.ts", "lib/typert.remote-client.js", - "lib/typert.remote-client.d.ts", - "lib/typert.remote-client.d.ts.map", - "src" + "lib/typert.remote-client.d.ts" ], "license": "BSD-3-Clause", "peerDependencies": { diff --git a/packages/interaction/commands/package.json b/packages/interaction/commands/package.json index b654451b37..59ce5dcebe 100644 --- a/packages/interaction/commands/package.json +++ b/packages/interaction/commands/package.json @@ -49,8 +49,7 @@ "lib/typert.host.js", "lib/typert.host.d.ts", "lib/typert.remote-client.js", - "lib/typert.remote-client.d.ts", - "lib/typert.remote-client.d.ts.map" + "lib/typert.remote-client.d.ts" ], "license": "BSD-3-Clause", "peerDependencies": { diff --git a/packages/typert/generator/src/workspace.ts b/packages/typert/generator/src/workspace.ts index 4a303c4bd4..94d1d937e4 100644 --- a/packages/typert/generator/src/workspace.ts +++ b/packages/typert/generator/src/workspace.ts @@ -98,10 +98,12 @@ export class WorkspaceTypertGenerator { const remoteActual = manifest.exports !== null && typeof manifest.exports === 'object' ? (manifest.exports as Record)['./remote'] : undefined + // The declaration map is emitted beside these two but never published: it + // serves editor navigation in the workspace, where the package link + // resolves its source. const remoteFiles = [ 'lib/typert.remote-client.js', 'lib/typert.remote-client.d.ts', - 'lib/typert.remote-client.d.ts.map', ] if (artifact.remote === undefined) { if (remoteActual !== undefined || remoteFiles.some(file => files.includes(file))) { diff --git a/packages/typert/generator/tests/fixtures/remote-model/packages/remote/package.json b/packages/typert/generator/tests/fixtures/remote-model/packages/remote/package.json index b7e0631a0a..bfd57762df 100644 --- a/packages/typert/generator/tests/fixtures/remote-model/packages/remote/package.json +++ b/packages/typert/generator/tests/fixtures/remote-model/packages/remote/package.json @@ -18,7 +18,6 @@ "lib/typert.host.js", "lib/typert.host.d.ts", "lib/typert.remote-client.js", - "lib/typert.remote-client.d.ts", - "lib/typert.remote-client.d.ts.map" + "lib/typert.remote-client.d.ts" ] } diff --git a/scripts/check-workspace-constraints.ts b/scripts/check-workspace-constraints.ts index 0036dc2929..f22dac25c0 100644 --- a/scripts/check-workspace-constraints.ts +++ b/scripts/check-workspace-constraints.ts @@ -53,7 +53,9 @@ const releaseMemberDirectory = /^(?:packages\/[^/]+\/[^/]+|apps\/[^/]+|vendor\/[ const localArtifactDirs = new Set(['node_modules']) const appPackageFiles: Readonly> = { '@deepseek-ai/dsh': ['lib/*.js', 'config'], - '@deepseek-ai/dsh-frontend': ['dist'], + // The Web build emits sourcemaps for browser debugging; publishing them is + // what the payload policy forbids, so the bundle ships without them. + '@deepseek-ai/dsh-frontend': ['dist', '!dist/**/*.map'], } /** The subset of package.json fields this constraint check cares about. */ @@ -152,7 +154,6 @@ function sameStringList(actual: readonly string[] | undefined, expected: readonl function expectedDshPackageFiles(manifest: PackageManifest): readonly string[] { const extras = manifest.name ? packageFileExtras[manifest.name] ?? [] : [] - const typeRTRemoteNavigation = hasTypeRTRemoteNavigation(manifest) return [ 'lib/index.js', // Every package publishes its invariant ownership companion as a separate @@ -185,13 +186,8 @@ function expectedDshPackageFiles(manifest: PackageManifest): readonly string[] { ...hasExportPair(manifest, './client/typert', './lib/typert.client.d.ts', './lib/typert.client.js') ? ['lib/typert.client.js', 'lib/typert.client.d.ts'] : [], - ...typeRTRemoteNavigation - ? [ - 'lib/typert.remote-client.js', - 'lib/typert.remote-client.d.ts', - 'lib/typert.remote-client.d.ts.map', - 'src', - ] + ...hasTypeRTRemoteNavigation(manifest) + ? ['lib/typert.remote-client.js', 'lib/typert.remote-client.d.ts'] : [], ] } @@ -270,9 +266,8 @@ function checkWorkspace({ dir, manifest }: WorkspaceManifest): string[] { if (manifest.name?.startsWith('@deepseek-ai/')) { const allowedSources = publicationSourceAllowlist[manifest.name] ?? [] - const publicationPolicy = { typeRTRemoteNavigation: hasTypeRTRemoteNavigation(manifest) } for (const file of manifest.files ?? []) { - if (isForbiddenPublicationFile(file, publicationPolicy) && !allowedSources.includes(file)) { + if (isForbiddenPublicationFile(file) && !allowedSources.includes(file)) { errors.push(`${label}: package.json files must not publish ${JSON.stringify(file)}`) } } diff --git a/scripts/publication-payload.spec.ts b/scripts/publication-payload.spec.ts index 03603ef54d..11db34ed55 100644 --- a/scripts/publication-payload.spec.ts +++ b/scripts/publication-payload.spec.ts @@ -29,6 +29,9 @@ describe('publication payload policy', () => { String.raw`src\index.ts`, 'lib/types/index.d.ts.map', './lib/types/index.d.ts.map', + 'lib/typert.remote-client.d.ts.map', + 'lib/client.js.map', + './lib/client.js.map', ])('rejects static manifest path %s', (file) => { expect(isForbiddenPublicationFile(file)).toBe(true) }) @@ -40,11 +43,19 @@ describe('publication payload policy', () => { ])).toThrow('fixture.tgz publishes source file package/src/index.ts') }) - it('rejects declaration maps in packed tarballs', () => { + it('rejects source maps in packed tarballs', () => { expect(validateFixtureTarball([ 'package/package.json', 'package/lib/types/index.d.ts.map', - ])).toThrow('fixture.tgz publishes declaration map package/lib/types/index.d.ts.map') + ])).toThrow('fixture.tgz publishes source map package/lib/types/index.d.ts.map') + expect(validateFixtureTarball([ + 'package/package.json', + 'package/lib/typert.remote-client.d.ts.map', + ])).toThrow('fixture.tgz publishes source map package/lib/typert.remote-client.d.ts.map') + expect(validateFixtureTarball([ + 'package/package.json', + 'package/lib/client.js.map', + ])).toThrow('fixture.tgz publishes source map package/lib/client.js.map') }) it('accepts a clean packed tarball', () => { @@ -56,19 +67,6 @@ describe('publication payload policy', () => { ])).not.toThrow() }) - it('allows only the TypeRT declaration map and its navigable source tree when requested', () => { - const policy = { typeRTRemoteNavigation: true } - expect(isForbiddenPublicationFile('src/index.ts', policy)).toBe(false) - expect(isForbiddenPublicationFile('lib/typert.remote-client.d.ts.map', policy)).toBe(false) - expect(isForbiddenPublicationFile('lib/types/index.d.ts.map', policy)).toBe(true) - expect(() => { - validateTarballPayload([ - 'package/lib/typert.remote-client.d.ts.map', - 'package/src/index.ts', - ], 'fixture.tgz', policy) - }).not.toThrow() - }) - it('recognizes only the canonical Host-for-Client export pair', () => { expect(hasTypeRTRemoteNavigation({ exports: { diff --git a/scripts/publication-payload.ts b/scripts/publication-payload.ts index 60f37b4f94..a6b4f6bebf 100644 --- a/scripts/publication-payload.ts +++ b/scripts/publication-payload.ts @@ -1,11 +1,10 @@ /** Publication payload policy shared by static manifests and packed tarballs. */ -/** Publication exceptions required for TypeRT declaration-map navigation. */ -export interface PublicationPayloadPolicy { - readonly typeRTRemoteNavigation?: boolean -} - -/** Whether a package manifest exports generated Host-for-Client metadata with source navigation. */ +/** + * Whether a package manifest exports generated Host-for-Client metadata. + * @param manifest - parsed package manifest to inspect. + * @returns whether the canonical `./remote` export pair is present. + */ export function hasTypeRTRemoteNavigation(manifest: unknown): boolean { if (manifest === null || typeof manifest !== 'object' || Array.isArray(manifest)) return false const exportsField = (manifest as Record).exports @@ -23,35 +22,34 @@ function payloadPath(file: string): string { return normalized.startsWith('package/') ? normalized.slice('package/'.length) : normalized } -/** Whether a package payload path exposes source or declaration-map intermediates. */ -export function isForbiddenPublicationFile( - file: string, - policy: PublicationPayloadPolicy = {}, -): boolean { +/** + * Whether a package payload path exposes source or map intermediates. Maps + * serve editor navigation during development, where a workspace consumer + * resolves their source through the package link; a published map resolves + * nothing, so no payload publishes one. + * @param file - manifest path or tarball member to classify. + * @returns whether publishing this path is forbidden. + */ +export function isForbiddenPublicationFile(file: string): boolean { const normalized = payloadPath(file) - if (policy.typeRTRemoteNavigation === true - && (normalized === 'src' - || normalized.startsWith('src/') - || normalized === 'lib/typert.remote-client.d.ts.map')) { - return false - } return normalized === 'src' || normalized.startsWith('src/') || normalized.endsWith('.d.ts.map') + || normalized.endsWith('.js.map') } -/** Reject source and declaration-map members in a packed npm tarball. */ -export function validateTarballPayload( - files: readonly string[], - context: string, - policy: PublicationPayloadPolicy = {}, -): void { +/** + * Reject source and map members in a packed npm tarball. + * @param files - tarball members to validate. + * @param context - tarball identity named in the failure. + */ +export function validateTarballPayload(files: readonly string[], context: string): void { for (const file of files) { - if (!isForbiddenPublicationFile(file, policy)) continue + if (!isForbiddenPublicationFile(file)) continue const normalized = payloadPath(file) if (normalized === 'src' || normalized.startsWith('src/')) { throw new Error(`${context} publishes source file ${file}`) } - throw new Error(`${context} publishes declaration map ${file}`) + throw new Error(`${context} publishes source map ${file}`) } } diff --git a/scripts/publish-npm-baseline.ts b/scripts/publish-npm-baseline.ts index 320f11997f..d69923910f 100644 --- a/scripts/publish-npm-baseline.ts +++ b/scripts/publish-npm-baseline.ts @@ -18,7 +18,7 @@ import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep import { createInterface } from 'node:readline/promises' import { pathToFileURL } from 'node:url' import { parseArgs } from 'node:util' -import { hasTypeRTRemoteNavigation, validateTarballPayload } from './publication-payload.ts' +import { validateTarballPayload } from './publication-payload.ts' const DEFAULT_REGISTRY = 'https://registry.npm.harnessment.com' const DEFAULT_OUTPUT_DIRECTORY = '.artifacts/npm-baseline' @@ -323,9 +323,7 @@ class ReleaseBundle { throw new Error(`unexpected or duplicate packed package: ${artifact.name}`) } if (expected.origin === 'harness') { - validateTarballPayload(artifact.files, tarball, { - typeRTRemoteNavigation: hasTypeRTRemoteNavigation(artifact.manifest), - }) + validateTarballPayload(artifact.files, tarball) } if (artifact.version !== version) { throw new Error(`${tarball} has version ${artifact.version}; expected ${version}`) @@ -401,9 +399,7 @@ class ReleaseBundle { } const artifact = inspectTarball(path, runner) if (pkg.origin === 'harness') { - validateTarballPayload(artifact.files, pkg.tarball, { - typeRTRemoteNavigation: hasTypeRTRemoteNavigation(artifact.manifest), - }) + validateTarballPayload(artifact.files, pkg.tarball) } if (artifact.name !== pkg.name || artifact.version !== this.manifest.version) { throw new Error(`tarball identity mismatch: ${pkg.tarball}`) diff --git a/scripts/release/families.ts b/scripts/release/families.ts index e4c5fda5be..d39552636d 100644 --- a/scripts/release/families.ts +++ b/scripts/release/families.ts @@ -11,7 +11,7 @@ import { globSync, readFileSync } from 'node:fs' import { resolve } from 'node:path' -import { hasTypeRTRemoteNavigation, validateTarballPayload } from '../publication-payload.ts' +import { validateTarballPayload } from '../publication-payload.ts' /** Dependency sections that constrain publish order: a consumer must publish after its dependency. */ const ORDER_SECTIONS = ['dependencies', 'optionalDependencies'] as const @@ -225,9 +225,7 @@ class DshFamily extends ReleaseFamily { * @param files - every path inside its tarball. */ validatePayload(member: ReleaseMember, files: readonly string[]): void { - validateTarballPayload(files, member.name, { - typeRTRemoteNavigation: hasTypeRTRemoteNavigation(member.manifest), - }) + validateTarballPayload(files, member.name) } readonly installedEntry = { packageName: '@deepseek-ai/dsh', binPath: 'lib/bin.js' }