Skip to content

Commit

Permalink
Chore: update in order to facilitate bundling (#5579)
Browse files Browse the repository at this point in the history
* chore: update for bundling

* chore: revert to unbundled versions

* chore: apply js esbuild

---------

Co-authored-by: Daphne Yang <[email protected]>
  • Loading branch information
mingxuanzhangsfdx and daphne-sfdc authored May 8, 2024
1 parent 5acd2da commit 23da60c
Show file tree
Hide file tree
Showing 22 changed files with 1,278 additions and 35 deletions.
833 changes: 833 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions packages/salesforcedx-vscode-apex-debugger/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"root": true,
"extends": ["../../config/base-eslintrc.json", "./fix-these-rules.json"],
"extends": [
"../../config/base-eslintrc.json",
"./fix-these-rules.json"
],
"overrides": [
{
"files": ["./src/**/*.ts", "./test/**/*.ts"],
"files": [
"./src/**/*.ts",
"./test/**/*.ts"
],
"parserOptions": {
"project": "./tsconfig.json"
}
}
]
}
],
"env": {
"node": true
}
}
46 changes: 46 additions & 0 deletions packages/salesforcedx-vscode-apex-debugger/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* 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
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// 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
external: [
'vscode',
'@salesforce/core',
'@salesforce/source-tracking'
]
};

// 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 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'
});
})().then(async () => {
// await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-apex-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@typescript-eslint/parser": "6.9.0",
"chai": "^4.0.2",
"cross-env": "5.2.0",
"esbuild": "^0.19.5",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-header": "3.1.1",
Expand All @@ -59,7 +60,7 @@
"scripts": {
"bundle:extension": "npm run bundle:extension:build && npm run bundle:extension:copy",
"bundle:extension:copy": "cp ../salesforcedx-apex-debugger/dist/apexdebug.js ./dist/",
"bundle:extension:build": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --format=cjs --platform=node --external:vscode --external:@salesforce/core --external:@salesforce/source-tracking --minify",
"bundle:extension:build": "node ./esbuild.config.js",
"vscode:prepublish": "npm prune --production",
"vscode:package": "ts-node ../../scripts/vsce-bundled-extension.ts",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
Expand Down
17 changes: 13 additions & 4 deletions packages/salesforcedx-vscode-apex-replay-debugger/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"root": true,
"extends": ["../../config/base-eslintrc.json", "./fix-these-rules.json"],
"extends": [
"../../config/base-eslintrc.json",
"./fix-these-rules.json"
],
"overrides": [
{
"files": ["./src/**/*.ts", "./test/**/*.ts"],
"files": [
"./src/**/*.ts",
"./test/**/*.ts"
],
"parserOptions": {
"project": "./tsconfig.json"
}
}
]
}
],
"env": {
"node": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* 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
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// const fs = require('fs').promises;

const sharedConfig = {
bundle: true,
format: 'cjs',
platform: 'node',
external: [
'vscode',
'@salesforce/core',
'@salesforce/source-tracking',
'applicationinsights'
],
minify: true
};

// 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 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'
});
})().then(async () => {
// await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"@typescript-eslint/parser": "6.9.0",
"chai": "^4.0.2",
"cross-env": "5.2.0",
"esbuild": "^0.19.5",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-header": "3.1.1",
Expand Down Expand Up @@ -263,7 +264,7 @@
},
"scripts": {
"bundle:extension": "npm run bundle:extension:build && npm run bundle:extension:copy",
"bundle:extension:build": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --format=cjs --platform=node --external:vscode --external:@salesforce/core --external:@salesforce/source-tracking --external:applicationinsights --minify",
"bundle:extension:build": "node ./esbuild.config.js",
"bundle:extension:copy": "cp ../salesforcedx-apex-replay-debugger/dist/apexreplaydebug.js ./dist/",
"clean": "shx rm -rf node_modules && shx rm -rf out && shx rm -rf coverage && shx rm -rf .nyc_output",
"compile": "tsc -p ./",
Expand Down
17 changes: 13 additions & 4 deletions packages/salesforcedx-vscode-apex/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"root": true,
"extends": ["../../config/base-eslintrc.json", "./fix-these-rules.json"],
"extends": [
"../../config/base-eslintrc.json",
"./fix-these-rules.json"
],
"overrides": [
{
"files": ["./src/**/*.ts", "./test/**/*.ts"],
"files": [
"./src/**/*.ts",
"./test/**/*.ts"
],
"parserOptions": {
"project": "./tsconfig.json"
}
}
]
}
],
"env": {
"node": true
}
}
48 changes: 48 additions & 0 deletions packages/salesforcedx-vscode-apex/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* 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
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// const fs = require('fs').promises;

const sharedConfig = {
bundle: true,
format: 'cjs',
platform: 'node',
external: [
'vscode',
'@salesforce/core',
'applicationinsights',
'shelljs',
'@salesforce/source-deploy-retrieve',
'@salesforce/source-tracking'
],
minify: true
};

// 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 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'
});
})().then(async () => {
// await copyFiles(srcPath, destPath);
}).catch(() => process.exit(1));
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-apex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
"@typescript-eslint/parser": "6.9.0",
"chai": "^4.0.2",
"cross-env": "5.2.0",
"esbuild": "^0.19.5",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-header": "3.1.1",
Expand Down Expand Up @@ -410,7 +411,7 @@
},
"scripts": {
"bundle:extension": "npm run bundle:extension:build && npm run bundle:extension:copy",
"bundle:extension:build": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --format=cjs --platform=node --external:vscode --external:@salesforce/core --external:applicationinsights --external:shelljs --external:@salesforce/source-deploy-retrieve --external:@salesforce/source-tracking --minify",
"bundle:extension:build": "node ./esbuild.config.js",
"bundle:extension:copy": "cp ./out/apex-jorje-lsp.jar ./dist/",
"clean": "shx rm -rf node_modules && cd out && node ../../../scripts/clean-all-but-jar.js && shx rm -rf coverage && shx rm -rf .nyc_output",
"compile": "tsc -p ./",
Expand Down
17 changes: 13 additions & 4 deletions packages/salesforcedx-vscode-core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"root": true,
"extends": ["../../config/base-eslintrc.json", "./fix-these-rules.json"],
"extends": [
"../../config/base-eslintrc.json",
"./fix-these-rules.json"
],
"overrides": [
{
"files": ["./src/**/*.ts", "./test/**/*.ts"],
"files": [
"./src/**/*.ts",
"./test/**/*.ts"
],
"parserOptions": {
"project": "./tsconfig.json"
}
}
]
}
],
"env": {
"node": true
}
}
51 changes: 51 additions & 0 deletions packages/salesforcedx-vscode-core/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* 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
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const { build } = require('esbuild');
// const fs = require('fs').promises;

const sharedConfig = {
bundle: true,
format: 'cjs',
platform: 'node',
external: [
'vscode',
'applicationinsights',
'shelljs',
'@salesforce/core',
'@salesforce/source-tracking',
'@salesforce/templates',
'@salesforce/source-deploy-retrieve'
],
minify: true
};

// 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 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'
});
})()
.then(async () => {
// await copyFiles(srcPath, destPath);
})
.catch(() => process.exit(1));
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@typescript-eslint/parser": "6.9.0",
"chai": "^4.0.2",
"cross-env": "5.2.0",
"esbuild": "^0.19.5",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-header": "3.1.1",
Expand Down Expand Up @@ -107,7 +108,7 @@
}
},
"scripts": {
"bundle:extension": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --format=cjs --platform=node --external:vscode --external:@salesforce/core --external:applicationinsights --external:shelljs --external:@salesforce/source-tracking --external:@salesforce/templates --external:@salesforce/source-deploy-retrieve --minify",
"bundle:extension": "node ./esbuild.config.js",
"vscode:prepublish": "npm prune --production",
"vscode:package": "ts-node ../../scripts/vsce-bundled-extension.ts",
"vscode:sha256": "node ../../scripts/generate-sha256.js >> ../../SHA256",
Expand Down
Loading

0 comments on commit 23da60c

Please sign in to comment.