Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Project-wide preserveWhitespaces option is ignored

未关闭
#631 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@edbzn 已经在做这个了。

开始于 2026年10月25日。

  • #637 来自 @edbzn —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
angular, rust
领域
backend

调研方向

Start with compile_component_full and trace how it builds template parse options from metadata.preserve_whitespaces; compare that with the project default described in the issue. Check transformAngularFile and compileComponentHmrUpdate for the same option handling, then run the mentioned ngtsc spec, "should take preserveWhitespaces config option into account." Done means the project-wide setting is honored while a component decorator can override it; pull request #637 is already open.

由索引模型根据 Issue 内容生成。

描述

Summary

The project-wide preserveWhitespaces option (ngc's angularCompilerOptions.preserveWhitespaces) is ignored. TransformOptions.preserveWhitespaces exists, but transformAngularFile and compileComponentHmrUpdate only read the decorator's own preserveWhitespaces. A project that sets true globally therefore renders with collapsed whitespace, which can change the gaps between inline elements. The Vite plugin also has no way to set it.

Found by running Angular's ngtsc spec ngtsc_spec.ts: "should take preserveWhitespaces config option into account" against oxc.

Reproduction

import {Component} from '@angular/core';

@Component({selector: 'test', template: `<div>
    Template with whitespaces
  </div>`})
export class TestCmp {}

compiled with transformAngularFileSync(src, file, { preserveWhitespaces: true }).

Actual
i0.ɵɵtext(1, " Template with whitespaces ");
Expected (ngc, preserveWhitespaces: true)
i0.ɵɵtext(1, "\n    Template with whitespaces\n  ");

Cause

compile_component_full builds the template parse options from metadata.preserve_whitespaces only. ngtsc's parseTemplateDeclaration (annotations/component/src/resources.ts) starts from the project default and lets the decorator override it.

主要语言
Rust
星标
244
派生
26
平均合并
1 天 16 分钟
30 天内合并 PR
87

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

voidzero-dev/oxc-angular-compiler 的其他 Issue

查看 voidzero-dev/oxc-angular-compiler 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。