Skip to content

Commit 7a0e72e

Browse files
authored
fix(remix): Sourcemaps upload script is missing in the tarball (#5356)
Add the sourcemaps upload script to the tarball, which required the following changes: * Add a package-specific `prepack.ts` script which is invoked by the main `prepack.ts` script. This is similar to how we do it with the Gatsby SDK where - just as with Remix - we need to copy over additional files to the `build` directory that are not part of our other packages. The newly added files are: * `scripts/sentry-upload-sourcemaps.js` * `scripts/createRelease.js` * Add a package-specific `.npmignore` which extends the root level `.npmignore` file to not ignore the `scripts` directory in the `build` directory.
1 parent 956ea56 commit 7a0e72e

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

packages/remix/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ module.exports = {
1010
rules: {
1111
'@sentry-internal/sdk/no-async-await': 'off',
1212
},
13+
overrides: [
14+
{
15+
files: ['scripts/**/*.ts'],
16+
parserOptions: {
17+
project: ['../../tsconfig.dev.json'],
18+
},
19+
},
20+
],
1321
};

packages/remix/.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
!/scripts/**/*

packages/remix/scripts/prepack.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable no-console */
2+
3+
import * as fs from 'fs';
4+
import * as path from 'path';
5+
6+
const PACKAGE_ASSETS = ['scripts/sentry-upload-sourcemaps.js', 'scripts/createRelease.js'];
7+
8+
export function prepack(buildDir: string): boolean {
9+
// copy package-specific assets to build dir
10+
return PACKAGE_ASSETS.every(asset => {
11+
const assetPath = path.resolve(asset);
12+
const destinationPath = path.resolve(buildDir, asset);
13+
try {
14+
if (!fs.existsSync(assetPath)) {
15+
console.error(`\nERROR: Asset '${asset}' does not exist.`);
16+
return false;
17+
}
18+
const scriptsDir = path.resolve(buildDir, 'scripts');
19+
if (!fs.existsSync(scriptsDir)) {
20+
console.log('Creating missing directory', scriptsDir);
21+
fs.mkdirSync(scriptsDir);
22+
}
23+
console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`);
24+
fs.copyFileSync(assetPath, destinationPath);
25+
} catch (error) {
26+
console.error(
27+
`\nERROR: Error while copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}:\n`,
28+
error,
29+
);
30+
return false;
31+
}
32+
return true;
33+
});
34+
}

0 commit comments

Comments
 (0)