Comments (13)
I'm not too big a fan of this idea, as it can cause all kinds of issues with circular dependencies between classes. Also I must determine how to do it.
I won't close it as a wontfix, but it needs to be reevaluated again after support for the require() API has been added as I forsee major clashes with that feature.
from saltarellecompiler.
Ok, how would you suggest going about having separate files without using many projects?
from saltarellecompiler.
Don't. Does it hurt? It can actually help performance because all your application pages use the same JS so once it is downloaded, the cached response can be used on all pages.
from saltarellecompiler.
I imagine though (although I don't know yet) that this feature will be very similar to a feature that could allow code from one import library to specify different module names for require()
calls. As I said, I think this will be implemented in the future but I do not want to implement a feature that will cause module loading implementation to be messy.
from saltarellecompiler.
If I am using knockoutjs, i need to only bind once with my vm in the onDocReady. if I have all of them in one file, they would all bind. I suppose I could use Ids, but this doesn't look as neat and I would have to add ids in my view.
from saltarellecompiler.
I don't understand. I though that the thing that caused Knockout to do it stuff was when you call
ko.applyBindings(model);
Can't you have all the scripts in the same file and apply different models on different pages? Perhaps even adding the call to applyBindings() inside a <script>
directly on the HTML page?
from saltarellecompiler.
Oh yes! A face-palm moment :(
I am still relatively new to JS and I never liked it much (that's why I am using Saltarelle :)
But, that was a daft mistake ...
from saltarellecompiler.
I second @mattleibow in this request. This feature is very important.
A large single page application can't usually be packaged in a single file.
It's not just a matter of organization, caching or download speed. But also it may be a matter of security.
For example, the SPA I'm currently working on (and willing to port to Saltarelle), is composed from multiple modules and each module is in a separate file.
The main module loads the other modules when required. Some of these modules are protected by server side authorization.
So, I don't want all my modules in a single file and accessed by unprivileged users.
As for your fears about circular dependencies between classes, you can just add the feature to the compiler and let the responsibility of its usage on the side of developers.
If a developer chose to separate his library into multiple files, it should be his responsibility to reference them in the proper order.
from saltarellecompiler.
You don't need to package the application in a single file because you don't need to have all your code in a single project. If your project is composed of multiple modules, it makes sense to me to have them in different projects.
As a security advice, hiding the Javascript for certain features is not secure. You should always prevent the things that the Javascript might be doing (eg. action methods), preventing unauthorized people to access the script seems just like security through obscurity to me.
from saltarellecompiler.
Of course having the modules in different projects is an option, but I still didn't make my mind on how to achieve this, as I have some cross references between modules, and I don't like cross references between VS projects.
I do all my security on the server side. The system can't be hacked if just a secured JS module is exposed. But such exposure may give the hacker a starting point to plan to hack the system.
from saltarellecompiler.
What do you mean with cross references? If you mean normal references between projects, I'm afraid that's something you will need to accept someday anyway.
Anyway, this is likely to be implemented in the future but don't expect it too soon.
from saltarellecompiler.
Currently, in my JS project, I have for example, a Main module referencing a Security module, and the Security module references Main too.
I fear that if I map this to C# I get the same cross references between projects. But still I didn't start working on this yet. Maybe this pattern won't occur in C#.
This issue is not crucial for me. It's acceptable to package the whole project in a single file as far this feature will be implemented one day.
Also, after I pass my current bottle neck, I'll download the project code to start doing something other than complaining about bugs and missing features.
By the way, what the word Saltarelle mean? a music instrument?
from saltarellecompiler.
We use these kinds of problems with interfaces.
Saltarelle is a song by Camille Saint-Saëns
from saltarellecompiler.
Related Issues (20)
- [2.6.2] Canceled tasks should throw TaskCanceledException instead of InvalidOperationException HOT 3
- Status? HOT 1
- [2.6.2] Combining async, finally and IList/IEnumerable results in an incorrect execution workflow HOT 3
- Bridge.NET Acquires Saltarelle HOT 54
- Boolean XORs generate incorrect result HOT 1
- Non-serializable properties for serializable types HOT 1
- int.Parse() gets translated to parseInt(), which isn't precise HOT 4
- Bug in inheritance? HOT 3
- INTERNAL ERROR: ResolveResult ConversionResolveResult HOT 6
- Add support for InternalsVisibleTo attribute HOT 3
- [2.7.0] Asynchronous tasks swallow exceptions
- Minifier incorrectly minifies '+ ++' into '+++'
- When using [NamedValuesAttribute] on an enum, that enum's values are not compiled correctly when used as default parameters HOT 3
- If the data exict HOT 1
- Saltarelle.Runtime HOT 1
- Saltarelle rewrites Mixing expression $.expr[':'] to $["expr[':']"] HOT 1
- Provide toString override for Exception class, otherwise uncaught exceptions will end up logged as [object Object]
- ss_Int32.tryParse returns 0 when value can't be parsed (when input does not match regexp)
- Dictionary issue on Chrome HOT 3
- Saltarelle.Compiler 2.7.0 - INTERNAL ERROR: System.TypeLoadException
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 saltarellecompiler.