ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.56k stars 785 forks source link

bug: Unnecessary files generated #3786

Closed csisy closed 4 months ago

csisy commented 2 years ago

Prerequisites

Stencil Version

2.19.2

Current Behavior

Despite explicitly turning off ES5 build, there is no way to let the compiler know that we are trying to target a modern browser that doesn't need (for example) nomodule js files.

Targeting www, a very basic single-component library/app generates 5 files in prod mode and 9 files in dev mode. The dev build contains additional unnecessary files, like css-shim and shadow-css. No matter what I set in the config file.

Files generated in dev mode under www/build:

In prod mode, the polyfill/shim files are not present, fortunately.

Lastly, executing a dev build then a prod build generates one additional unnecessary file that is not generated in a second prod build. So build dev > build prod (+1 file for a total of 6 files) > build prod (5 files)

Expected Behavior

Either provide a config option to completely disable any kind of legacy support, or better examine the project files.

For example, despite the nomodule script tag is removed from the index.html, the unnecessary my-app.js file and an empty index.js is generated. By better examining the root html file, the compiler could find out that no nomodule file is needed.

The unnecessary shim and other polyfill files should not be generated when not needed.

Lastly, the 1 extra file on the first prod build must not be created.

Steps to Reproduce

Follow the getting started documentation.

Code Reproduction URL

-

Additional Information

No response

rwaskiewicz commented 1 year ago

Thanks @csisy, I was able to confirm this behavior described in issue summary.

I'm going to label this to get it into our backlog for the team to take a look

Tragio commented 6 months ago

Hi @rwaskiewicz 👋,

Is there any news regarding this issue? With more and more browser support, having all this legacy code is a bit unnecessary.

Thank you for all the great work 🚀

rwaskiewicz commented 6 months ago

@Tragio

Is there any news regarding this issue? With more and more browser support, having all this legacy code is a bit unnecessary.

This effort is up for consideration for Stencil v5. I don't have a timeline for this version of Stencil ATM, other than I'm quite literally doing the planning work as we speak.

Thank you for all the great work 🚀

❤️

rwaskiewicz commented 6 months ago

Related: https://github.com/ionic-team/stencil/issues/5416 (potentially the same)

christian-bromann commented 4 months ago

The fix for this issue has been released as a part of Stencil v4.18.1 release!