Skip to content

Commit 61cb9ed

Browse files
committed
add prepack script
1 parent 35baadb commit 61cb9ed

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/utils/scripts/prepack.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable no-console */
2+
3+
// DO NOT RUN this script yourself!
4+
// This is invoked from the main `prepack.ts` script in `sentry-javascript/scripts/prepack.ts`.
5+
6+
import * as fs from 'fs';
7+
import * as fse from 'fs-extra';
8+
import * as path from 'path';
9+
10+
export function prepack(buildDir: string): boolean {
11+
// copy package-specific assets to build dir
12+
const assetPath = path.resolve('jsPolyfills');
13+
try {
14+
if (!fs.existsSync(assetPath)) {
15+
console.error(
16+
"\nERROR: Missing 'packages/utils/jsPolyfills' directory. Please run `yarn build` in the `utils` package before running this script again.",
17+
);
18+
return false;
19+
}
20+
console.log(`Copying 'jsPolyfills' to ${path.resolve(buildDir, 'jsPolyfills')}.`);
21+
fse.copySync(assetPath, path.resolve(buildDir, 'jsPolyfills'));
22+
} catch (error) {
23+
console.error(`\nERROR: Error while copying 'jsPolyfills' to ${buildDir}:\n${error}`);
24+
return false;
25+
}
26+
return true;
27+
}

scripts/prepack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ try {
7373
async function runPackagePrepack(packagePrepackPath: string): Promise<void> {
7474
const { prepack } = await import(packagePrepackPath);
7575
if (prepack && typeof prepack === 'function') {
76-
const isSuccess = prepack(buildDir);
76+
const isSuccess = await prepack(buildDir);
7777
if (!isSuccess) {
7878
process.exit(1);
7979
}

0 commit comments

Comments
 (0)