Skip to content

Commit

Permalink
feat: opt in bundling @salesforce/core (#5656)
Browse files Browse the repository at this point in the history
* feat: opt in bundling core

* chore: templates version with caret
  • Loading branch information
mingxuanzhangsfdx authored Jun 24, 2024
1 parent 3ddb6c0 commit bc743fc
Show file tree
Hide file tree
Showing 136 changed files with 629 additions and 517 deletions.
524 changes: 318 additions & 206 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/salesforcedx-sobjects-faux-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"main": "out/src",
"dependencies": {
"@jsforce/jsforce-node": "3.2.0",
"@salesforce/core": "7.5.0",
"@salesforce/salesforcedx-utils-vscode": "61.2.0",
"shelljs": "0.8.5"
"shelljs": "0.8.5",
"@salesforce/core-bundle": "7.5.0"
},
"devDependencies": {
"@types/chai": "4.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SObjectShortDescription } from '../src/describe';
import { OrgObjectDetailRetriever } from '../src/retriever';
import { SObject } from '../src/types';

import { Connection, Org } from '@salesforce/core';
import { Connection, Org } from '@salesforce/core-bundle';

// tslint:disable-next-line:no-floating-promises
(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
DescribeSObjectResult,
Field
} from '@jsforce/jsforce-node';
import { Connection } from '@salesforce/core';
import { Connection } from '@salesforce/core-bundle';
import { CLIENT_ID } from '../constants';
import { BatchRequest, BatchResponse, SObject } from '../types';
import { SObjectField } from '../types/describe';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Connection } from '@salesforce/core';
import { Connection } from '@salesforce/core-bundle';
import {
SObjectDescribe,
SObjectSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { AuthInfo, Connection, SfProject } from '@salesforce/core';
import { AuthInfo, Connection, SfProject } from '@salesforce/core-bundle';
import {
ConfigUtil,
WorkspaceContextUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { AuthInfo, Connection } from '@salesforce/core';
import { AuthInfo, Connection } from '@salesforce/core-bundle';
import { fail } from 'assert';
import { expect } from 'chai';
import { createSandbox } from 'sinon';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { AuthInfo } from '@salesforce/core';
import { AuthInfo } from '@salesforce/core-bundle';
import { projectPaths } from '@salesforce/salesforcedx-utils-vscode';
import { fail } from 'assert';
import { expect } from 'chai';
Expand Down
8 changes: 4 additions & 4 deletions packages/salesforcedx-utils-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
],
"main": "out/src",
"dependencies": {
"@salesforce/core": "7.5.0",
"@salesforce/source-deploy-retrieve": "11.6.10",
"@salesforce/source-tracking": "6.5.1",
"applicationinsights": "1.0.7",
"cross-spawn": "7.0.3",
"rxjs": "^5.4.1",
"strip-ansi": "^5.2.0",
"tree-kill": "^1.1.0"
"tree-kill": "^1.1.0",
"@salesforce/core-bundle": "7.5.0",
"@salesforce/source-tracking-bundle": "6.5.1",
"@salesforce/source-deploy-retrieve-bundle": "11.6.10"
},
"devDependencies": {
"@types/cross-spawn": "6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Org,
OrgConfigProperties,
StateAggregator
} from '@salesforce/core';
} from '@salesforce/core-bundle';
import { workspaceUtils } from '..';
import {
SF_CONFIG_DISABLE_TELEMETRY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { AuthInfo, Connection, StateAggregator } from '@salesforce/core';
import { AuthInfo, Connection, StateAggregator } from '@salesforce/core-bundle';
import * as vscode from 'vscode';
import { ConfigAggregatorProvider, TelemetryService } from '..';
import { ConfigUtil } from '../config/configUtil';
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-utils-vscode/src/helpers/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Global } from '@salesforce/core';
import { Global } from '@salesforce/core-bundle';
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Connection } from '@salesforce/core';
import { Connection } from '@salesforce/core-bundle';
import { TraceFlagsRemover } from '../helpers';
import { nls } from '../messages';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Connection } from '@salesforce/core';
import { Connection } from '@salesforce/core-bundle';

/**
* TraceFlagsRemover is a singleton which deletes trace flags created by the extensions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { ConfigAggregator } from '@salesforce/core';
import { ConfigAggregator } from '@salesforce/core-bundle';
import { workspaceUtils } from '../workspaces';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Connection, Org, SfProject } from '@salesforce/core';
import { Connection, Org, SfProject } from '@salesforce/core-bundle';
import {
SourceTracking,
SourceTrackingOptions
} from '@salesforce/source-tracking';
} from '@salesforce/source-tracking-bundle';

/*
* The SourceTrackingProvider class is used to instantiate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Connection } from '@salesforce/core';
import { RetrieveResult } from '@salesforce/source-deploy-retrieve';
import { SourceTracking, StatusOutputRow } from '@salesforce/source-tracking';
import { Connection } from '@salesforce/core-bundle';
import { RetrieveResult } from '@salesforce/source-deploy-retrieve-bundle';
import { SourceTracking, StatusOutputRow } from '@salesforce/source-tracking-bundle';
import { WorkspaceContextUtil } from '../context/workspaceContextUtil';
import { nls } from '../messages';
import { Row, Table } from '../output';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Config, Org, StateAggregator } from '@salesforce/core';
import { Config, Org, StateAggregator } from '@salesforce/core-bundle';
import { ConfigUtil, TARGET_ORG_KEY, workspaceUtils } from '../../../src';
import { ConfigAggregatorProvider } from './../../../src/providers/configAggregatorProvider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { AuthInfo, Connection, StateAggregator } from '@salesforce/core';
import { AuthInfo, Connection, StateAggregator } from '@salesforce/core-bundle';
import * as vscode from 'vscode';
import {
ConfigAggregatorProvider,
Expand All @@ -15,7 +15,7 @@ import {
import { ConfigUtil } from '../../../src/config/configUtil';
import { WORKSPACE_CONTEXT_ORG_ID_ERROR } from '../../../src/context/workspaceContextUtil';
import { nls } from '../../../src/messages';
jest.mock('@salesforce/core', () => {
jest.mock('@salesforce/core-bundle', () => {
return {
Logger: {
childFromRoot: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
TOOLS
} from '../../../src/helpers/paths';

jest.mock('@salesforce/core', () => {
jest.mock('@salesforce/core-bundle', () => {
return {
Global: {
SFDX_STATE_FOLDER: '.sfdx',
Expand All @@ -34,7 +34,7 @@ jest.mock('@salesforce/core', () => {
};
});

jest.mock('@salesforce/source-tracking', () => {
jest.mock('@salesforce/source-tracking-bundle', () => {
return {};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { WorkspaceContextUtil } from '../../../../src';
import { SourceTrackingService } from '../../../../src/services';
import { testData } from './testData';

jest.mock('@salesforce/core', () => ({
...jest.requireActual('@salesforce/core'),
jest.mock('@salesforce/core-bundle', () => ({
...jest.requireActual('@salesforce/core-bundle'),
Org: { create: jest.fn() },
SfProject: { resolve: jest.fn() }
}));
Expand Down
37 changes: 20 additions & 17 deletions packages/salesforcedx-vscode-apex-debugger/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,44 @@
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// const fs = require('fs').promises;
const esbuildPluginPino = require('esbuild-plugin-pino');
const fs = require('fs').promises;

// Configure and run the build process
const sharedConfig = {
bundle: true, // Bundle all dependencies into one file
format: 'cjs', // Output format (CommonJS)
platform: 'node', // Platform target (Node.js)
minify: true, // Minify the output
keepNames: true, // keepNames to get rid of
external: [
'vscode',
'@salesforce/core',
'@salesforce/source-tracking'
'vscode'
],
plugins: [
esbuildPluginPino({ transports: ['pino-pretty'] })
]
};

// copy core-bundle/lib/transformStream.js to dist if core-bundle is included
// const copyFiles = async (src, dest) => {
// try {
// // Copy the file
// await fs.copyFile(src, dest);
// console.log(`File was copied from ${src} to ${dest}`);
// } catch (error) {
// console.error('An error occurred:', error);
// }
// };
const copyFiles = async (src, dest) => {
try {
// Copy the file
await fs.copyFile(src, dest);
console.log(`File was copied from ${src} to ${dest}`);
} catch (error) {
console.error('An error occurred:', error);
}
};

// const srcPath = '../../node_modules/@salesforce/core-bundle/lib/transformStream.js';
// const destPath = './dist/transformStream.js';
const srcPath = '../../node_modules/@salesforce/core-bundle/lib/transformStream.js';
const destPath = './dist/transformStream.js';

(async () => {
await build({
...sharedConfig,
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.js'
outdir: 'dist'
});
})().then(async () => {
// await copyFiles(srcPath, destPath);
await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
4 changes: 1 addition & 3 deletions packages/salesforcedx-vscode-apex-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
"packageUpdates": {
"main": "dist/index.js",
"dependencies": {
"applicationinsights": "1.0.7",
"@salesforce/core": "7.5.0",
"@salesforce/source-tracking": "6.5.1"
"applicationinsights": "1.0.7"
},
"devDependencies": {}
}
Expand Down
39 changes: 21 additions & 18 deletions packages/salesforcedx-vscode-apex-replay-debugger/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,45 @@
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// const fs = require('fs').promises;
const esbuildPluginPino = require('esbuild-plugin-pino');
const fs = require('fs').promises;

const sharedConfig = {
bundle: true,
format: 'cjs',
platform: 'node',
external: [
'vscode',
'@salesforce/core',
'@salesforce/source-tracking',
'applicationinsights',
'jsonpath'
],
minify: true
minify: true,
keepNames: true,
plugins: [
esbuildPluginPino({ transports: ['pino-pretty'] })
]
};

// copy core-bundle/lib/transformStream.js to dist if core-bundle is included
// const copyFiles = async (src, dest) => {
// try {
// // Copy the file
// await fs.copyFile(src, dest);
// console.log(`File was copied from ${src} to ${dest}`);
// } catch (error) {
// console.error('An error occurred:', error);
// }
// };
const copyFiles = async (src, dest) => {
try {
// Copy the file
await fs.copyFile(src, dest);
console.log(`File was copied from ${src} to ${dest}`);
} catch (error) {
console.error('An error occurred:', error);
}
};

// const srcPath = '../../node_modules/@salesforce/core-bundle/lib/transformStream.js';
// const destPath = './dist/transformStream.js';
const srcPath = '../../node_modules/@salesforce/core-bundle/lib/transformStream.js';
const destPath = './dist/transformStream.js';

(async () => {
await build({
...sharedConfig,
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.js'
outdir: 'dist'
});
})().then(async () => {
// await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"Debuggers"
],
"dependencies": {
"@salesforce/apex-node": "6.1.3",
"@salesforce/core": "7.5.0",
"@salesforce/salesforcedx-apex-replay-debugger": "61.2.0",
"@salesforce/salesforcedx-utils": "61.2.0",
"@salesforce/salesforcedx-utils-vscode": "61.2.0",
"async-lock": "1.0.0",
"request-light": "^0.7.0",
"vscode-extension-telemetry": "0.0.17"
"vscode-extension-telemetry": "0.0.17",
"@salesforce/core-bundle": "7.5.0",
"@salesforce/apex-node-bundle": "6.1.3"
},
"devDependencies": {
"@salesforce/salesforcedx-test-utils-vscode": "61.2.0",
Expand Down Expand Up @@ -106,8 +106,6 @@
"packageUpdates": {
"main": "dist/index.js",
"dependencies": {
"@salesforce/core": "7.5.0",
"@salesforce/source-tracking": "6.5.1",
"applicationinsights": "1.0.7",
"jsonpath": "1.1.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
TestLevel,
TestResult,
TestService
} from '@salesforce/apex-node';
import { Connection } from '@salesforce/core';
} from '@salesforce/apex-node-bundle';
import { Connection } from '@salesforce/core-bundle';
import {
ContinueResponse,
LibraryCommandletExecutor,
Expand Down
Loading

0 comments on commit bc743fc

Please sign in to comment.