Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions config/rsbuild/rsbuild.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {GenerateSW} from '@aaroon/workbox-rspack-plugin';
import {pluginSvgr} from '@rsbuild/plugin-svgr';
import {RsdoctorRspackPlugin} from '@rsdoctor/rspack-plugin';
import {rspack} from '@rspack/core';
import {sentryWebpackPlugin} from '@sentry/webpack-plugin';
import {execSync} from 'child_process';
import dotenv from 'dotenv';
import fs from 'fs';
Expand Down Expand Up @@ -296,10 +295,11 @@ const getSharedConfiguration = ({file = '.env', isDevServer = false}: Environmen
/**
* Get a production grade Rsbuild config for web
*/
const getCommonConfiguration = ({file = '.env', platform = 'web', isDevServer = false}: Environment): RsbuildConfig => {
const getCommonConfiguration = async ({file = '.env', platform = 'web', isDevServer = false}: Environment): Promise<RsbuildConfig> => {
const isDevelopment = file === '.env' || file === '.env.development';
const shared = getSharedConfiguration({file, platform, isDevServer});
const sharedRspackTool = shared.tools?.rspack;
const sentryWebpackPlugin = isDevelopment ? undefined : (await import('@sentry/webpack-plugin')).sentryWebpackPlugin;

if (!isDevelopment) {
const releaseName = `${process.env.npm_package_name}@${process.env.npm_package_version}`;
Expand Down Expand Up @@ -518,10 +518,10 @@ const getCommonConfiguration = ({file = '.env', platform = 'web', isDevServer =
]
: []),
...(platform === 'web' ? [new CustomVersionFilePlugin()] : []),
// Upload source maps to Sentry
...(isDevelopment
? []
: ([
// Upload source maps to Sentry. @sentry/webpack-plugin is dynamically imported so dev
// config evaluation does not load webpack's deprecated compat exports under Bun.
...(sentryWebpackPlugin
? ([
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN as string | undefined,
org: 'expensify',
Expand All @@ -538,7 +538,8 @@ const getCommonConfiguration = ({file = '.env', platform = 'web', isDevServer =
debug: false,
telemetry: false,
}),
] as RspackPluginInstance[])),
] as RspackPluginInstance[])
: []),
// This allows us to interactively inspect JS bundle contents, loader/plugin timings, and duplicate packages
...(process.env.ANALYZE_BUNDLE === 'true' ? [new RsdoctorRspackPlugin()] : []),
);
Expand Down
2 changes: 1 addition & 1 deletion config/rsbuild/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ switch (process.env.ENV) {

export default defineConfig(async ({command}) => {
const isDevServer = command === 'dev';
const common: RsbuildConfig = getCommonConfiguration({file: envFile, platform: 'web', isDevServer});
const common: RsbuildConfig = await getCommonConfiguration({file: envFile, platform: 'web', isDevServer});

if (!isDevServer) {
return {
Expand Down
Loading