ionic-team / ionic-team/ionic-framework

bug: Compiled files issue with angular 19

未关闭
#30,100 19 条评论 12 个 reaction 已指派 0 人 在 GitHub 查看
triage
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

v8.x

### Current Behavior

When I use the compiled file from www, i can't run the project.
If go on the browser, I have this error :
"NullInjectorError: No provider for ho!"

### Expected Behavior

If i go on the browser, with the compiled files, the app works normally.

### Steps to Reproduce

1. Install the last ionic/cli
npm uninstall -g ionic
npm install -g ionic

2. ionic start a starter project (example : tabs)

3. run ionic build

4. add a simple file inside the /www folder after the build (run.js) :

`const express = require('express');
const path = require('path');
const app = express();

/**
* Instead of build provide your build directory.
*/
app.use(express.static(path.join(__dirname, '')));

app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, '', 'index.html'));
});

var server = app.listen(9000, () => {
var port = server.address().port;
console.log('App listening at http://localhost:' + port);
require('child_process').exec(`start http://localhost:${server.address().port}`);
});`

5. execute "node run.js"

6. open the browser and try the app. Then observe the issue.

7. Bonus : If you add in the angular.json file "optimization:false" to the production configuration so it works. I think the problem come from the "uglification"

### Code Reproduction URL

https://github.com/devilalex505/test-ez0kwm

### Ionic Info

Ionic:

Ionic CLI : 7.2.0
Ionic Framework : @ionic/angular 8.4.1
@angular-devkit/build-angular : 19.0.6
@angular-devkit/schematics : 19.0.6
@angular/cli : 19.0.6
@ionic/angular-toolkit : 12.1.1

Capacitor:

Capacitor CLI : 6.2.0
@capacitor/android : 6.2.0
@capacitor/core : 6.2.0
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 2.0.1

System:

NodeJS : v20.11.0
npm : 10.2.4
OS : Windows 10

### Additional Information

https://stackblitz.com/~/github.com/devilalex505/test-ez0kwm
1 . ng build
2 . node run.js

![bug](https://github.com/user-attachments/assets/32aa6181-c538-4d73-a44b-70fdf0b8c123)

If downgrade angular to v18, no issue

贡献指南

打开贡献指南

调研方向

Start with the linked reproduction and compare `ionic build`/`ng build` output in `www` with the `optimization` setting in `angular.json`. Run `node run.js` and verify that the Angular 19 app loads without the `NullInjectorError`; done means the optimized compiled files work when served from `www`.

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

评估

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

把新 issue 发到你的邮箱

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