Comments (11)
My only hesitation has been the build step requirement. I agree with all your points though, and think I should "see the light" as so much of the modern web has moved to the babel approach. Getting new contributors is a huge thing for the project right now, as I'd like it to include the voices of others.
Currently I only use webpack to build the bundles, which is something that only happens on release, and is not a dependency of setting up a development environment. You don't need to start a server, npm install anything, have a file watcher etc. I really like the simplicity of that.
That said new es6 features are great and I can't ignore them, so migrating to them sooner than later is a good idea. It will definitely happen. It's on the roadmap, but it's not the current top priority.
If there's a way you think I could better organize samsara to support the es6/webpack/babel developer workflow, please let me know. For one, I could provide a CommonJS version for each file, and not just the samsara.js bundle.
from samsara.
I am not very familiar with Samsara and its structure, nor with how developers would benefit from importing only a few modules and not the whole library, but the ES2015 syntax for modules allows the importation of specific object inside modules:
import { Surface } from 'samsara'
Is this what you mean?
Regarding the implications of moving to ES2015: it would indeed probably mean adding a 'tasks' folder, with the webpack config file and a basic express server. But in my opinion, it isn't too bad of a requirement / feature. The dev workflow with webpack, especially when combined with hot reloading and eslint, is really nice and productive. I have set up quite a few projects with webpack / babel lately, so I could help you moving forward with it if you want.
from samsara.
I agree with vkammerer.
Also from a development perspective, it's not hard to wire up babeljs to transpile in the browser. So no build step.
from samsara.
@culyun could you link me to a place that describes the process you mention? After the node removal API is set (sometime this week), the next priority will be migrating to es6
from samsara.
systemjs can use babeljs to transpile on the fly.
The magic is setup via a config script that is loaded in index.html immediately after systemjs.
Here's a systemjs config I'm fiddling with at the moment
`
System.config({
baseURL: '.',
transpiler: 'babel',
babelOptions: {
'optional': [
'runtime',
'optimisation.modules.system'
]
},
map: {
'babel': 'node_modules/babel-core/browser.js',
'fastclick': 'node_modules/fastclick/lib/fastclick.js',
'image': 'node_modules/system-image/image.js',
'j2c': 'node_modules/j2c/dist/j2c.global.min.js',
'lodash': 'node_modules/lodash.js',
'mithril-infinite': 'node_modules/mithril-infinite/lib/mithril-infinite.js',
'mithril': 'node_modules/mithril/mithril.min.js',
'mmsvg': 'node_modules/mmsvg.js',
'samsara': 'node_modules/samsarajs/samsara',
'text': 'node_modules/system-text/text.js',
'verge': 'node_modules/verge/verge.min.js'
},
meta: {
'app/*.svg': {
loader: 'image'
}
}
});
System.config({
packages: {
// meaning [baseURL]/local/package when no other rules are present
// path is normalized using map and paths configuration
'image': {
defaultExtension: 'false'
},
'samsara': {
defaultExtension: 'js'
},
},
});
`
from samsara.
Not necessary to migrate the entire source to es6 because there's no benefit and gives less speed transpiled. However, the biggest benefit is migrate to using the import/export es6 module syntax for tree-shaking to shave unused exports. I was a big user of the Famous library. Hope you're continuing that path with solid devs. You guys implementing repulsion physics/gravity fields? Has so much use!
from samsara.
I wouldn't be so sure about the less speed point. From what I've read babeljs uses things like Object.defineProperty. This will actually speed up code in some instances since it allows the runtime to replace slow dictionary-based property lookups with pointer dereferencing.
from samsara.
The transpilation of calling super() in es6 has up to 16x degraded speed in some browsers like Firefox I think as well as some other things that don't match native by 2-4x. It won't matter in the future but as of now at initialization time you take the biggest hit using classes. There's are charts for this floating around. It's why the Famous team decided to stick with es5 because when building the foundation of an engine you want to squeeze every bit of performance you can from widely used functionality.
from samsara.
Here's a chart http://kpdecker.github.io/six-speed/
This will be looked at closely when the es6 migration happens
from samsara.
Sorry all, looks like I was a bit quick off the mark.
Eating humble pie.. yum yum ;-) <<
I remember reading a bit of guff from Andreas Rossberg where he was advocating Object.createproperty in the context of runtime optimization. Looks like I took 1 +1 and came up with 42.
Thanks for the links!
from samsara.
just to let others now, you can already use it in your es6 application like this
// first I added it via: npm install --save samsarajs
import * as Samsara from 'samsarajs';
// use it directly
let block = new Samsara.DOM.Surface({...});
// or via helper - needs to be defined on every import
const Surface = Samsara.DOM.Surface;
const View = Samsara.Core.View;
let block = new Surface({...});
doing it like this you will always use the full samsara so it is probably not as perfect as it should be - anyway still better then without es6 :)
from samsara.
Related Issues (20)
- Not responsive to split view on iOS HOT 4
- [Question] Min & Max Opacity HOT 8
- EventEmitter incorrectly binds owner on `once`
- EventHandler never turns off upstream events HOT 1
- [Question] will-change size HOT 2
- [Question] How to populate the div within a Surface using Javascript HOT 8
- React Native HOT 3
- Manipulating StyleSheets instead of inline styles HOT 4
- Views added to context after context has been mounted need a resize event to be render HOT 2
- Question : Can Samsara leverage the capabilities of shadow-dom ?? HOT 1
- FYI - FastDom HOT 1
- SequentialLayout can't be align to bottom HOT 7
- Scrollview.goTo(x) goes bananas on iOS HOT 6
- Paginated Scrollview can't handle resize/orientation change HOT 1
- Scrollview bug IE11
- set/toggle/remove classes bug
- Awesome work HOT 2
- Non-nested CSS3D seems to be getting bad in Chrome. HOT 5
- Is Samsara viable when implementing animations designed in Framer? HOT 1
- misalignment with Cube demo HOT 3
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 samsara.