Skip to content

Commit cc36ea8

Browse files
committed
refactor(cli,build,core): parse-based createRequire scanner, scoped install-command suppression
Replaces the hand-rolled lexer and regex scanner with a @babel/parser scan (typescript/jsx with fallbacks, parse failures skip the file), eliminating the comment/string/regex/JSX misparse class outright; template-literal specifiers now also match. Cross-file require functions resolve through the metafile's own import records, so index files and path aliases work. Build-layer install commands suppress only the packages they actually name instead of silencing the whole feature, first-party extensions that install no node packages declare that so dev warnings stay active for them, extension matchers are computed before internal extensions are prepended, deploy warning output honors plain mode and keeps location-less messages with a segment-exact node_modules filter, and additionalPackages only claims packages for the deploy target.
1 parent 4046b86 commit cc36ea8

17 files changed

Lines changed: 528 additions & 404 deletions

packages/build/src/extensions/audioWaveform.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export function audioWaveform(options: AudioWaveformOptions = {}): BuildExtensio
1717
class AudioWaveformExtension implements BuildExtension {
1818
public readonly name = "AudioWaveformExtension";
1919

20+
installedPackagesForTarget() {
21+
return [];
22+
}
23+
2024
constructor(private options: AudioWaveformOptions = {}) {}
2125

2226
async onBuildComplete(context: BuildContext, manifest: BuildManifest) {

packages/build/src/extensions/core/additionalFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type AdditionalFilesOptions = {
88
export function additionalFiles(options: AdditionalFilesOptions): BuildExtension {
99
return {
1010
name: "additionalFiles",
11+
installedPackagesForTarget: () => [],
1112
async onBuildComplete(context, manifest) {
1213
await addAdditionalFilesToBuild("additionalFiles", options, context, manifest);
1314
},

packages/build/src/extensions/core/additionalPackages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function additionalPackages(options: AdditionalPackagesOptions): BuildExt
2020
return {
2121
name: "additionalPackages",
2222
installedPackagesForTarget(target) {
23-
if (target === "dev") {
23+
if (target !== "deploy") {
2424
return [];
2525
}
2626

packages/build/src/extensions/core/aptGet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type AptGetOptions = {
77
export function aptGet(options: AptGetOptions): BuildExtension {
88
return {
99
name: "aptGet",
10+
installedPackagesForTarget: () => [],
1011
onBuildComplete(context) {
1112
if (context.target === "dev") {
1213
return;

packages/build/src/extensions/core/ffmpeg.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type FfmpegOptions = {
2424
export function ffmpeg(options: FfmpegOptions = {}): BuildExtension {
2525
return {
2626
name: "ffmpeg",
27+
installedPackagesForTarget: () => [],
2728
onBuildComplete(context) {
2829
if (context.target === "dev") {
2930
return;

packages/build/src/extensions/core/syncEnvVars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type SyncEnvVarsOptions = {
7777
export function syncEnvVars(fn: SyncEnvVarsFunction, options?: SyncEnvVarsOptions): BuildExtension {
7878
return {
7979
name: "SyncEnvVarsExtension",
80+
installedPackagesForTarget: () => [],
8081
async onBuildComplete(context, manifest) {
8182
if (context.target === "dev") {
8283
return;

packages/build/src/extensions/lightpanda.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const lightpanda = ({
1010
disableTelemetry = false,
1111
}: LightpandaOpts = {}): BuildExtension => ({
1212
name: "lightpanda",
13+
installedPackagesForTarget: () => [],
1314
onBuildComplete: async (context) => {
1415
if (context.target === "dev") {
1516
return;

packages/build/src/extensions/puppeteer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export function puppeteer() {
88
class PuppeteerExtension implements BuildExtension {
99
public readonly name = "PuppeteerExtension";
1010

11+
installedPackagesForTarget() {
12+
return [];
13+
}
14+
1115
async onBuildComplete(context: BuildContext, manifest: BuildManifest) {
1216
if (context.target === "dev") {
1317
return;

packages/build/src/extensions/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const decoratorMatcher = new RegExp(/((?<![(\s]\s*['"])@\w[.[\]\w\d]*\s*(?![;])[
88
export function emitDecoratorMetadata(): BuildExtension {
99
return {
1010
name: "emitDecoratorMetadata",
11+
installedPackagesForTarget: () => [],
1112
onBuildStart(context) {
1213
const { convertCompilerOptionsFromJson, transpileModule, ModuleKind } = loadTypescript(
1314
context.workingDir

packages/cli-v3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"ini": "^5.0.0",
108108
"json-stable-stringify": "^1.3.0",
109109
"jsonc-parser": "3.2.1",
110+
"@babel/parser": "^7.29.7",
110111
"magicast": "^0.3.4",
111112
"minimatch": "^10.0.1",
112113
"mlly": "^1.7.1",

0 commit comments

Comments
 (0)