es6-module-loader

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

£可爱£侵袭症+ 提交于 2020-01-13 12:03:06
问题 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

Module.exports and es6 Import

ぃ、小莉子 提交于 2020-01-11 19:58:27
问题 React with babel. I have this confusion with imports and module.exports. I assume babel when converting the ES6 code to ES5 converts the imports and exports to require and module.exports respectively. If i export a function from one module and import the function in another module, the code executes fine. But if i export the function with module.exports and import using "import" the error is thrown at runtime saying it is not a function. I cooked up an example. // Tiger.js function Tiger() {

Module.exports and es6 Import

风格不统一 提交于 2020-01-11 19:58:05
问题 React with babel. I have this confusion with imports and module.exports. I assume babel when converting the ES6 code to ES5 converts the imports and exports to require and module.exports respectively. If i export a function from one module and import the function in another module, the code executes fine. But if i export the function with module.exports and import using "import" the error is thrown at runtime saying it is not a function. I cooked up an example. // Tiger.js function Tiger() {

JavaScript - How to make ES6 imports work in browser?

断了今生、忘了曾经 提交于 2020-01-11 06:07:26
问题 I'm starting a new project in which I'd like to have ES6 style modules, however, I can't get it to run in a browser. I'm using Chrome. I isolated the issue into very few lines of code. Here are my 2 TypeScript files: app.ts import { Component } from './component'; var component: Component = new Component(); component.ts export class Component { } Here's how they compile to JavaScript: app.js import { Component } from './component'; var component = new Component(); component.js export class

Importing lodash into angular2 + typescript application

半城伤御伤魂 提交于 2020-01-05 05:57:27
问题 I am having a hard time trying to get the lodash modules imported. I've setup my project using npm+gulp, and keep hitting the same wall. I've tried the regular lodash, but also lodash-es. The lodash npm package: (has an index.js file in the package root folder) import * as _ from 'lodash'; Results in: error TS2307: Cannot find module 'lodash'. The lodash-es npm package: (has a defaut export in lodash.js i the package root folder) import * as _ from 'lodash-es/lodash'; Results in: error TS2307

Importing lodash into angular2 + typescript application

巧了我就是萌 提交于 2020-01-05 05:57:16
问题 I am having a hard time trying to get the lodash modules imported. I've setup my project using npm+gulp, and keep hitting the same wall. I've tried the regular lodash, but also lodash-es. The lodash npm package: (has an index.js file in the package root folder) import * as _ from 'lodash'; Results in: error TS2307: Cannot find module 'lodash'. The lodash-es npm package: (has a defaut export in lodash.js i the package root folder) import * as _ from 'lodash-es/lodash'; Results in: error TS2307

es6 import as a read only view understanding

无人久伴 提交于 2020-01-01 09:24:22
问题 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

Webpack 4.36.1 not working with html-webpack-externals-plugin

与世无争的帅哥 提交于 2019-12-24 07:41:04
问题 I am migrating a library from webpack 1 to webpack 4. Which is to be consumed by another application with webpack 3. My libraries index.js looks like this, import * as config from './config'; export default class Helper{ constructor(options) { this.configurePaths({assetPath: options.assetPath || ''}); } configurePaths(configuration) { config.assetPath = configuration.assetPath || config.assetPath; } ... } Webpack of the library has: const path = require('path'); const env = require('yargs')

How to achieve inheritance in ES6 with “webpack module bundler”?

你。 提交于 2019-12-24 01:25:34
问题 Unable to achieve inheritance in ES6 classes, when import two file using webpack module bundler with babel My directory structure looks like webpack.config.js looks like module.exports = { entry: "./entry.js", output: { path: __dirname, filename: "bundle.js" }, module: { loaders: [ { loader: "babel-loader", // Only run `.js` and `.jsx` files through Babel test: /\.jsx?$/, // Options to configure babel with query: { presets: ['es2015'], } }, ] } }; Entry.js looks like import './content.js';

Randomly failing polymer web component test

不想你离开。 提交于 2019-12-23 15:36:10
问题 Yet another attempt to marry Polymer with ES6 classes. And it almost works except a wct test failing randomly on a polymer component with an imported es6 class (by systemjs). As far as I understand, this happens because the script, containing class definition, gets loaded after mocha executed the test. The polymer component consists of two parts - html and javascript (to compile latter to es5), html: <dom-module id="my-test"> <template>hello</template> <script> System.import('elements/my-test