Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mz/bundle core n templates #5705

Merged
merged 19 commits into from
Aug 15, 2024
Merged

Conversation

mingxuanzhangsfdx
Copy link
Member

@mingxuanzhangsfdx mingxuanzhangsfdx commented Jul 31, 2024

What does this PR do?

This PR further bundles sfdx-core and templates in core extension. The total size of core extension reduces from 8.9MB to 2.8MB

What issues does this PR fix or reference?

@W-15736969@

Functionality Before

sfdx-core and templates are not bundled in core extension.

Functionality After

sfdx-core and templates are bundled.

@@ -96,11 +96,11 @@
"dist"
],
"packageUpdates": {
"main": "dist/index.js",
"main": "dist/src/index.js",
"salesforceApiVersion": "61",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this config in package.json of the core vsix, in order to provide the missing info from bundling template. So with this setting, one should be aware to update the field when the version of templates is bumped here with a bump of salesforceApiVersion.

I would also like to make this dynamic within esbuild.config.js, so one does not need to update the field frequently, but this added config should be always taken care.

The reason why it works is that the relative path of package.json of baseGenerator.ts within templates library is identical to the relative path of package.json within vsix (of dist/src/index.js).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this. Having this here does not guarantee it is correct. This data should come from templates module.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "salesforceApiVersion" can be removed.

@@ -6,7 +6,7 @@
*/

import { ConfigUtil } from '@salesforce/salesforcedx-utils-vscode';
import { nls as templatesNls } from '@salesforce/templates-bundle/lib/i18n';
import { nls as templatesNls } from '@salesforce/templates/lib/i18n';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage like this should not work, but vscode-integration is deprecated now so we just ignore it.

@mingxuanzhangsfdx mingxuanzhangsfdx marked this pull request as ready for review August 6, 2024 23:19
@mingxuanzhangsfdx mingxuanzhangsfdx requested a review from a team as a code owner August 6, 2024 23:19
@@ -96,11 +96,11 @@
"dist"
],
"packageUpdates": {
"main": "dist/index.js",
"main": "dist/src/index.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the path of entry due to the reason from the other comments

packages/salesforcedx-vscode-core/esbuild.config.js Outdated Show resolved Hide resolved
@@ -96,11 +96,11 @@
"dist"
],
"packageUpdates": {
"main": "dist/index.js",
"main": "dist/src/index.js",
"salesforceApiVersion": "61",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this. Having this here does not guarantee it is correct. This data should come from templates module.

@mingxuanzhangsfdx
Copy link
Member Author

@peternhale I create a PR in templates to resolve the concern you raised.

e2e test passes.


(async () => {
await build({
...sharedConfig,
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.js'
outdir: 'dist/src'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mingxuanzhangsfdx can this be simplified to 'dist'? That would then "match" the other extension bundles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the bundle artifacts inside a src folder in order to align the relative path to /templates with the original one. I can put them directly under dist, but that will make /templates parallel to /dist. So I need to adjust this during vscode:package process, which I found it hard to maintain. So the best solution is to construct it during /dist generation imho.

@@ -96,11 +96,11 @@
"dist"
],
"packageUpdates": {
"main": "dist/index.js",
"main": "dist/src/index.js",
"salesforceApiVersion": "61",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "salesforceApiVersion" can be removed.

@mingxuanzhangsfdx mingxuanzhangsfdx requested review from peternhale and removed request for lahernandezb August 14, 2024 22:01
@mingxuanzhangsfdx
Copy link
Member Author

@mingxuanzhangsfdx mingxuanzhangsfdx merged commit 40b0ad4 into develop Aug 15, 2024
12 checks passed
@mingxuanzhangsfdx mingxuanzhangsfdx deleted the mz/bundle-core-n-templates branch August 15, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants