build: fix windows build (#11975)

This commit is contained in:
Alex Rudenko 2024-02-22 15:30:58 +01:00 committed by GitHub
parent 5e942b3b2f
commit 3448a4097b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,8 @@
*/ */
import {mkdir, readFile, readdir, writeFile} from 'fs/promises'; import {mkdir, readFile, readdir, writeFile} from 'fs/promises';
import Module from 'node:module'; import Module from 'node:module';
import {join, dirname} from 'path/posix'; import path from 'path';
import posixPath from 'path/posix';
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import {execa} from 'execa'; import {execa} from 'execa';
@ -99,13 +100,13 @@ export const buildTask = task({
}); });
const builders = []; const builders = [];
for (const format of formats) { for (const format of formats) {
const folder = join('lib', format, 'third_party'); const folder = posixPath.join('lib', format, 'third_party');
for (const name of packages) { for (const name of packages) {
const path = join(folder, name, `${name}.js`); const entrypoint = posixPath.join(folder, name, `${name}.js`);
builders.push( builders.push(
await esbuild.build({ await esbuild.build({
entryPoints: [path], entryPoints: [entrypoint],
outfile: path, outfile: entrypoint,
bundle: true, bundle: true,
allowOverwrite: true, allowOverwrite: true,
format, format,
@ -118,22 +119,27 @@ export const buildTask = task({
switch (name) { switch (name) {
case 'rxjs': case 'rxjs':
license = await readFile( license = await readFile(
`${dirname(require.resolve('rxjs'))}/../../LICENSE.txt`, path.join(
path.dirname(require.resolve('rxjs')),
'..',
'..',
'LICENSE.txt'
),
'utf-8' 'utf-8'
); );
break; break;
case 'mitt': case 'mitt':
license = await readFile( license = await readFile(
`${dirname(require.resolve('mitt'))}/../LICENSE`, path.join(path.dirname(require.resolve('mitt')), '..', 'LICENSE'),
'utf-8' 'utf-8'
); );
break; break;
default: default:
throw new Error(`Add license handling for ${path}`); throw new Error(`Add license handling for ${path}`);
} }
const content = await readFile(path, 'utf-8'); const content = await readFile(entrypoint, 'utf-8');
await writeFile( await writeFile(
path, entrypoint,
`/** `/**
${license} ${license}
*/ */