Skip to content

Commit

Permalink
perf: dynamically import apex-node + sfdx-auth-helper
Browse files Browse the repository at this point in the history
This will create chunks and allow for the js to be loaded and
parsed faster as the chunks will be parsed later.
  • Loading branch information
lukecotter committed Dec 15, 2023
1 parent a752e67 commit 61f354c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lana/src/salesforce/logs/GetLogFile.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2020 Certinia Inc. All rights reserved.
*/
import { AuthHelper } from '@apexdevtools/sfdx-auth-helper';
import { LogService } from '@salesforce/apex-node';

export class GetLogFile {
static async apply(wsPath: string, logDir: string, logId: string): Promise<void> {
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');

Check warning on line 7 in lana/src/salesforce/logs/GetLogFile.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Variable name `AuthHelper` must match one of the following formats: camelCase, UPPER_CASE
const ah = await AuthHelper.instance(wsPath);
const connection = await ah.connect(await ah.getDefaultUsername());

if (connection) {
const { LogService } = await import('@salesforce/apex-node');

Check warning on line 12 in lana/src/salesforce/logs/GetLogFile.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Variable name `LogService` must match one of the following formats: camelCase, UPPER_CASE
await new LogService(connection).getLogs({ logId: logId, outputDir: logDir });
}
return new Promise((resolve) => resolve());
Expand Down
5 changes: 3 additions & 2 deletions lana/src/salesforce/logs/GetLogFiles.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/*
* Copyright (c) 2020 Certinia Inc. All rights reserved.
*/
import { AuthHelper } from '@apexdevtools/sfdx-auth-helper';
import { type LogRecord, LogService } from '@salesforce/apex-node';
import { type LogRecord } from '@salesforce/apex-node';

export class GetLogFiles {
static async apply(wsPath: string): Promise<LogRecord[]> {
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');

Check warning on line 8 in lana/src/salesforce/logs/GetLogFiles.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Variable name `AuthHelper` must match one of the following formats: camelCase, UPPER_CASE
const ah = await AuthHelper.instance(wsPath);
const connection = await ah.connect(await ah.getDefaultUsername());

if (connection) {
const { LogService } = await import('@salesforce/apex-node');

Check warning on line 13 in lana/src/salesforce/logs/GetLogFiles.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Variable name `LogService` must match one of the following formats: camelCase, UPPER_CASE
return new LogService(connection).getLogRecords();
}
return [];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"bump-prerelease": "node ./scripts/pre-release.js",
"preinstall": "npx only-allow pnpm",
"build": "NODE_ENV=production pnpm run build:dev",
"build:dev": "concurrently -r -g 'rm -rf lana/out && rollup -c rollup.config.mjs' 'tsc --noemit --skipLibCheck -p log-viewer/tsconfig.json' 'tsc --noemit --skipLibCheck -p lana/tsconfig.json'",
"build:dev": "rm -rf lana/out && concurrently -r -g 'rollup -c rollup.config.mjs' 'tsc --noemit --skipLibCheck -p log-viewer/tsconfig.json' 'tsc --noemit --skipLibCheck -p lana/tsconfig.json'",
"watch": "rm -rf lana/out && rollup -w -c rollup.config.mjs",
"prepare": "husky install",
"lint": "concurrently -r -g 'eslint . --ext ts' 'prettier --cache **/*.{ts,css,md,scss} --check' 'tsc --noemit --skipLibCheck -p log-viewer/tsconfig.json' 'tsc --noemit --skipLibCheck -p lana/tsconfig.json'",
Expand Down
37 changes: 19 additions & 18 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default [
input: './lana/src/Main.ts',
output: {
format: 'cjs',
file: './lana/out/Main.js',
dir: './lana/out',
chunkFileNames: '[name].js',
sourcemap: false,
},
external: ['vscode'],
Expand Down Expand Up @@ -87,23 +88,23 @@ export default [
dest: './log-viewer/out/index.html',
minifierOptions: production
? {
collapseWhitespace: true,
html5: true,
includeAutoGeneratedTags: false,
minifyCSS: true,
preventAttributesEscaping: true,
processConditionalComments: true,
removeAttributeQuotes: false,
removeComments: true,
removeEmptyAttributes: false,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true,
collapseWhitespace: true,
html5: true,
includeAutoGeneratedTags: false,
minifyCSS: true,
preventAttributesEscaping: true,
processConditionalComments: true,
removeAttributeQuotes: false,
removeComments: true,
removeEmptyAttributes: false,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true,
}
: {},
},
Expand Down

0 comments on commit 61f354c

Please sign in to comment.