const isDevelopmentBuild = env.BUILD === 'development';
const isAnalyzeBuild = env.ANALYZE;
-const sourceMap = !!isDevelopmentBuild;
+const sourcemap = !!isDevelopmentBuild;
export default defineConfig({
input: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
{
dir: './dist',
format: 'esm',
- sourcemap: sourceMap,
+ sourcemap,
plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })],
},
],
typescript({
tsconfig: './tsconfig.json',
compilerOptions: {
- sourceMap,
+ sourceMap: sourcemap,
},
}),
del({
| WorkerConfiguration
| UIServerConfiguration;
+// Avoid ESM race condition at class initialization
+const configurationLogPrefix = (): string => {
+ return logPrefix(' Simulator configuration |');
+};
+
export class Configuration {
public static configurationChangeCallback: () => Promise<void>;
);
}
- private static logPrefix = (): string => {
- return logPrefix(' Simulator configuration |');
- };
-
private static isConfigurationSectionCached(sectionName: ConfigurationSection): boolean {
return Configuration.configurationSectionCache.has(sectionName);
}
(stationTemplateUrl: StationTemplateUrl) => {
if (!isUndefined(stationTemplateUrl?.['numberOfStation' as keyof StationTemplateUrl])) {
console.error(
- `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `${chalk.green(configurationLogPrefix())} ${chalk.red(
`Deprecated configuration key 'numberOfStation' usage for template file '${stationTemplateUrl.file}' in 'stationTemplateUrls'. Use 'numberOfStations' instead`,
)}`,
);
('staticPool' as WorkerProcessType)
) {
console.error(
- `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `${chalk.green(configurationLogPrefix())} ${chalk.red(
`Deprecated configuration 'staticPool' value usage in worker section 'processType' field. Use '${WorkerProcessType.fixedPool}' value instead`,
)}`,
);
// uiServer section
if (hasOwnProp(Configuration.getConfigurationData(), 'uiWebSocketServer')) {
console.error(
- `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `${chalk.green(configurationLogPrefix())} ${chalk.red(
`Deprecated configuration section 'uiWebSocketServer' usage. Use '${ConfigurationSection.uiServer}' instead`,
)}`,
);
)
) {
console.error(
- `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `${chalk.green(configurationLogPrefix())} ${chalk.red(
`Deprecated configuration key '${key}' usage in section '${sectionName}'${
logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
}`,
!isUndefined(Configuration.getConfigurationData()?.[key as keyof ConfigurationData])
) {
console.error(
- `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+ `${chalk.green(configurationLogPrefix())} ${chalk.red(
`Deprecated configuration key '${key}' usage${
logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
}`,
Configuration.configurationFile,
FileType.Configuration,
error as NodeJS.ErrnoException,
- Configuration.logPrefix(),
+ configurationLogPrefix(),
);
}
}
Configuration.configurationFile,
FileType.Configuration,
error as NodeJS.ErrnoException,
- Configuration.logPrefix(),
+ configurationLogPrefix(),
);
}
}