babel/babelify: Browserify transform for Babel Why aren’t files in node_modules being transformed with Browserify? https://github.com/babel/babelify#why-arent-files-in-node_modules-being-transformed This is the default browserify behavior. A possible solution is to add: { “browserify”: { “transform”: [“babelify”] } } to the root of all your modules package.json that you want to be transformed. If you’d like to specify options then…
Read MoreRead Setting up ES6 | Leanpub What are the ES6 modules and CommonJS modules? This chapter examines how Babel ensures that code it transpiles interoperates properly with normal CommonJS modules. Consult chapter “Modules” in “Exploring ES6” for more information on ES6 modules. 7.1 ES6 modules vs. CommonJS modules 7.1.1 ECMAScript 6 modules Default export (single…
Read MoreES Modules: Using Named Exports as the Default Export https://medium.com/@timoxley/named-exports-as-the-default-export-api-670b1b554f65 // in `cow.js` : export function speak () { return ‘moo’ } To use a named export, we can import it directly into our code: // in `import-named.js` : import { speak } from ‘./cow’; speak() // => ‘moo’ Aliasing named imports You can assign…
Read MoreUsing Babel 6 + grunt to work with ES6 – how to transform require statements? https://stackoverflow.com/questions/41067220/using-babel-grunt-to-work-with-es6-how-to-transform-require-statements Browserify will handle the import bindings for the ES6 modules. Also a package named babelify will help to handle your babel browserify transform. The following seems to work well: Use babel-cli instead of babel. Step 1. It’s worth noting…
Read Morehttps://stackoverflow.com/questions/40294870/module-exports-vs-export-default-in-node-js-and-es6 module.exports vs. export default in Node.js and ES6 ES6 default exports are actually also named exports, except that default is a “reserved” name and there is special syntax support for it. Lets have a look how Babel compiles named and default exports: // input export const foo = 42; export default 21; // output…
Read MoreClient-side Aangularjs Install: bower install angular-paginate-anything –save Angularjs: app.js angular.module(‘myModule’, [‘bgf.paginateAnything’]); blog.controller.js [js] class BlogCtrl { constructor(Auth, Blog, $state, $stateParams, $http, $scope, $location, socket) { this.errors = {}; this.success = {}; this.submitted = false; this.Auth = Auth; this.Blog = Blog; this.$state = $state; this.$stateParams = $stateParams; this.blogs = []; $scope.url = ‘/api/blogs’; $scope.perPage = parseInt($location.search().perPage,…
Read MoreUpdate: var comment = blog.comments.id(comment_id); comment.author = ‘Bruce Wayne’; blog.save(function (err) { // emmbeded comment with author updated }); Delete: Blog.findByIdAndUpdateAsync(blogId, { $pull: { comments: {_id: commentId}} }) .then(blog => { res.status(200).json(‘Comment is deleted successfully.’); }) .catch(err => { console.error(err); res.status(500).json(err.message || err); });
Read MoreInstall Babel 6 related packages: npm install –save-dev babel-register npm install –save-dev babel-plugin-add-module-exports npm uninstall –save-dev babel-core npm install –save-dev babel-core npm install babel-preset-es2015 Create .babelrc file: vi .babelrc { “presets”: [“es2015”], “plugins”: [“babel-plugin-add-module-exports”] } Chanage server/index.js file: vi server/index.js if (env === ‘development’ || env === ‘test’) { // Register the Babel require hook…
Read Moreclass Agent { static get CIRCLE() { return 1; } static get SQUARE() { return 2; } } console.log(Agent.CIRCLE); // 1 class Shape { } Shape.CIRCLE = 1; Shape.SQUARE = 2; console.log(Shape.CIRCLE); // 1 class MyClass { static get MY_CONST() { delete MyClass.MY_CONST; return (MyClass.MY_CONST = ‘string’); } static set MY_CONST(value) { delete MyClass.MY_CONST; MyClass.MY_CONST…
Read More