Comments (10)
Hello !
Indeed, to support async
functions, you can add stage-0
or stage-1
or modern-browsers-stage-1
.
It doesn't compile everything the same as es2015
, but safari 9 doesn't supports classes, so it does transform classes. You can see all features supported in the compatibility table. I can't wait for safari 10 ! =)
You can also choose to support only latest firefox and chrome.
from babel-preset-modern-browsers.
Ah, for sure. The problem is I'm making a library (as opposed to an app), so I guess I need to compile the classes then since I want it to be usable everywhere.
Hmmm, but I am using my library in some apps. Maybe I can just use the original source, and compile specifically in each app for each target. It would mean I have to make Webpack not ignore the node_modules folder. Also, Meteor by default doesn't touch the node_modules folder and I'm not sure how to make Meteor compile things (it uses Babel) from node_modules.
But yeah, I can't wait for Safari 10 either. It's going to have Proxy too, which will allow some interesting things!
from babel-preset-modern-browsers.
Turns out I will not be using ES6 classes any more anyways (for now, because super
is static, and constructors are not callable), and I am making a tool for multiple inheritance where in one implementation that involves method copying it simply breaks the super
keyword at runtime unless using eval
which loses the scope where the original method-to-be-copied was defined, and in the other implementation super
works just fine but I need to have callable constructors which ES6 classes don't provide (and Proxy will make the implementation cleaner once Safari 10 is out).
The idea stemmed from my desire to do something like this:
import SomeClass from './SomeClass'
import OtherClass from './OtherClass'
class Foo extends multiple(SomeClass, OtherClass) {
// ...
}
where SomeClass
and OtherClass
may have two completely separate prototype chains, or may simply be non-derived classes as in
export default
class SomeClass {
// ..
}
export default
class OtherClass {
// ..
}
from babel-preset-modern-browsers.
You can also consider building your library for several targets with several main, allowing you to choose with webpack which one you want in the end. Faster than rebuilding all node_modules with babel !
from babel-preset-modern-browsers.
Him, I guess that would work but also multiply the size of the published package by the number of targets. Well, NPM and GitHub are free for open source projects, so I guess they are okay with that.
I can make a separate repo just for the releases on GitHub I suppose.
Sounds like a plan! 👍
from babel-preset-modern-browsers.
@christophehurpeau When someone does
import SomeClass from 'my-library/path/to/SomeClass'
, how does that import for the proper target?
I know how to configure it in Webpack and Browserify, but Meteor and NPM both just look at imports relative to node_modules/my-library
.
I feel like suggesting
import SomeClass from 'my-library/<target>/path/to/SomeClass'
where <target>
is replaced with the actual target as in
import SomeClass from 'my-library/safari/path/to/SomeClass'
would be problematic because then the code relies on the <target>
and is not portable across targets without having to find/replace all occurrences of <target>
.
from babel-preset-modern-browsers.
I advise you to do single-file packages when possible. If not, you can either export everything in the main file, or create multiple entry-points and configure webpack to go look in the right directory.
from babel-preset-modern-browsers.
A single-file package is not really always feasible, and may not help in tree-shaking. Sometimes classes don't make sense to be shipped in separate packages because they aren't intended to be standalone classes, and having them in different files of the same package helps keep code organized.
I guess really I should just write for my lowest common denominator target. I think modern-browsers and modern-browsers/safari may be that.
How do I read the compatibility table? Do I assume that modern-browsers compiles anything that says "No" in the table?
from babel-preset-modern-browsers.
Yes: "No" or the version is not the stable version
from babel-preset-modern-browsers.
Gotcha! Thanks! Would be nice if that was more apparent somehow.
from babel-preset-modern-browsers.
Related Issues (10)
- Similar to https://github.com/askmatey/babel-preset-modern HOT 5
- Action Required: Fix Renovate Configuration
- object-rest import failing in webpack HOT 1
- Missing dependencies HOT 1
- State or add support for iOS HOT 2
- Maintain the changelog HOT 1
- Dependency Dashboard
- can I use it with a stable babel-register? HOT 1
- support babel preset es2016
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 babel-preset-modern-browsers.