Is it possible to pass options to ES6 imports?  How do you translate this:  var x = require('module')(someoptions);   to  ES6?...
I have some code:  baseTypes.ts  export namespace Living.Things {   export class Animal {     move() { /* ... */ }   }   export class Plant {     photosynthesize() { /* ... */ }   } }   dog.ts  import b = require('./baseTypes');  export nam...
I'm using ECMAScript6 modules. What is the correct way to export/import multiple methods from a module from the options below?  Single class of static methods:  //------ myClass.js ------  export default class myClass {    static myMethod1() {...
I need to do something like:  if (condition) {     import something from 'something'; } // ... if (something) {     something.doStuff(); }   The above code does not compile; it throws SyntaxError: ... 'import' and 'export' m...
What is the different between two declarations of a module in JavaScript? One has parentheses around the function and other one doesn't?  One article says that     Notice the () around the anonymous function.  This is required by the   language...
Is there a way to define a module that "dynamically" load other modules in RequireJS? If yes, how the optimizer (r.js) understands how/when a module has to be included?   For example, let dynModules a module which defines name/path pairs:...
While looking at code on github, I found the following:  (function() {  }).call(this);   This is clearly a self invoking anonymous function. But why is it written this way? I'm used to seeing the canonical variant (function() {})().  Is there a...
I've seen public exports of ES6 modules done in both of the following ways:  // method 1 export var getAnswer = function () { return 'forty two'; };  // method 2 export default function () { return 'forty two'; };    Are both of...
I know that global variables are bad.  But if I am using node's module "util" in 40 files in my framework, isn't it better to just declare it as a global variable like:  util = require('util');   in the index.js file instead...
I'm trying to create a module that exports multiple ES6 classes. Let's say I have the following directory structure:  my/ ??? module/     ??? Foo.js     ??? Bar.js     ??? index.js   Foo.js and Bar.js each export a default ES6 class:  // Fo...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.