Giter VIP home page Giter VIP logo

Comments (5)

lukastaegert avatar lukastaegert commented on July 4, 2024 1

Setting moduleSideEffects: 'no-treeshake' is always considered one hell of a side effect, so those would be properly ordered 😉

from rollup.

lukastaegert avatar lukastaegert commented on July 4, 2024

Yes, I am aware of this and it is indeed a duplicate. One problem is that fixing this would involve creating quite a few more chunks, and we already have a lot of chunks in complicated projects. So I wonder if this "strict execution order" should be an opt-in or an opt-out for users via an option. What would you think?
Another thought would be to track which modules have side effects and only ensure correct execution order between modules with side effects. Then maybe we could just enable it for everyone and hope that people do not have too many side effects in their modules.

from rollup.

sapphi-red avatar sapphi-red commented on July 4, 2024

In Vite, we transform each HTML into a module with <link rel=stylesheet href=/foo.css /> transformed to import './foo.css'. We set moduleSideEffects: 'no-treeshake' to CSS files and HTML files. Then, we inject the CSS tag rely on the generated chunk order. So in this specific case, opt-in for each module would work for Vite.

I guess in most cases, users would want to apply it only to some modules like modules injecting polyfills.

from rollup.

lukastaegert avatar lukastaegert commented on July 4, 2024

For polyfills, there is usually not a problem if you ensure that all static entries first import the polyfill. See also https://rollupjs.org/faqs/#how-do-i-add-polyfills-to-a-rollup-bundle . But it would still be nice to fix this properly.

from rollup.

sapphi-red avatar sapphi-red commented on July 4, 2024

Ah, that's true.

If rollup goes with the latter way (= track which modules have side effects), Vite would need to inject a dummy statement that has side effects and remove that later in renderChunk. So it'd be nice if there's a way to opt-in per module even with the latter way.


Maybe starting with an new option that opt-in the behavior is good. Then, I guess we can know how much the number of chunks will increase. Also we can try if experimentalMinChunkSize can eliminate the increase.

from rollup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.