Comments (9)
Yeah, definitely. I'd probably use it if that were in place. I doubt performance would be an issue in my case and am not too concerned about it on IE or old Android Browser anyway - just so long as it works.
from monolite.
I would add a note about requiring Proxy support. Sadly I can't use it. :(
from monolite.
@spacejack This is something that I'm already aware, but did not take time to fix: You can check #2 for more information.
I'm currently working on Electron applications, so I don't have this kind of issue right now, but as I will have soon to target browsers again, I need to find a solution for that.
What kind of build process do you use? This should be easily fixed, but my real problem is to find the correct tool to use.
TypeScript
Using TypeScript compiler would need to create a custom transpiler using TypeScript API, which would do the transformation before calling the real TypeScript compiler.
The goal of this transpiler would only be to resolve the Accessor Function statically.
It would mean another build process step, as it's currently not possible to plug custom AST transform functions in the TypeScript compiler.
Another solution would be to create a wrapper around the TypeScript compiler, and call this custom compiler for Production. But it's kinda strange to create a wrapper of TSC for just one little functionality.
Babel
Babel provides a simple way to plug custom transform functions, but it would mean to use both TypeScript AND Babel during build.
I still did not decide which solution I would choose.
What kind of build process did you setup? Also, do you use Webpack or Gulp? What environments are you targeting?
from monolite.
I'm using pretty minimalist tooling - so browserify/tsify. I'm not sure I'd add additional tooling just for this unless I was going to make heavy use of it. Possibly on a future project though.
Babel seems like a reasonable approach, though I haven't spent a lot of time looking at how to add Babel to my pipeline.
from monolite.
Just a little question about what your target is:
If you target browsers in general, and performance in old browsers (those that do not support ES2015) is not a real problem, there's a way to add support (in a dirty way).
Today I use a Proxy to convert Accessor Function to Accessors Chain, but this could fall back on a Regex-based resolution if there's no support for Proxy.
Something like:
const getAccessorChainWithoutProxy = (accessorFn: Function) =>
accessorFunction.toString().match(/someregexhere/).andSomeAdditionalTransform()
It's not a clean way to achieve this, and would not be really performing, but has the benefit to work out of the box, even during development, until the Babel plugin is available (and even after).
Maybe even it could be cached if there's a way to detect accessorFunction identity equality.
Would this be something useful for you?
from monolite.
I will add support for ES5 this week-end.
from monolite.
Just for info, I started the Babel plugin:
https://github.com/kube/babel-plugin-monolite
You can already install it using NPM
npm install --save-dev babel-plugin-monolite
It's still in really early stage, but I would love any feedback on it.
from monolite.
I have a slightly unrelated question - is the usage of proxies a performance hazard for a Node JS backend? I'm getting away from ImmutableJS and trying to find a safe spot to land.
Also, I believe Typescript is getting to the place where plugins will be possible pretty soon.
from monolite.
@bryanerayner
Just did a little Google search, and the first article seems to say that performance is not heavily impacted by usage of Proxy:
http://dealwithjs.io/es6-features-10-use-cases-for-proxy/#performance
But one thing is that Proxies and Reflection in general make harder JIT optimisation.
I did not make a benchmark myself at the moment, but it's something I'm gonna need to do soon.
If you have a real need of performance, I suggest you to use the Babel Monolite Plugin. It's still early stage, but it will permit to resolve accessors statically.
Let me know if you start using it, I would really like to have feedback on it. (And enhance it too)
from monolite.
Related Issues (20)
- Can use an array as root object? HOT 1
- Setup TSLint
- Use Jest instead of Mocha HOT 1
- Add RegEx-based getAccessorChain to support ES5 HOT 3
- add support for ES6 Map's
- Flow types not type validating correctly HOT 2
- Possibly null values in the input data? HOT 6
- Missing null guard in deepEqual HOT 5
- deepEqual usage of Object.getOwnPropertyNames
- Zapier Test
- Monolite with react, redux and array HOT 2
- Possibility for IE11 support? HOT 5
- Bundle Babel Plugin in Monolite HOT 1
- Add support for collection mapping
- Babel plugin: nested set not transformed
- node/electron target HOT 2
- Type inference fails with optional state parameters
- ReferenceError: window is not defined in node_modules/monolite/lib/monolite/index.js:1 HOT 7
- Idea
- Add merge function
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 monolite.