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
12
votes
2 answers

Re-exporting ES6 modules in TS 1.7?

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…
XeroxDucati
  • 5,130
  • 2
  • 37
  • 66
11
votes
1 answer

module specifier in es6 import and export

I'm confused about what the module specifier in these statements refer to: export {bar} from "foo"; import {bar} from "foo"; What does "foo" refer to? It can't be a file since it would be something like "./foo". If it's not a file, I assume it's…
Fred Finkle
  • 115
  • 1
  • 1
  • 6
11
votes
3 answers

Do I still need a module loader if I'm using ES6 modules?

Unfortunately my knowledge of JavaScript module loaders is still growing and I'm trying to understand their relationship to the new ES6 Modules. As far as I can tell using a module loader like CommonJS or RequireJS using ES5 compliant JavaScript…
atconway
  • 20,624
  • 30
  • 159
  • 229
11
votes
1 answer

es6-module default export importing as undefined

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 = { …
flyingL123
  • 7,686
  • 11
  • 66
  • 135
11
votes
1 answer

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

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…
Permutator
  • 523
  • 3
  • 10
10
votes
1 answer

How do I get Istanbul to recognize code coverage when using ESM?

I'm using ESM to loading my modules and I use them in this way: // More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006) async function wire(){ await import("./Sanity.spec.mjs"); await…
JGleason
  • 3,067
  • 6
  • 20
  • 54
10
votes
1 answer

Exporting angularjs module as es6 module

You are supposed to wrap angularjs modules in an IIFE according to the styleguide, which we use https://github.com/johnpapa/angular-styleguide/tree/master/a1#iife my-dir.js (function() { 'use strict'; angular .module('my.dir', []) …
tic
  • 2,484
  • 1
  • 21
  • 33
10
votes
2 answers

How will browsers handle ES6 import/export syntax

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…
Alex29
  • 1,211
  • 2
  • 10
  • 20
10
votes
1 answer

Jasmine: How to spy imported function/constructor on ES6?

I am wondering how can I spy/stub function on Jasmine if I am using ES6 imports/exports with babel? import MobileDetect from 'mobile-detect'; it('should spy MobileDetect', () => { MobileDetect = jasmine.createSpy('MobileDetect'); });` The first…
dedirot
  • 101
  • 1
  • 4
10
votes
0 answers

Run-time bundling of ES6 modules in ASP.NET MVC

Are there any existing solutions for run-time bundling of ES6 modules? I'm looking to simplify JavaScript code development in a MVC5 web app. We're having issues with large, unwieldy JS files, so I'm hoping to get a module loader system in place. …
Ken
  • 834
  • 9
  • 25
10
votes
2 answers

How to get a reference to a class function in ES6?

Sorry if question is too simple, but I'm missing something here. Just switched an ES5 module that looked like: module.exports = { func1: function(a, b) {...}, func2: function(a, b) {...} }; To an ES6 class that looks like this: export default…
Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159
9
votes
1 answer

Publish ES module (.mjs) to NPMJS, with backwards compatibility for Node <8.5.0 (Dual Package)

Up to Node v8.5.0, publishing a module written in ES6 to NPMJS was a straightforward process: transpile the ES6 code using a tool like Babel, and publish to NPMJS the resulting lib directory, while your GitHub repo contains the src files. With…
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
8
votes
2 answers

javascript: modifing an imported 'variable' causes 'Assignment to constant variable' even it is not a constant

I have two files, file1 exports a variable 'not a constant' var x=1 and file2 which imports this variable from it the problem is that I canno't modify that imported variable even it is not a constant! file1.js export var x=1 //it is defined as a…
xx yy
  • 529
  • 1
  • 7
  • 16
8
votes
1 answer

JavaScript - How to make ES6 imports work in browser?

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…
Royi Bernthal
  • 882
  • 4
  • 17
  • 45
8
votes
1 answer

require working but import not working

I have a actions.js file that is exporting actions like this export var toggleTodo = (id) => { return { type: 'TOGGLE_TODO', id } } but when i import it using es6 import i get error Uncaught TypeError: Cannot read property 'toggleTodo'…
xtabbas
  • 627
  • 4
  • 10
  • 18
1 2
3
19 20