Closed renanwilliam closed 2 years ago
I'm having exactly the same error
Have used @tybys/cross-zip while this issue is open:
const zip = require('@tybys/cross-zip');
const path = require('path');
require('esbuild').build({
entryPoints: ['./src/index.ts'],
bundle: true,
platform: 'node',
outfile: './build/index.js',
plugins: [
compress({
outputDir: 'dist',
}),
],
}).then(result => {
if (result.errors.length === 0) {
const inPath = path.join(__dirname, 'build/');
const outPath = path.join(__dirname, 'dist', 'artifact.zip');
zip.zipSync(inPath, outPath, false);
}
}).catch(() => process.exit(1));
It looks like the ESBuild update caused the breaking change, need fix.
ESBuild doesnot expose outputFile
info when using write: true
options. so you need to set this explictly, and this was incorrectly tiped in plugin.
You can use just like this:
import { compress } from './plugin';
import { build } from 'esbuild';
import type { BuildOptions } from 'esbuild';
const baseOptions: BuildOptions = {
entryPoints: ['./src/index.ts'],
bundle: true,
platform: 'node',
outfile: './build/index.js',
};
const compressOptions: BuildOptions = {
...baseOptions,
write: false,
plugins: [
...(baseOptions.plugins ?? []),
compress({
outputDir: 'dist',
}),
],
};
build(baseOptions).catch(() => process.exit(1));
build(compressOptions).catch(() => process.exit(1));
ok, I've seen the updated docs. thanks
Just trying the compress plugin and always receiving the same message:
Using: