es6-module-loader

How to load a local video in React using webpack?

筅森魡賤 提交于 2019-11-27 23:48:05
问题 I can't seem to figure out how to get an html5 video to render in a react app from local files. Literally the only way I've been able to get this to work is like this: <video src="http://www.w3schools.com/html/movie.mp4" controls /> Here's what I've tried 1. Including the path directly <video src={require('path/to/file.mp4')} controls /> which returns an error Module parse failed: /path/to/file.mp4 Line 1: Unexpected token ILLEGAL You may need an appropriate loader to handle this file type. 2

What is the defined execution order of ES6 imports?

你说的曾经没有我的故事 提交于 2019-11-27 20:28:42
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? McMath Imported ES6 modules are executed asynchronously . However, all imports are executed prior to the script doing the importing. This makes ES6 modules different from, for example, Node.js modules or <script> tags without the async

Re-exporting ES6 modules in TS 1.7?

淺唱寂寞╮ 提交于 2019-11-27 17:48:10
问题 I'm getting a bit lost in TS re-exports. Say I create a pair of test modules; test1.ts; export function test1() { return 'test'; } test2.ts; export function test2() { return 'test'; } I believe I should be able to then do something like this; combined.ts; export * from './test1'; export * from './test2'; module.exports = { test1: test1, test2: test2 }; But, no such luck. There seem to be lots of GitHub issues discussing various approaches to this, including an old hack using export import *

Path aliases for imports in WebStorm

最后都变了- 提交于 2019-11-27 17:14:27
I use webpack path aliases for ES6 module loading. E.g. If I define an alias for utils instead of something like import Foo from "../../../utils/foo" , I can do import Foo from "utils/foo" The problem is that once I start using aliases, WebStorm looses track of the import and I'm left with warnings and no auto-completion. Is there a way to instruct WebStorm to use such aliases? [Deprecated answer. Starting since WS2017.2 Webstorm automatically parses and applies Webpack config (see @anstarovoyt comment)] Yes, there is. In fact, Webstorm can't automatically parse and apply Webpack config, but

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

て烟熏妆下的殇ゞ 提交于 2019-11-27 13:56:09
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: Uncaught TypeError: Button is not a function Now, I know that the right way to include ES6 module would be

How to fix this ES6 module circular dependency?

天涯浪子 提交于 2019-11-27 11:20:41
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 this: // --- Module A import C from 'C' class A extends C { // ... } export {A as default} . // ---

How will browsers handle ES6 import/export syntax

落爺英雄遲暮 提交于 2019-11-27 09:17:01
I've been thinking around this question lot of days and i have decided to ask the experts. How browsers will handle the new import/export syntax ? I mean: will the modules be loaded asynchronously ? Referencing only my main or entry file and browsers will lazy load the requiere modules. Maybe am i missing or misunderstanding something about this new architecture ? Thank you very much! Regards. This is standardized now and supported by all major modern browsers. will the modules be loaded asynchronously? Yes, with two options available; details below. Referencing only my main or entry file and

Path aliases for imports in WebStorm

[亡魂溺海] 提交于 2019-11-27 04:11:25
问题 I use webpack path aliases for ES6 module loading. E.g. If I define an alias for utils instead of something like import Foo from "../../../utils/foo" , I can do import Foo from "utils/foo" The problem is that once I start using aliases, WebStorm looses track of the import and I'm left with warnings and no auto-completion. Is there a way to instruct WebStorm to use such aliases? 回答1: [Deprecated answer. Starting since WS2017.2 Webstorm automatically parses and applies Webpack config (see

Dynamic System.import with webpack?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:35:35
问题 I am trying to port some ES6 code I have written that uses systemjs + Babel. I didn't have any problem porting most of the code. However, I have some code that needs to dynamically load an ES6 module, like this: function load(src) { System.import(src).then(function() {}); } src is an external ES6 module which may also have dependencies (static imports). How could I port this code to Webpack ? If I try to use require statement I'm getting a WARNING which seems to be normal according to the

How will browsers handle ES6 import/export syntax

半世苍凉 提交于 2019-11-26 17:49:09
问题 I've been thinking around this question lot of days and i have decided to ask the experts. How browsers will handle the new import/export syntax ? I mean: will the modules be loaded asynchronously ? Referencing only my main or entry file and browsers will lazy load the requiere modules. Maybe am i missing or misunderstanding something about this new architecture ? Thank you very much! Regards. 回答1: This is standardized now and supported by all major modern browsers. will the modules be loaded