Skip to content

Commit

Permalink
Merge pull request #30 from catdad-experiments/libheif-1.18.2
Browse files Browse the repository at this point in the history
updating to libheif 1.18.2, compiling `fs` out of wasm bundles
  • Loading branch information
catdad authored Oct 13, 2024
2 parents e86e853 + 66bf5df commit 841cf2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libheif-js",
"version": "1.18.0",
"version": "1.18.2",
"description": "Emscripten distribution of libheif for Node.JS and the browser",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,6 +32,7 @@
"babel-eslint": "^10.1.0",
"chai": "^4.2.0",
"esbuild": "^0.19.5",
"esbuild-plugins-node-modules-polyfill": "^1.6.7",
"eslint": "^5.16.0",
"fs-extra": "^8.1.0",
"gunzip-maybe": "^1.4.2",
Expand Down
20 changes: 16 additions & 4 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const tar = require('tar-stream');
const gunzip = require('gunzip-maybe');

const esbuild = require('esbuild');
const { nodeModulesPolyfillPlugin } = require('esbuild-plugins-node-modules-polyfill');

const version = 'v1.18.0';
const version = 'v1.18.2';

const base = `https://github.com/catdad-experiments/libheif-emscripten/releases/download/${version}`;
const tarball = `${base}/libheif.tar.gz`;
Expand Down Expand Up @@ -79,6 +80,15 @@ const autoReadStream = async stream => {
platform: 'neutral'
};

const plugins = () => [
nodeModulesPolyfillPlugin({
modules: {
fs: 'empty',
path: 'empty'
}
})
];

await esbuild.build({
...buildOptions,
outfile: path.resolve(root, 'libheif-wasm/libheif-bundle.js'),
Expand All @@ -92,7 +102,8 @@ libheif = libheif.default;
if (typeof exports === 'object' && typeof module === 'object') {
module.exports = libheif;
}`
}
},
plugins: plugins(),
});

await esbuild.build({
Expand All @@ -102,8 +113,9 @@ if (typeof exports === 'object' && typeof module === 'object') {
banner: {
// hack to avoid the ENVIRONMENT_IS_NODE detection
// the binary is built in, so the environment doesn't matter
js: 'var process;'
}
js: 'var process, __dirname;'
},
plugins: plugins(),
});
})().then(() => {
console.log(`fetched libheif ${version}`);
Expand Down
2 changes: 1 addition & 1 deletion test/libheif.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function runTests(libheif) {
it('is the correct version', () => {
expect(libheif).to.have.property('heif_get_version')
.and.to.be.a('function');
expect(libheif.heif_get_version()).to.equal('1.18.0')
expect(libheif.heif_get_version()).to.equal('1.18.2')
.and.to.equal(pkg.version);
});

Expand Down

0 comments on commit 841cf2a

Please sign in to comment.