Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Utkarsh Sinha
    babeljs.io down - do I need that for using trine?
    Utkarsh Sinha
    okay - it isn't down.
    Just an ES6 modules question
    I use Babel and browserify for modules, but I would like to change all "require" to "import"
    So, I have this require inside the code:
    var test = require('./test');
    And inside test.js I have this:
    (function() {
    ...some code here...
    class myClass {
    ...more code here...
        module.exports = new myClass();
    I changed the module.exports to export default new myClass();
    and the require to import('./test');
    But it does not work. Do I need some kind of polyfill?
    Jaeho Lee
    @af7 Babel gitter room would be more appropriate place to ask, but how does it fail?
    I don't think you need IIFE block to wrap after all
    Thx @sairion
    Gorm Casper

    What's the easiest way to mess around with this library? If I want to be able to have a file like this:

    import map from 'trine/src/iterable/map'; // require is fine too

    What's the compile step? ... Or am I doing it completely wrong?

    Gaetano Checinski
    you could use babel-node --stage 0 --optional runtime myfile
    babel-runtime and babel-node must be installed in this case
    Gorm Casper
    Odd error: ReferenceError: The version of babel-runtime of undefined that you have installed does not match the babel version of 5.0.8 -- Pretty sure I just installed it babel-runtime@5.5.8
    Thanks though :)
    Jussi Kalliokoski
    if you want to just mess around, I recommend creating a new directory, npm init there followed by npm i --save babel babel-runtime trine , then ./node_modules/.bin/babel-node --stage 0 myfile (--optional runtime shouldn't be required)
    I'm hoping to add a Trine-enabled Babel REPL to the website soon as well - that should enable "just messing around" type of trying out the library. :)
    btw, you should also import { map } from 'trine/iterable/map'; instead - trine exports things as named exports whereas the import foo from 'foo' syntax imports the default export of the 'foo' module under the identifier foo.
    Filip Stachura
    Hi guys! Is there any way to use trine in TypeScript?
    Jussi Kalliokoski
    @filipstachura Hi Filip! Let's try and be as inclusive as possible and use gender neutral terms. :) Currently Trine doesn't expose the type definitions because TS / flow are lacking the possibility to annotate this other than automatically inside class declarations. However, with some tinkering you might be able to get Trine to work with TS, albeit AFAIK TS doesn't support the function bind syntax so the API will be quite awkward ( "babbca"::sortAlphabetically()::uniq()::head(2) vs head.call(uniq.call(sortAlphabetically.call("babbca")), 2) ). Maybe propose the function bind syntax to be added to TypeScript? ;)
    Barney Carroll
    @jussi-kalliokoski just dropping in to say Trine has been an utter revelation for me