Skip to content

Commit

Permalink
Compile pixel-match file correctly (#5199)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann authored Jan 3, 2024
1 parent d4f790f commit e4f1c42
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions scripts/esbuild/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { BuildOptions } from '../utils/options';
import { writePkgJson } from '../utils/write-pkg-json';
import { getBaseEsbuildOptions, getEsbuildAliases, getEsbuildExternalModules, runBuilds } from './util';

const screenshotBuilds = {
'Stencil Screenshot': 'index',
'Stencil Screenshot Pixel Match': 'pixel-match',
};

export async function buildScreenshot(opts: BuildOptions) {
const inputScreenshotDir = join(opts.buildDir, 'screenshot');
const inputScreenshotSrcDir = join(opts.srcDir, 'screenshot');
Expand Down Expand Up @@ -45,23 +50,18 @@ export async function buildScreenshot(opts: BuildOptions) {
platform: 'node',
} satisfies ESBuildOptions;

const screenshotEsbuildOptions = {
...baseScreenshotOptions,
banner: {
js: getBanner(opts, 'Stencil Screenshot'),
},
entryPoints: [join(inputScreenshotSrcDir, 'index.ts')],
outfile: join(opts.output.screenshotDir, 'index.js'),
} satisfies ESBuildOptions;

const pixelmatchEsbuildOptions = {
...baseScreenshotOptions,
banner: {
js: getBanner(opts, 'Stencil Screenshot Pixel Match'),
},
entryPoints: [join(inputScreenshotSrcDir, 'index.ts')],
outfile: join(opts.output.screenshotDir, 'pixel-match.js'),
} satisfies ESBuildOptions;

return runBuilds([screenshotEsbuildOptions, pixelmatchEsbuildOptions], opts);
return runBuilds(
Object.entries(screenshotBuilds).map(
([label, file]) =>
({
...baseScreenshotOptions,
banner: {
js: getBanner(opts, label),
},
entryPoints: [join(inputScreenshotSrcDir, `${file}.ts`)],
outfile: join(opts.output.screenshotDir, `${file}.js`),
}) satisfies ESBuildOptions,
),
opts,
);
}

0 comments on commit e4f1c42

Please sign in to comment.