Skip to content

@W-18471994 ci: web bundling #1189

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

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft

@W-18471994 ci: web bundling #1189

wants to merge 36 commits into from

Conversation

mshanemc
Copy link
Contributor

@mshanemc mshanemc commented May 15, 2025

What does this PR do?

makes a web bundle
simplify existing bundling code

What issues does this PR fix or reference?

@W-18471994@

@@ -54,6 +54,9 @@ export const retrieveKeychain = async (platform: string): Promise<KeyChain> => {
return keyChainImpl.generic_unix;
}
}
} else if (platform === 'browser') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the polyfill for os will return platform as browser, something node would never do

@@ -7,9 +7,6 @@

import { AnyJson, Dictionary } from '@salesforce/ts-types';
import { compare } from 'semver';
// needed for TS to not put everything inside /lib/src
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this ignore comment didn't seem necessary

@@ -278,7 +279,7 @@ export class Logger {
* Gets the name of this logger.
*/
public getName(): string {
return (this.pinoLogger.bindings().name as string) ?? '';
return (this.pinoLogger?.bindings ? (this.pinoLogger.bindings().name as string) : '') ?? '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the binding don't come through when pino is in browser mode

@@ -216,7 +224,7 @@ export const getFileLocation = (): string => join(homedir(), Global.SFDX_STATE_F

const unlockIfLocked = async (fileLocation: string): Promise<void> => {
try {
await unlock(fileLocation);
await unlock(fileLocation, { fs });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the fs is injectable, otherwise it defaults to graceful.

this lets the lockfile use our memfs polyfill

import { lockOptions, lockRetryOptions } from './lockRetryOptions';

type LockInitResponse = { writeAndUnlock: (data: string) => Promise<void>; unlock: () => Promise<void> };
type LockInitSyncResponse = { writeAndUnlock: (data: string) => void; unlock: () => void };

export const noop = (): void => {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hypothesis: the in-memory fs is fast enough to not have synchronous read/write; also we're single-org in the web.

we can have these use locks if that turns out to be wrong

@@ -6,9 +6,11 @@
*/

// docs: https://github.com/moxystudio/node-proper-lockfile
import fs from 'node:fs';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same injectable fs to get polyfill

@@ -142,60 +142,3 @@ describe('myDomainResolver', () => {
expect(lookupAsyncSpy.callCount).to.be.equal(0);
});
});
describe('cname resolver', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isn't used by anything in salesforcecli or forcedotcom.

I know it's a breaking change to a public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

import { SfdcUrl } from '../../../src/util/sfdcUrl';
import { MyDomainResolver } from '../../../src/status/myDomainResolver';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

and then you don't have to mock it

@@ -116,19 +115,21 @@ export class AliasAccessor extends AsyncOptionalCreatable {
*/
public async setAndSave(alias: string, entity: Aliasable): Promise<void> {
// get a very fresh copy to merge with to avoid conflicts, then lock
await this.readFileToAliasStore(true);
const lockResponse = await lockInit(this.fileLocation);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the biggest change. I reworked alias to use the same exported lockfile that everything else is using.

@mshanemc mshanemc changed the title @W-18471994 Sm/web bundling @W-18471994 ci: web bundling May 22, 2025
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy