forked from GetStream/stream-chat-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-esm.mjs
More file actions
executable file
·35 lines (28 loc) · 966 Bytes
/
bundle-esm.mjs
File metadata and controls
executable file
·35 lines (28 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
import { exec } from 'node:child_process';
import { readFile, writeFile } from 'node:fs/promises';
import glob from 'glob';
import { promisify } from 'node:util';
import getPackageVersion from './get-package-version.mjs';
const execAsync = promisify(exec);
const version = getPackageVersion();
const bundleEsm = async () => {
// Run TypeScript compiler
console.log('Running TypeScript compiler...');
await execAsync('tsc');
// Replace version string in generated files
console.log('Replacing version strings...');
const files = glob.glob.sync('dist/**/*.js');
await Promise.all(
files.map(async (file) => {
const content = await readFile(file, 'utf8');
const newContent = content.replace(
/process.env.STREAM_CHAT_REACT_VERSION/g,
JSON.stringify(version),
);
await writeFile(file, newContent);
}),
);
console.log('ESM build complete');
};
bundleEsm().catch(console.error);