Questions tagged [es6-module-loader]

ES6 Module Loader Polyfill dynamically loads ES6 modules in browsers and NodeJS with support for loading existing and custom module formats through loader hooks.

Dynamically loads ES6 modules in browsers and NodeJS with support for loading existing and custom module formats through loader hooks.

This project implements dynamic module loading through System exactly to the previous ES6-specified loader API at 2014-08-24 ES6 Specification Draft Rev 27, Section 15. The specification for the module loader was removed from the ES6/ES2015 specification in 2014, and a new loader implementing the new draft WhatWG loader spec is pending alpha release on the 1.0 branch.

For an overview of build workflows, see the production guide.

For an example of a universal module loader based on this polyfill for loading AMD, CommonJS and globals, see SystemJS.

Documentation

294 questions
23
votes
5 answers

export / import single class method using ES6 modules?

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 {…
Rotareti
  • 49,483
  • 23
  • 112
  • 108
21
votes
3 answers

How to export default modules in index.js barrels

I'm trying to export default modules using index.js barrels but can't seem to get it to work. It works fine with named exports but not default exports. Simplified Project Structure /hellos /components Hello.js Hellos.js index.js …
Jon Miles
  • 9,605
  • 11
  • 46
  • 66
21
votes
2 answers

ES6 (ECMAScript 2015) modules: import index.js

Looking on the Internet I'm confused with the special "index.js" module file. Using babelJS + Node.js or Browserify/Webpack I can import an "index.js" module inside a "libs" directory using import myLib from "./libs" (i.e., omitting the /index or…
Zorgatone
  • 4,176
  • 4
  • 30
  • 47
18
votes
4 answers

TypeError: __webpack_require__.i(...) is not a function

I am getting a webpack TypeError when I am trying to simplify an import. The following code works without any issues. Here I am importing a React Higher-Order-Component (HOC) called smartForm from…
Naresh
  • 23,937
  • 33
  • 132
  • 204
18
votes
2 answers

Can't import TypeScript modules without providing the file extension

I am very new to TypeScript and I expect I should be able to import my TS files without needing to specify that they are TS files. I have to do import {sealed} from "./decorators/decorators.ts"; instead of what i want think is the right way which…
18
votes
1 answer

ES6 import syntax with Angular 1.5 UI Router

I'm trying to combine Angular 1.5, UI Router using ES6 import modules syntax with Babel & Webpack. In my app.js I have: 'use strict'; import angular from 'angular'; import uiRouter from 'angular-ui-router'; ... import LoginCtrl from…
17
votes
1 answer

es6-module-loader cannot locate @angular/core in Angular 6

I used this es6-module-loader in an Angular 2 project and it worked great for loading TypeScript modules in real time in the web-browser. Now, I am upgrading this project to Angular 6, but here the dependencies are not met for the imports of the…
Joe Almore
  • 4,036
  • 9
  • 52
  • 77
17
votes
1 answer

Imported variable works but is not defined when accessed in debugger (within same scope)

I am using webpack + es6 to build my files. I exported modules in a Math.js, then imported in Main.js. In the latter, I used the module to compute, then set a stop in the debugger. The former worked but it was not defined when I tried to use it in…
meow
  • 27,476
  • 33
  • 116
  • 177
16
votes
1 answer

How can an es6 module import itself?

I have a module called fooModule. Inside this module, I import fooModule (itself): import * as fooModule from './fooModule'; export function logFoo() { console.log(fooModule) } When logFoo() is called, I can see all of the exports of the…
Mr. Spice
  • 1,552
  • 1
  • 15
  • 15
14
votes
1 answer

JavaScript intercept module import

I have a SPA (in Aurelia / TypeScript but that should not matter) which uses SystemJS. Let's say it runs at http://spa:5000/app. It sometimes loads JavaScript modules like waterservice/external.js on demand from an external URL like…
ZoolWay
  • 5,411
  • 6
  • 42
  • 76
14
votes
2 answers

Trying ES6 imports with Chrome but it doesn't seem to work

I am contemplating moving from Dart to ES6 but Chrome doesn't seem to support the new import statement which is critical to me. I used the (named export) code from this site: http://www.2ality.com/2014/09/es6-modules-final.html I tried it even with …
Ray Hulha
  • 10,701
  • 5
  • 53
  • 53
13
votes
1 answer

Awaiting on dynamic imports in JavaScript

While trying to port some of our JS code to use modules, I ran into this peculiar case which I couldn't explain. I was setting up my main JS file to have dynamic imports for my main entry points and they in turn have imports for all the files they…
13
votes
2 answers

How to load a local video in React using webpack?

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:
Alex Cory
  • 10,635
  • 10
  • 52
  • 62
13
votes
11 answers

how to import highcharts with webpack and babel

I use ES6, Babel and webpack stack. I have installed highcharts by npm (I prefer to use the official highcharts npm repo): npm install highcharts-release --save But, regular import (ES6) doesn't work as expected: import highcharts from…
Shai M.
  • 1,284
  • 4
  • 17
  • 30
12
votes
2 answers

eslint - per file parserOptions.sourceType?

My project uses Webpack and es6 modules for most of the files. These files run in browser, and bundled by Webpack. There are just a small number of files, that run in node. They are not touched by Webpack and I don't see any benefit including them…
Boyang
  • 2,520
  • 5
  • 31
  • 49
1
2
3
19 20