Skip to content

Conversation

kemmerle
Copy link
Contributor

@kemmerle kemmerle commented May 7, 2025

Description and Context

This PR needs to be merged into the PR to add JSON schema validation to the extension: #280

In the schema validation PR, we need to bump the @hubspot/local-dev-lib package version to ^3.1.0 to be compatible with the new dependency @hubspot/project-parsing-lib library which also contains LDL as a dependency.

There are significant differences between the two versions of LDL, and so I've made updates to the code where needed.

IMPORTANT NOTE PLEASE READ:

Some imports from @hubspot/local-dev-lib must keep CommonJS syntax. This is because:

  1. In @hubspot/local-dev-lib, the exports field in the package.json file exports the lib folder like this:
  "./*": "./lib/*.js"
  1. Only ES modules can read the exports field.

  2. VSCode extensions don't support ES Modules. I'm not joking, this is a very active issue.

  3. Ergo, imports from the /lib folder must keep CommonJS syntax.

  4. We could mess with the tsconfig.json file to try to change compilerOptions.module to nodenext or node16 and override any issues, but Microsoft specifically warns against any hacks. They're brittle and prone to breakage.

TODO

  • Address feedback
  • Get more folks to test it out

Who to Notify

@TanyaScales @brandenrodgers @camden11 @joe-yeager

const config = getConfig();
let invalidReason = '';
if (config) {
// @ts-expect-error TODO: Fix this when updating local-dev-lib
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 deprecated config and new config types are simply incompatible with one another. We can remove this error, once we account for the new global config in the extension.

commands.registerCommand(
COMMANDS.REMOTE_FS.FETCH,
async (clickedFileLink) => {
showMissingAccountError();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If no account is specified, we throw an error to the user and exit the command. This guarantees that getAccountId() is not undefined.

const decodedFilePath = decodeURIComponent(filepath);
try {
const file = await download(getAccountId(), decodedFilePath);
const { data: file } = await download(getAccountId()!, decodedFilePath);
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 accounts for changes to the http module in LDL versions 3 and above.

async () => {
const config = getConfig();
// @ts-expect-error TODO: Fix this when updating local-dev-lib
if (config && config.portals) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any utils we could leverage from LDL to get around some of these issues? Would getConfigAccounts help here?

@kemmerle kemmerle closed this May 7, 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