Giter Club home page Giter Club logo

Comments (4)

gzm0 avatar gzm0 commented on June 13, 2024

I can see how this might be a problem even with a full blown bundler: The bundler will not make the distinction between internal and public modules, as such, it might leave exports around unnecessarily.

@scf37 could you actually observe unnecessary export statements in bundled output (I'm not sure I'd count Uglfy as a bundler)?

Scala.js does not have the goal to generate shipping ready JS code. It is expected that a downstream bundler is run.

More specifically: Scala.js does make no attempt to generate optimal modules. It merely generates modules with sufficiently granular structure so general-purpose JS bundlers can take advantage of it. But it is expected that the module structure is still changed / optimized after Scala.js is run.

from scala-js.

scf37 avatar scf37 commented on June 13, 2024

could you actually observe unnecessary export statements

Yep. AFAIK GCC simple mode run independently on every file with --assume_function_wrapper still produces the best results. Writing simple script to analyze dependencies and comment out unused exports decreases output module size significantly (for simple scalajs project, 306K -> 217K after GCC).

No big deal to write such transformer btw but I guess it could be easy fix on your side.

from scala-js.

gzm0 avatar gzm0 commented on June 13, 2024

AFAIK GCC simple mode run independently

Ah, yes. That's expected. I meant if you observe unnecessary exports if you run a bundler that optimizes the whole program / all the modules.

it could be easy fix on your side.

Not really :-/ Basically, when generating, say a function, in a module, we do not (trivially) have tracking information of whether this function is only used by this module (no export) or also other modules, (must export). Tracking this comes at a cost, especially in an incremental scenario where this information can change non-locally (another module started using it, so now it must be exported, even though it didn't change).

from scala-js.

gzm0 avatar gzm0 commented on June 13, 2024

I have checked that vite (when set-up like in the tutorial) is able to fully remove all the exports when bundling.

Therefore and in combination with #4977 (comment), I'm going to close this as-designed.

from scala-js.

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.