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
6
votes
4 answers

Dynamic System.import with webpack?

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) { …
warpdesign
  • 727
  • 2
  • 7
  • 17
6
votes
1 answer

How can I specify library dependencies using SystemJS?

Using SystemJS, how do I specify that one library depends on another? For example, the Bootstrap JavaScript library depends on jQuery. Based on the SytemJS docs, I assumed I would specify this dependency using System.config.meta…
Nathan Friend
  • 12,155
  • 10
  • 75
  • 125
5
votes
1 answer

Is circular type reference a bad thing to do In TypeScript?

I encountered below code snippets which contain a cyclic importing dependency on type reference. // Foo.ts import { Bar } from './Bar'; export interface Foo { isBarOK: (bar: Bar) => boolean; } // Bar.ts import { Foo } form './Foo'; export class…
Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40
5
votes
0 answers

npm test - Must use import to load ES Module - but I thought I was? (node 12)

My files are all .mjs extension I have fizz_buzz.mjs and test/fizz_buzz.spec.mjs test/fizz_buzz.spec.mjs uses import { fizzBuzz } from '../fizz_buzz' I run npm test and I get > mocha test/**/*.spec.mjs …
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
5
votes
4 answers

Module has no exported member 'AWS'

Can someone help me understand how different the namespace and module is? AWS.d.ts declare module AWS { ... ... } export = AWS helper.d.ts export declare namespace Helpers{ ... ... } app.component.d.ts import {Helpers} from…
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129
5
votes
2 answers

ES6 best way to import React's named imports

I was wondering which of the two way of importing React named imports ( PropTypes , Component) in ES6 is the best. First import React, {PropTypes, Component} from 'react'; which would save a lot of typing specially on components that have lots of…
Amir Hoseinian
  • 2,312
  • 2
  • 24
  • 27
5
votes
1 answer

Import JSON files in the browser using ES6 style syntax with React

I have folder, with a lot of JSON files: -json --file1.json --anotherfile.json ... --lastfile.json How can I import all of them from that folder, without explicitly defining their names? Suppose, I should use something like this: import * as…
Yurii N.
  • 5,455
  • 12
  • 42
  • 66
5
votes
1 answer

Javascript (ES6) Modules: Is it possible to export a variable with a dynamic name?

In ES6 I can export a simple foo constant: export const foo = 1; I can also convert the value of that export (1) to a variable, and export that: const fooValue = 1; export foo = fooValue; But my question is, is there any way I can convert the key…
machineghost
  • 33,529
  • 30
  • 159
  • 234
5
votes
3 answers

Javascript import handle undefined

Is it possible to catch typos like in switch case example statement below? Preferred way would be that eslinter report an warning/error. Currently adding toString() to const can be used to raise an TypeError in runtime if…
bmihelac
  • 6,233
  • 34
  • 45
5
votes
1 answer

how to use SystemJS to bundle angular TypeScript with internal modules

We are considering moving some of our angular projects over to typescript and having some trouble with internal module/namespaces. We posted this working example on github: https://github.com/hikirsch/TypeScriptSystemJSAngularSampleApp steps: npm…
4
votes
1 answer

Jest test suite failed to run because of "TypeError: Cannot read property 'xxx' of undefined"

I am trying to reorganize the import/export statements of my TypeScript React project to make them shorter and cleaner, basically by the approach of defining an index.ts file in each feature specific folder to export resources…
Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40
4
votes
0 answers

How to let WkWebview support js module feature? use require.js?

I need to let WkWebview to read my .ts file, which include "export" and "import". after I compile to js, it seems that WkWebView does not support the js module, which could not read my function. Is there any way to check which of js…
4
votes
2 answers

Wepback import html template not loading

I have a monolith project made with AngularJS using Webpack but I'm getting an error saying: Unexpected token < main.html. This error occurs when I have this line of code in one of my controllers: import templateUrl from './main.html'; From my…
Nizar B.
  • 3,098
  • 9
  • 38
  • 56
4
votes
1 answer

ES6 javascript import external js file

I'm trying this in my ES6 javascript module: import externalutil from 'https://externalutil.com/js/externalutil.js'; but it fails with this transpile error: Module not found: 'https://externalutil.com/js/externalutil.js' The file…
Nikola Schou
  • 2,386
  • 3
  • 23
  • 47
4
votes
1 answer

Cleanest way to import/require a Vue.js directive?

I'm trying to organize my plugins into custom Vue Directives that could be a simple as: Vue.directive('popout', { bind() { $(this.el).popOut(); } }); And save these in separate files, to be imported in either the main JS file or the…
oscaralexander
  • 307
  • 2
  • 11