Skip to content

Commit 08de7db

Browse files
committed
fix(cli): parse decorator syntax and never suppress on global installs
Files using decorators parse instead of being skipped, and npm install -g commands no longer suppress the warning for packages task code can't resolve.
1 parent b320848 commit 08de7db

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/cli-v3/src/build/createRequireWarnings.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ describe("packagesInstalledByCommands", () => {
688688
"yarn add -D typescript",
689689
"npm install sqlite3@npm:@vscode/sqlite3",
690690
"npm install file:../local-lib",
691+
"npm install -g wrangler-cli",
691692
"bun run generate",
692693
"npm ci",
693694
"apt-get install -y ffmpeg",

packages/cli-v3/src/build/createRequireWarnings.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ type AstNode = {
156156
};
157157

158158
const MODULE_BUILTIN_SPECIFIERS = new Set(["module", "node:module"]);
159-
const PARSER_PLUGIN_ATTEMPTS: ParserPlugin[][] = [["typescript", "jsx"], ["typescript"], []];
159+
const PARSER_PLUGIN_ATTEMPTS: ParserPlugin[][] = [
160+
["typescript", "jsx", "decorators-legacy"],
161+
["typescript", "decorators-legacy"],
162+
["typescript"],
163+
[],
164+
];
160165

161166
function parseWithFallbacks(source: string): AstNode | undefined {
162167
for (const plugins of PARSER_PLUGIN_ATTEMPTS) {
@@ -610,6 +615,10 @@ export function packagesInstalledByCommands(commands: ReadonlyArray<string>): st
610615

611616
for (const command of commands) {
612617
for (const match of command.matchAll(INSTALL_COMMAND_REGEX)) {
618+
if (/(?:^|\s)(?:-g|--global)(?:\s|$)/.test(match[1]!)) {
619+
continue;
620+
}
621+
613622
for (const token of match[1]!.trim().split(/\s+/)) {
614623
if (token.length === 0 || token.startsWith("-")) {
615624
continue;

0 commit comments

Comments
 (0)