Skip to content

Commit

Permalink
fix(remix): Sourcemaps upload script is missing in the tarball (#5356)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lms24 authored Jul 4, 2022
1 parent 956ea56 commit 7a0e72e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/remix/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ module.exports = {
rules: {
'@sentry-internal/sdk/no-async-await': 'off',
},
overrides: [
{
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['../../tsconfig.dev.json'],
},
},
],
};
4 changes: 4 additions & 0 deletions packages/remix/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

!/scripts/**/*
34 changes: 34 additions & 0 deletions packages/remix/scripts/prepack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-console */

import * as fs from 'fs';
import * as path from 'path';

const PACKAGE_ASSETS = ['scripts/sentry-upload-sourcemaps.js', 'scripts/createRelease.js'];

export function prepack(buildDir: string): boolean {
// copy package-specific assets to build dir
return PACKAGE_ASSETS.every(asset => {
const assetPath = path.resolve(asset);
const destinationPath = path.resolve(buildDir, asset);
try {
if (!fs.existsSync(assetPath)) {
console.error(`\nERROR: Asset '${asset}' does not exist.`);
return false;
}
const scriptsDir = path.resolve(buildDir, 'scripts');
if (!fs.existsSync(scriptsDir)) {
console.log('Creating missing directory', scriptsDir);
fs.mkdirSync(scriptsDir);
}
console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`);
fs.copyFileSync(assetPath, destinationPath);
} catch (error) {
console.error(
`\nERROR: Error while copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}:\n`,
error,
);
return false;
}
return true;
});
}

0 comments on commit 7a0e72e

Please sign in to comment.