From 84be2b257c6d2c323d381d7b23149a4ea6a80a92 Mon Sep 17 00:00:00 2001 From: Sven Rogge Date: Wed, 4 Nov 2026 15:16:59 +0100 Subject: [PATCH] fix: include core runtime dependencies in published package --- .github/workflows/test-build.yaml | 2 ++ bun.lock | 6 ++--- packages/core/CHANGELOG.md | 6 +++++ packages/core/package.json | 8 +++---- scripts/package-smoke.sh | 19 +++++++++++++++ scripts/package-smoke.ts | 40 +++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 scripts/package-smoke.sh create mode 100644 scripts/package-smoke.ts diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index c6233c0..ec98555 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -15,6 +15,8 @@ jobs: - run: bun run build - run: bun run typecheck - run: bun run test + - name: Smoke test packed production dependencies + run: bash scripts/package-smoke.sh container-smoke: name: Test production container runs-on: ubuntu-latest diff --git a/bun.lock b/bun.lock index 9bf8906..624f281 100644 --- a/bun.lock +++ b/bun.lock @@ -35,14 +35,14 @@ }, "packages/core": { "name": "m4k", - "version": "0.3.6", + "version": "0.3.7", "dependencies": { + "@ffmpeg-installer/ffmpeg": "^1.1.0", "@huggingface/transformers": "3.8.1", "@m4k/common": "workspace:^", + "tasque": "^0.1.2", }, "devDependencies": { - "@ffmpeg-installer/ffmpeg": "^1.1.0", - "tasque": "^0.1.2", "typescript": "^7.0.2", }, "peerDependencies": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 9e995d7..f3764e5 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to `m4k` are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.7] + +### Fixed + +- Declared `tasque` and `@ffmpeg-installer/ffmpeg` as runtime dependencies so production-only consumers can import and use the published package without workspace development dependencies. + ## [0.3.6] ### Added diff --git a/packages/core/package.json b/packages/core/package.json index f6e9a43..77c438a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "m4k", - "version": "0.3.6", + "version": "0.3.7", "description": "Media toolkit for node, bun, and deno", "keywords": [ "audio", @@ -33,12 +33,12 @@ "test": "bun test" }, "dependencies": { + "@ffmpeg-installer/ffmpeg": "^1.1.0", "@huggingface/transformers": "3.8.1", - "@m4k/common": "workspace:^" + "@m4k/common": "workspace:^", + "tasque": "^0.1.2" }, "devDependencies": { - "@ffmpeg-installer/ffmpeg": "^1.1.0", - "tasque": "^0.1.2", "typescript": "^7.0.2" }, "peerDependencies": { diff --git a/scripts/package-smoke.sh b/scripts/package-smoke.sh new file mode 100644 index 0000000..1d918d5 --- /dev/null +++ b/scripts/package-smoke.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +root=$(cd "$(dirname "$0")/.." && pwd) +scratch=$(mktemp -d) +trap 'rm -rf "$scratch"' EXIT +mkdir -p "$scratch/packs" "$scratch/consumer" "$scratch/work" +for package in common core client; do + (cd "$root/packages/$package" && bun pm pack --destination "$scratch/packs" --quiet) +done +common=("$scratch"/packs/m4k-common-*.tgz) +# Resolve internal dependencies to this pack even when its version is not published yet. +bun -e 'console.log(JSON.stringify({private:true,type:"module",overrides:{"@m4k/common":`file:${Bun.argv[1]}`}}))' "${common[0]}" > "$scratch/consumer/package.json" +# Copy the runner too: executing it from the repository would resolve workspace dependencies. +cp "$root/scripts/package-smoke.ts" "$scratch/consumer/smoke.ts" +( + cd "$scratch/consumer" + bun add --production --ignore-scripts "$scratch"/packs/*.tgz + env -u NODE_PATH -u FFMPEG_PATH M4K_TMP_DIR="$scratch/work" bun run smoke.ts "$root/fixtures" +) diff --git a/scripts/package-smoke.ts b/scripts/package-smoke.ts new file mode 100644 index 0000000..18ea361 --- /dev/null +++ b/scripts/package-smoke.ts @@ -0,0 +1,40 @@ +// Copied into an isolated production-only consumer by package-smoke.sh. +import assert from "node:assert/strict"; +import { ProcessedFile } from "@m4k/common"; +import { classifyImage as classifyRemote } from "@m4k/client"; +import { classifyImage, processAudio, processImage } from "m4k"; + +const fixtures = Bun.argv[2]; +assert(fixtures, "Fixture directory is required"); +assert.equal(process.env.FFMPEG_PATH, undefined); +assert.equal(process.env.NODE_PATH, undefined); +assert.equal(typeof classifyImage, "function"); +assert.equal(typeof classifyRemote, "function"); + +const images = processImage(`${fixtures}/image.jpeg`, { format: "webp" }); +assert(images); +let imageOutputs = 0; +for await (const part of images) { + if (!(part instanceof ProcessedFile)) continue; + assert.equal(part.type, "image/webp"); + assert(part.stream); + let size = 0; + for await (const chunk of part.stream) size += chunk.byteLength; + assert(size > 0); + imageOutputs++; +} +assert.equal(imageOutputs, 1); + +const audio = processAudio(`${fixtures}/audio.mp3`, { format: "ogg", codec: "libvorbis" }); +assert(audio); +let audioOutputs = 0; +for await (const part of audio) { + if (!(part instanceof ProcessedFile)) continue; + assert.equal(part.type, "audio/ogg"); + assert(Bun.file(part.name).size > 0); + audioOutputs++; +} +assert.equal(audioOutputs, 1); +console.log( + "Package smoke passed: isolated production imports, JPEG → WebP and bundled FFmpeg MP3 → Ogg", +);