Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function "statsToString" only prints the size of the first file #16627

Closed
1 of 15 tasks
EmaGht opened this issue Jan 10, 2020 · 6 comments
Closed
1 of 15 tasks

function "statsToString" only prints the size of the first file #16627

EmaGht opened this issue Jan 10, 2020 · 6 comments

Comments

@EmaGht
Copy link
Contributor

EmaGht commented Jan 10, 2020

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

No

Description

I'm CLI-izing an old application and to do so, i've set up the build target with
@angular-builders/custom-webpack:browser
My webpack.config.js emits the main_client.js together with an initial.css,
when this happens, the Angular-CLI function statsToString only prints the size of the first file it encounters like so:

function statsToString(json, statsConfig) {
    const colors = statsConfig.colors;
    const rs = (x) => colors ? reset(x) : x;
    const w = (x) => colors ? bold(white(x)) : x;
    const changedChunksStats = json.chunks
        .filter((chunk) => chunk.rendered)
        .map((chunk) => {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//Notice "chunk.files[0]"
        const asset = json.assets.filter((x) => x.name == chunk.files[0])[0];
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        return generateBundleStats({ ...chunk, size: asset && asset.size }, colors);
    });

which generates this not-so-good report where the sizes are 73KB for initial.css and around 8MB for main-client.js

.
.
.
chunk {main-client} initial.css, main-client.js (main-client) 73 kB [entry] [rendered]

Now, i know i'm not supposed to use my own webpack with the CLI etc.. etc.. etc.. but since the logger actually prints all initial file's names i would assume it would also sum their sizes?

Still, the build is somehow working and I'm already quite happy about that, but if you guys could fix up the size count of the initial chunk, that would be terrific! :)

Thanks!

@filipesilva
Copy link
Contributor

That's indeed not great :(

I'm surprised it took this long to come up too!

Would you be interested in taking a look?

@EmaGht
Copy link
Contributor Author

EmaGht commented Jan 17, 2020

I'll try to take a look at it!
I'm pretty sure i will need a pointer or two when i get to the testing side of the matter but until then... wish me good luck :D

@filipesilva
Copy link
Contributor

I don't think we have a good way of testing this change...

If I were looking into this, I'd first start with a real project that I know is doing the wrong thing. Then I'd go directly into node modules and change the code to do the right thing. Then I'd make a PR with those changes, and put in the PR message a before and after screenshot.

Rather informal but I think that's what we did the last few times we changes the logging format.

@clydin
Copy link
Member

clydin commented Jan 21, 2020

Can you also provide an example webpack configuration that exhibits the issue described above?

@EmaGht
Copy link
Contributor Author

EmaGht commented Jan 22, 2020

@filipesilva Ok
@clydin Ok
I'll see to put something together before the weekend

-Edit
I actually found a couple of minutes to put a hopefully-decent Pull Request together:
#16734

EmaGht added a commit to EmaGht/angular-cli that referenced this issue Jan 29, 2020
@kyliau kyliau closed this as completed in 2f1a9db Feb 13, 2020
kyliau pushed a commit that referenced this issue Feb 13, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants