diff --git a/packages/remix/.eslintrc.js b/packages/remix/.eslintrc.js index e682ebb55f7d..de52e01b9c4b 100644 --- a/packages/remix/.eslintrc.js +++ b/packages/remix/.eslintrc.js @@ -10,4 +10,12 @@ module.exports = { rules: { '@sentry-internal/sdk/no-async-await': 'off', }, + overrides: [ + { + files: ['scripts/**/*.ts'], + parserOptions: { + project: ['../../tsconfig.dev.json'], + }, + }, + ], }; diff --git a/packages/remix/.npmignore b/packages/remix/.npmignore new file mode 100644 index 000000000000..e1bb7e5136bd --- /dev/null +++ b/packages/remix/.npmignore @@ -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/**/* diff --git a/packages/remix/scripts/prepack.ts b/packages/remix/scripts/prepack.ts new file mode 100644 index 000000000000..890b3bc2b9f1 --- /dev/null +++ b/packages/remix/scripts/prepack.ts @@ -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; + }); +}