Skip to content

Switch env var for isVSCE check - #8257

Merged
joehan merged 9 commits into
masterfrom
jh-better-vsce-detections
Feb 26, 2025
Merged

joehan merged 9 commits into
masterfrom
jh-better-vsce-detections

Conversation

@joehan

@joehan joehan commented Feb 25, 2025 •

Copy link
Copy Markdown
Member

Description

VSCODE_CWD is set whenever you're running within VSCode, so its not safe to assume we've been webpacked if it is set. Instead, we define our own variable and use that.
Fixes #7471.

@joehan
joehan requested review from hlshen and yuchenshi and removed request for hlshen and yuchenshi February 25, 2025 22:35
@joehan

joehan commented Feb 25, 2025

Copy link
Copy Markdown
Member Author

Debugging this now, seems like this is causing extension activation to fail

@joehan

joehan commented Feb 25, 2025

Copy link
Copy Markdown
Member Author

Should be working now - tested both through the VSCE development host and by manually packaging a VSIX and installing it

@yuchenshi yuchenshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems fine but it's too confusing with a real env var.

Have we considered using a global variable instead, such as globalThis.WEBPACK_IS_VSCE? Or, can we at least add comments to the code saying it's not set but just defined by webpack?

@joehan

joehan commented Feb 26, 2025

Copy link
Copy Markdown
Member Author

This seems fine but it's too confusing with a real env var.

Have we considered using a global variable instead, such as globalThis.WEBPACK_IS_VSCE? Or, can we at least add comments to the code saying it's not set but just defined by webpack?

I'll try out the global variable idea.

@joehan
joehan requested a review from yuchenshi February 26, 2025 19:09
@joehan

joehan commented Feb 26, 2025

Copy link
Copy Markdown
Member Author

Refactored as you suggested - it required a little bit of finagling to make work with our build/lint rules tho

@yuchenshi yuchenshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

General approach lgtm, see nits inline. Your call

Comment thread firebase-vscode/src/extension.ts Outdated
"latest"
];
const env = { ...process.env, VSCODE_CWD: "" };
const env = { ...process.env, VSCODE_CWD: "", IS_FIREBASE_VSCE: "" };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert

Comment thread src/vsCodeUtils.ts Resolved
import { EMULATORS_SUPPORTED_BY_USE_EMULATOR, Emulators } from "../emulator/types";
import { readTemplateSync } from "../templates";

const INIT_TEMPLATE = readTemplateSync("hosting/init.js");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Had to move this into the function so that it wasn't evaluated before activation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's exactly this kind of stuff that makes me hate mutable state so much that I even awakened the mighty webpack. Well, at least we know what the tradeoffs are and we can deal with it another day

@joehan
joehan enabled auto-merge (squash) February 26, 2025 23:18
@codecov-commenter

codecov-commenter commented Feb 26, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.02%. Comparing base (aafe0a3) to head (12df64d).
⚠️ Report is 474 commits behind head on master.

Files with missing lines Patch % Lines
src/hosting/implicitInit.ts 0.00% 3 Missing ⚠️
src/deploy/lifecycleHooks.ts 0.00% 2 Missing ⚠️
src/emulator/hub.ts 0.00% 1 Missing ⚠️
src/vsCodeUtils.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8257      +/-   ##
==========================================
- Coverage   51.02%   51.02%   -0.01%     
==========================================
  Files         423      423              
  Lines       29944    29945       +1     
  Branches     6140     6140              
==========================================
  Hits        15278    15278              
- Misses      13286    13287       +1     
  Partials     1380     1380              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joehan
joehan merged commit 828e2d6 into master Feb 26, 2025
@joehan
joehan deleted the jh-better-vsce-detections branch February 26, 2025 23:44
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.

Incorrect path resolve when other VS Code extensions run firebase related command

3 participants