Comments (4)
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.
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.
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.
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)
- Wrong pretty-printing of JS tree that *starts* with an object lit
- Error while running `sbt`: bad constant pool index: 0 at pos: 48445 using Java version 21.0.1 HOT 3
- Race condition in AnalyzerRun.WorkTracker during `allowComplete()`.
- scala.util.Try does not catch `ClassCastException` HOT 1
- ConflictingTopLevelExport error reports incomplete error message
- linkerJS2_13/test spuriously fails too often on the CI (Killed)
- Locals stored as private symbols on non-native JS types breaks JS semantics HOT 3
- Improve GCC/ Minifier documentation HOT 10
- Analyzer never marks Interfaces with isAnySubclassInstantiated.
- Formatting a byte as a hexadecimal integer produces an incorrect result for a negative value HOT 4
- Excess modules are generated HOT 11
- Synthesized reflective proxies have wrong This type for hijacked classes
- FewestModules OOMs with dynamic dependencies HOT 5
- Scala 2.13's `scala.util.RandomTest.testShuffle()` crashes V8 on WebAssembly HOT 2
- Make Scala.js Wasm backend suitable for standalone Wasm VMs HOT 2
- [Wasm] Add option to use `js-string-builtins` for using JS string to implement string
- 1.16.0 does not work `sbt run` with Scala 2.13.12 or lower versions due to SIP-51
- Allow variable method name on Selectable.selectDynamic / Selectable.applyDynamic when invoked within macro implementation HOT 11
- Allow for linktime conditional branching HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-js.