es6-module-loader

How to correctly use ES6 “export default” with CommonJS “require”?

吃可爱长大的小学妹 提交于 2019-11-26 16:22:58
问题 I've been working through Webpack tutorial. In one of the sections, it gives the code example that contains one line of essence to this question: export default class Button { /* class code here */ } In the next section of said tutorial, titled "Code splitting", the class defined above is loaded on demand, like this: require.ensure([], () => { const Button = require("./Components/Button"); const button = new Button("google.com"); // ... }); Unfortunately, this code throws an exception:

How to fix this ES6 module circular dependency?

你。 提交于 2019-11-26 15:31:59
问题 EDIT: for more background, also see the discussion on ES Discuss. I have three modules A , B , and C . A and B import the default export from module C , and module C imports the default from both A and B . However, module C does not depend on the values imported from A and B during module evaluation, only at runtime at some point after all three modules have been evaluated. Modules A and B do depend on the value imported from C during their module evaluation. The code looks something like

What is the defined execution order of ES6 imports?

早过忘川 提交于 2019-11-26 14:07:56
问题 I've tried searching the internet for the execution order of imported modules. For instance, let's say I have the following code: import "one" import "two" console.log("three"); Where one.js and two.js are defined as follows: // one.js console.log("one"); // two.js console.log("two"); Is the console output guaranteed to be: one two three Or is it undefined? 回答1: Imported ES6 modules are executed asynchronously . However, all imports are executed prior to the script doing the importing. This

Which browsers support import and export syntax for ECMAScript 6?

£可爱£侵袭症+ 提交于 2019-11-26 13:37:46
I am currently writing a web application using the MEAN Stack, and am attempting to write code in ECMAScript 6 JavaScript; however, I am getting errors in both Chrome and Firefox when using import and export syntax. Are there currently any browsers that fully support ECMAScript 6? Please note: I am not asking when ECMAScript 6 will be supported by browsers. I'm asking which browsers support ECMAScript 6 import and export syntax. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Features_not_yet_supported_by_Firefox Chrome and Firefox

“You may need an appropriate loader to handle this file type” with Webpack and Babel

 ̄綄美尐妖づ 提交于 2019-11-26 13:00:01
I am trying to use Webpack with Babel to compile ES6 assets, but I am getting the following error message: You may need an appropriate loader to handle this file type. | import React from 'react'; | /* | import { render } from 'react-dom' Here is what my Webpack config looks like: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './index', output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/dist/' }, module: { loaders: [ { test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ } ] } } Here is the middleware step

ES6: import module from URL

让人想犯罪 __ 提交于 2019-11-26 12:58:31
问题 Is it possible to import javascript module from external url in ES6? I tried (using babel-node): import mymodule from \'http://...mysite.../myscript.js\'; // Error: Cannot find module \'http://...mysite.../myscript.js\' 回答1: 2018 Update: The module loader spec is now a part of the ES Spec - what you are describing is allowed and possible with <script type="module"> in browsers and with a custom --loader with Node.js as well as with Deno if you're into that. The module loader spec and the

Which browsers support import and export syntax for ECMAScript 6?

删除回忆录丶 提交于 2019-11-26 03:42:00
问题 I am currently writing a web application using the MEAN Stack, and am attempting to write code in ECMAScript 6 JavaScript; however, I am getting errors in both Chrome and Firefox when using import and export syntax. Are there currently any browsers that fully support ECMAScript 6? Please note: I am not asking when ECMAScript 6 will be supported by browsers. I\'m asking which browsers support ECMAScript 6 import and export syntax. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/New

Importing lodash into angular2 + typescript application

人走茶凉 提交于 2019-11-26 01:37:14
问题 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: