feat(npm): split platform binaries into optionalDependencies (1.11.0) (#154)
* feat(npm): split platform binaries into optionalDependencies (1.11.0)
The single package bundled all three .node binaries (17.6 MB unpacked)
so every install downloaded every platform. Publish one package per
platform (@firecrawl/pdf-inspector-{linux-x64-gnu,darwin-arm64,
win32-x64-msvc}) holding just its binary; the napi-generated loader
already falls back to exactly these names. Main package drops *.node
from files (8.5 kB tarball) and pins the platform packages as
optionalDependencies, re-stamped to the exact version at publish time.
Publish workflow gains a workflow_dispatch fallback and per-package
already-published checks so partial releases can be retried.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs(npm): document Windows support and platform packages; drop stale napi.package.name
Review follow-ups: the README claimed only linux-x64 and macOS ARM64
despite the win32-x64-msvc binary shipping, and napi.package.name
(@firecrawl/pdf-inspector-js) contradicts the real platform package
prefix — the loader and workflow derive it from the root package name.
Verified the generated loader is unchanged without the config.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
cffe253d1d
commit
c80bedf4bd
@@ -4,6 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths: ['napi/package.json']
|
paths: ['napi/package.json']
|
||||||
|
# Manual fallback: retry a publish that failed partway (per-package
|
||||||
|
# already-published checks make re-runs idempotent).
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -12,6 +15,10 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
check-version:
|
check-version:
|
||||||
name: Check version change
|
name: Check version change
|
||||||
|
# Guard manual dispatches: npm trusted publishing matches
|
||||||
|
# repo+workflow+environment but NOT branch, so without this a
|
||||||
|
# workflow_dispatch from any branch could publish unmerged code.
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
changed: ${{ steps.check.outputs.changed }}
|
changed: ${{ steps.check.outputs.changed }}
|
||||||
@@ -25,11 +32,21 @@ jobs:
|
|||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
NEW_VERSION=$(node -p "require('./napi/package.json').version")
|
NEW_VERSION=$(node -p "require('./napi/package.json').version")
|
||||||
|
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
# Manual dispatch rebuilds and publishes the current version; the
|
||||||
|
# per-package already-published checks in the publish job skip
|
||||||
|
# anything that made it out in a previous partial run.
|
||||||
|
echo "manual dispatch: publishing v$NEW_VERSION"
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
OLD_VERSION=$(git show HEAD~1:napi/package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version")
|
OLD_VERSION=$(git show HEAD~1:napi/package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version")
|
||||||
echo "old=$OLD_VERSION new=$NEW_VERSION"
|
echo "old=$OLD_VERSION new=$NEW_VERSION"
|
||||||
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
|
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
|
||||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
else
|
||||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
@@ -115,14 +132,81 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: napi/artifacts
|
path: napi/artifacts
|
||||||
|
|
||||||
- name: Collect binaries and publish
|
- name: Publish platform packages
|
||||||
working-directory: napi
|
working-directory: napi
|
||||||
run: |
|
run: |
|
||||||
cp artifacts/bindings-*/*.node .
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
|
|
||||||
|
for node_file in artifacts/bindings-*/pdf-inspector.*.node; do
|
||||||
|
base=$(basename "$node_file")
|
||||||
|
suffix=${base#pdf-inspector.}
|
||||||
|
suffix=${suffix%.node}
|
||||||
|
pkg="@firecrawl/pdf-inspector-$suffix"
|
||||||
|
|
||||||
|
if npm view "$pkg@$VERSION" version >/dev/null 2>&1; then
|
||||||
|
echo "$pkg@$VERSION already published — skipping"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir="npm-dist/$suffix"
|
||||||
|
mkdir -p "$dir"
|
||||||
|
cp "$node_file" "$dir/"
|
||||||
|
node -e '
|
||||||
|
const [suffix, version] = process.argv.slice(1)
|
||||||
|
const meta = {
|
||||||
|
"linux-x64-gnu": { os: ["linux"], cpu: ["x64"], libc: ["glibc"] },
|
||||||
|
"darwin-arm64": { os: ["darwin"], cpu: ["arm64"] },
|
||||||
|
"win32-x64-msvc": { os: ["win32"], cpu: ["x64"] },
|
||||||
|
}[suffix]
|
||||||
|
if (!meta) {
|
||||||
|
console.error(`unknown platform suffix: ${suffix} — add it to the meta map`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
const pkg = {
|
||||||
|
name: `@firecrawl/pdf-inspector-${suffix}`,
|
||||||
|
version,
|
||||||
|
description: `Prebuilt ${suffix} binary for @firecrawl/pdf-inspector`,
|
||||||
|
main: `pdf-inspector.${suffix}.node`,
|
||||||
|
files: [`pdf-inspector.${suffix}.node`],
|
||||||
|
license: "MIT",
|
||||||
|
engines: { node: ">= 10" },
|
||||||
|
repository: { type: "git", url: "https://github.com/firecrawl/pdf-inspector" },
|
||||||
|
publishConfig: { access: "public" },
|
||||||
|
...meta,
|
||||||
|
}
|
||||||
|
require("fs").writeFileSync(`npm-dist/${suffix}/package.json`, JSON.stringify(pkg, null, 2) + "\n")
|
||||||
|
' "$suffix" "$VERSION"
|
||||||
|
|
||||||
|
echo "=== $pkg@$VERSION ==="
|
||||||
|
ls -la "$dir"
|
||||||
|
(cd "$dir" && npm publish --provenance --access public)
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Publish main package
|
||||||
|
working-directory: napi
|
||||||
|
run: |
|
||||||
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
|
|
||||||
|
if npm view "@firecrawl/pdf-inspector@$VERSION" version >/dev/null 2>&1; then
|
||||||
|
echo "@firecrawl/pdf-inspector@$VERSION already published — skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
cp artifacts/js-bindings/index.js .
|
cp artifacts/js-bindings/index.js .
|
||||||
cp artifacts/js-bindings/index.d.ts .
|
cp artifacts/js-bindings/index.d.ts .
|
||||||
|
|
||||||
echo "=== Package contents ==="
|
# Stamp optionalDependencies to this exact version so the platform
|
||||||
ls -la *.node index.js index.d.ts
|
# pins can never drift from the main package version.
|
||||||
|
node -e '
|
||||||
|
const fs = require("fs")
|
||||||
|
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"))
|
||||||
|
for (const dep of Object.keys(pkg.optionalDependencies ?? {})) {
|
||||||
|
pkg.optionalDependencies[dep] = pkg.version
|
||||||
|
}
|
||||||
|
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n")
|
||||||
|
'
|
||||||
|
|
||||||
|
echo "=== Main package contents ==="
|
||||||
|
npm pack --dry-run
|
||||||
|
|
||||||
npm publish --provenance --access public
|
npm publish --provenance --access public
|
||||||
|
|||||||
Generated
+1
-1
@@ -830,7 +830,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdf-inspector"
|
name = "pdf-inspector"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
+8
-5
@@ -12,7 +12,7 @@ npm install @firecrawl/pdf-inspector
|
|||||||
bun add @firecrawl/pdf-inspector
|
bun add @firecrawl/pdf-inspector
|
||||||
```
|
```
|
||||||
|
|
||||||
Prebuilt binaries included for **linux-x64** and **macOS ARM64**. No Rust toolchain needed.
|
Prebuilt binaries for **Linux x64**, **macOS ARM64**, and **Windows x64** — npm installs only the one matching your platform. No Rust toolchain needed.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
@@ -90,10 +90,13 @@ interface RegionText {
|
|||||||
|
|
||||||
## Platforms
|
## Platforms
|
||||||
|
|
||||||
| Platform | Architecture | Supported |
|
Prebuilt binaries ship as platform-specific packages installed automatically via `optionalDependencies`:
|
||||||
|----------|-------------|-----------|
|
|
||||||
| Linux | x64 | Yes |
|
| Platform | Architecture | Package |
|
||||||
| macOS | ARM64 | Yes |
|
|----------|-------------|---------|
|
||||||
|
| Linux | x64 (glibc) | `@firecrawl/pdf-inspector-linux-x64-gnu` |
|
||||||
|
| macOS | ARM64 | `@firecrawl/pdf-inspector-darwin-arm64` |
|
||||||
|
| Windows | x64 | `@firecrawl/pdf-inspector-win32-x64-msvc` |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@napi-rs/cli": "^3.4.1",
|
"@napi-rs/cli": "^3.4.1",
|
||||||
},
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@firecrawl/pdf-inspector-darwin-arm64": "1.11.0",
|
||||||
|
"@firecrawl/pdf-inspector-linux-x64-gnu": "1.11.0",
|
||||||
|
"@firecrawl/pdf-inspector-win32-x64-msvc": "1.11.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
+7
-6
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@firecrawl/pdf-inspector",
|
"name": "@firecrawl/pdf-inspector",
|
||||||
"version": "1.10.4",
|
"version": "1.11.0",
|
||||||
"description": "Fast PDF classification and text extraction. Detect text-based vs scanned PDFs, extract text by region with quality checks. Native Rust performance via napi-rs.",
|
"description": "Fast PDF classification and text extraction. Detect text-based vs scanned PDFs, extract text by region with quality checks. Native Rust performance via napi-rs.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
"index.d.ts",
|
"index.d.ts",
|
||||||
"*.node",
|
|
||||||
"bin/",
|
"bin/",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
@@ -40,10 +39,7 @@
|
|||||||
"x86_64-unknown-linux-gnu",
|
"x86_64-unknown-linux-gnu",
|
||||||
"aarch64-apple-darwin",
|
"aarch64-apple-darwin",
|
||||||
"x86_64-pc-windows-msvc"
|
"x86_64-pc-windows-msvc"
|
||||||
],
|
]
|
||||||
"package": {
|
|
||||||
"name": "@firecrawl/pdf-inspector-js"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "napi build --platform --release",
|
"build": "napi build --platform --release",
|
||||||
@@ -51,5 +47,10 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@napi-rs/cli": "^3.4.1"
|
"@napi-rs/cli": "^3.4.1"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@firecrawl/pdf-inspector-linux-x64-gnu": "1.11.0",
|
||||||
|
"@firecrawl/pdf-inspector-darwin-arm64": "1.11.0",
|
||||||
|
"@firecrawl/pdf-inspector-win32-x64-msvc": "1.11.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user