es6-module-loader

es6-module default export importing as undefined

那年仲夏 提交于 2019-12-10 13:26:43
问题 I'm not sure what I'm missing here. I'm working on a project using jspm and es6-module-loader. I've got an module defined as follows: import hooks from './hooks'; import api from './api'; import tools from './tools'; const StencilUtils = { hooks: hooks, api: api, tools: tools, }; export {hooks, api, tools}; export default StencilUtils; /* global define */ (function(root) { if (typeof define === 'function' && define.amd) { define(function() { return (root.stencilUtils = StencilUtils); }); }

export / import single class method using ES6 modules?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 02:31:53
问题 Let's say I have a simple class like this in fileA.js : class foo { constructor(x) { this.name = x } fooMethod(x) { return x + 'hello'; } } And I want to import and use fooMethod in fileB.js like this: import { fooMethod } from './fileA'; class bar() { ... barMethod(x) { return fooMethod(x); } } How would I write the export in fileA to achieve this? 回答1: You would have to export it on the prototype. But remember that if you do that you won't call the function in the class/object context:

Proper way to implement jwplayer in react component using webpack (react-starter-kit)

别等时光非礼了梦想. 提交于 2019-12-06 02:30:02
问题 i am making VideoPlayer react component with jwpalyer and i am using webpack es6 for loading module webpack support npm module loading & there is no npm for jwplayer so am trying to include jwplayer.js using es6 import but it giving me error ReferenceError: window is not defined so any one can help me to properly setup jwplayer with webpack import React, { PropTypes, Component } from 'react'; import $ from 'jquery'; import Player from "./lib/jwplayer/jwplayer.js"; import styles from '.

ES6 module's “import” officially compatible with CommonJS and AMD?

早过忘川 提交于 2019-12-05 12:00:19
From this article : https://hacks.mozilla.org/2015/08/es6-in-depth-modules/ It is written that The new standard is designed to interoperate with existing CommonJS and AMD modules. And more precisely All CommonJS and AMD modules are presented to ES6 as having a default export If it is really the case all we'd need is a ES6 polyfill and we wouldn't have to do use anything else. Yet for eg this ES6 Polyfill : https://github.com/ModuleLoader/es6-module-loader doesn't seem to allow loading CommonJS/AMD modules from ES6 but only solutions built on top of it like SystemJS allow it. So the question is

export / import single class method using ES6 modules?

断了今生、忘了曾经 提交于 2019-12-05 03:06:10
Let's say I have a simple class like this in fileA.js : class foo { constructor(x) { this.name = x } fooMethod(x) { return x + 'hello'; } } And I want to import and use fooMethod in fileB.js like this: import { fooMethod } from './fileA'; class bar() { ... barMethod(x) { return fooMethod(x); } } How would I write the export in fileA to achieve this? You would have to export it on the prototype. But remember that if you do that you won't call the function in the class/object context: export foo.prototype. fooMethod However I would recommend you to not to do so. Okay, due to your comment you

Proper way to implement jwplayer in react component using webpack (react-starter-kit)

我只是一个虾纸丫 提交于 2019-12-04 05:29:42
i am making VideoPlayer react component with jwpalyer and i am using webpack es6 for loading module webpack support npm module loading & there is no npm for jwplayer so am trying to include jwplayer.js using es6 import but it giving me error ReferenceError: window is not defined so any one can help me to properly setup jwplayer with webpack import React, { PropTypes, Component } from 'react'; import $ from 'jquery'; import Player from "./lib/jwplayer/jwplayer.js"; import styles from './VideoPayer.css'; import withStyles from '../../decorators/withStyles'; import Link from '../Link';

es6 import as a read only view understanding

孤人 提交于 2019-12-04 04:42:05
There is no detalied explanation of what exactly es6 import and export do under the hood. Someone describe import as an read only view. Check the code below: // lib/counter.js export let counter = 1; export function increment() { counter++; } export function decrement() { counter--; } // src/main.js import * as counter from '../../counter'; console.log(counter.counter); // 1 counter.increment(); console..log(counter.counter); // 2 My question is if two modules import the same counter module and the first module increment the counter, will the second module also see the the counter as

ES6 (EcmaScript 2015) modules: import index.js

社会主义新天地 提交于 2019-12-04 00:03:52
Looking on the internet I'm confused with the special "index.js" module file. Using babelJS + nodeJS or Browserify/Webpack I can import an "index.js" module inside a "libs" directory using import myLib from "./libs" (ie. omitting the /index or /index.js part). Is the "index.js" module resolution (specifying the containing folder) supported by the ES6 (EcmaScript 2015) modules official standard? Or is it just "custom" NodeJS/CommonJS transpiling behaviour? Will it be possible to omit the /index | /index.js part of the import in all browsers as well (when modules will be supported on all

Is it possible to export the result of “import * as” in ES2015?

◇◆丶佛笑我妖孽 提交于 2019-12-03 12:29:10
In ES2015, it's possible to import an entire module as an object whose properties are the module's exports: import * as name from 'module'; I find this to be extraordinarily useful for namespacing and use it all the time. It's also possible to re-export other modules' exports: export { name } from 'module'; // selectively export * from 'other-module'; // indiscriminately Now I'm trying to write a library with namespacing in this style. The intuitive way of collecting everything in the top-level module would be like this: export * as name from 'module'; But that doesn't seem to work; Babel and

Can I use an ES6/2015 module import to set a reference in 'global' scope?

删除回忆录丶 提交于 2019-12-03 03:03:21
问题 I have this situation where I am trying to import an existing library, which I'll call troublesome (using Webpack/Babel FWIW) and it has a global reference to jQuery in it which i am trying to resolve using module syntax. I have successfully imported jquery into the 'local' scope of a module, via: import jQuery from 'jquery' so I tried: import jQuery from 'jquery' import 'troublesome' but perhaps not surprisingly, I get something like jQuery is not a function kicked back from troublesome.js I