Skip to content

Commit

Permalink
Adding a types-only package
Browse files Browse the repository at this point in the history
  • Loading branch information
Yahweasel committed Dec 19, 2024
1 parent f8737d4 commit 590545e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ release: extract
mkdir dist/release/libav.js-$(LIBAVJS_VERSION)
cp -a README.md docs dist/release/libav.js-$(LIBAVJS_VERSION)/
mkdir dist/release/libav.js-$(LIBAVJS_VERSION)/dist
$(MAKE) dist/release/libav.js-types-$(LIBAVJS_VERSION)
for v in $(RELEASE_VARIANTS); \
do \
$(MAKE) build-$$v; \
Expand Down Expand Up @@ -959,13 +960,20 @@ dist/release/libav.js-$(LIBAVJS_VERSION)-%: build-%
sed 's/@VARIANT/$(*)/g ; s/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \
package-one-variant.json > $(@)/package.json

dist/release/libav.js-types-$(LIBAVJS_VERSION): dist/libav.types.d.ts
mkdir -p $(@)/dist
cp dist/libav.types.d.ts $(@)/dist
sed 's/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \
package-types-only.json > $(@)/package.json

npm-publish:
cd dist/release && unzip libav.js-$(LIBAVJS_VERSION).zip
cd dist/release/libav.js-$(LIBAVJS_VERSION) && \
cp ../../../package.json . && \
rm -f dist/*.dbg.* dist/*-av1* dist/*-vp9* dist/*.asm.mjs && \
npm publish
rm -rf dist/release/libav.js-$(LIBAVJS_VERSION)
( cd dist/release/libav.js-types-$(LIBAVJS_VERSION) && npm publish --access=public )
for v in $(RELEASE_VARIANTS); \
do \
( cd dist/release/libav.js-$(LIBAVJS_VERSION)-$$v && npm publish --access=public ) \
Expand Down
8 changes: 8 additions & 0 deletions Makefile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ release: extract
mkdir dist/release/libav.js-$(LIBAVJS_VERSION)
cp -a README.md docs dist/release/libav.js-$(LIBAVJS_VERSION)/
mkdir dist/release/libav.js-$(LIBAVJS_VERSION)/dist
$(MAKE) dist/release/libav.js-types-$(LIBAVJS_VERSION)
for v in $(RELEASE_VARIANTS); \
do \
$(MAKE) build-$$v; \
Expand Down Expand Up @@ -219,13 +220,20 @@ dist/release/libav.js-$(LIBAVJS_VERSION)-%: build-%
sed 's/@VARIANT/$(*)/g ; s/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \
package-one-variant.json > $(@)/package.json

dist/release/libav.js-types-$(LIBAVJS_VERSION): dist/libav.types.d.ts
mkdir -p $(@)/dist
cp dist/libav.types.d.ts $(@)/dist
sed 's/@VERSION/$(LIBAVJS_VERSION)/g ; s/@VER/$(LIBAVJS_VERSION_SHORT)/g' \
package-types-only.json > $(@)/package.json

npm-publish:
cd dist/release && unzip libav.js-$(LIBAVJS_VERSION).zip
cd dist/release/libav.js-$(LIBAVJS_VERSION) && \
cp ../../../package.json . && \
rm -f dist/*.dbg.* dist/*-av1* dist/*-vp9* dist/*.asm.mjs && \
npm publish
rm -rf dist/release/libav.js-$(LIBAVJS_VERSION)
( cd dist/release/libav.js-types-$(LIBAVJS_VERSION) && npm publish --access=public )
for v in $(RELEASE_VARIANTS); \
do \
( cd dist/release/libav.js-$(LIBAVJS_VERSION)-$$v && npm publish --access=public ) \
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ released version, it is sufficient to provide the `sources` directory.

libav.js is published to NPM as `libav.js`, and each released variant is
published in a much smaller NPM package as `@libav.js/variant-<variant>`. The
CDN example above uses the `@libav.js/variant-default` package, for example.
CDN example above uses the `@libav.js/variant-default` package, for example. The
`@libav.js/types` package is also provided with only the types (`.d.ts` file),
and if using TypeScript, you are highly recommended to use it, to avoid bringing
entire variants in as dependencies of your own packages.

### Why the version number in the filenames?

Expand Down
2 changes: 1 addition & 1 deletion package-one-variant.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@libav.js/variant-@VARIANT",
"version": "@VER",
"description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web.",
"description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web. This package includes only one variant.",
"main": "dist/[email protected]",
"types": "dist/libav.types.d.ts",
"exports": {
Expand Down
28 changes: 28 additions & 0 deletions package-types-only.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@libav.js/types",
"version": "@VER",
"description": "A compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil and libswresample—for WebAssembly and asm.js, and thus the web. This package includes only the types.",
"types": "dist/libav.types.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/Yahweasel/libav.js.git"
},
"keywords": [
"ffmpeg",
"libav",
"audio",
"video",
"av",
"encode",
"decode",
"transcode",
"mux",
"demux"
],
"author": "Yahweasel",
"license": "LGPL-2.1",
"bugs": {
"url": "https://github.com/Yahweasel/libav.js/issues"
},
"homepage": "https://github.com/Yahweasel/libav.js#readme"
}

0 comments on commit 590545e

Please sign in to comment.