es6-module-loader

How can I specify library dependencies using SystemJS?

旧巷老猫 提交于 2019-12-22 05:28:16
问题 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 property: System.config({ baseUrl: './scripts', defaultJSExtensions: true, map: { jquery: './lib/jquery-2.2.0.min.js', bootstrap: './lib/bootstrap.min.js' }, meta: { bootstrap: { deps: ['jquery'] } } }); System.import('./scripts/app.js'); But this seems to have no

ES6 (EcmaScript 2015) modules: import index.js

我与影子孤独终老i 提交于 2019-12-21 07:10:52
问题 Looking on the internet I'm confused with the special "index.js" module file. Using babelJS + nodeJS or Browserify/Webpack I can import an "index.js" module inside a "libs" directory using import myLib from "./libs" (ie. omitting the /index or /index.js part). Is the "index.js" module resolution (specifying the containing folder) supported by the ES6 (EcmaScript 2015) modules official standard? Or is it just "custom" NodeJS/CommonJS transpiling behaviour? Will it be possible to omit the

ES6 javascript import external js file

浪子不回头ぞ 提交于 2019-12-19 05:08:32
问题 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 externalutil.js is an old-fashioned javascript library that does not export anything. Any help will be appreciated. 回答1: You cannot import URL's (as of yet). You should download the file, put it somewhere locally and reference it locally as well. However in your case

module specifier in es6 import and export

孤街浪徒 提交于 2019-12-18 05:47:05
问题 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 an ID. How is the ID defined? I'm exporting from a js file, but the import would be part of an inline html script ( type="module" ) in the firefox browser. The browser version (and browser settings) have been verified to work with es6 modules. Thanks

How to import everything exported from a file with ES2015 syntax? Is there a wildcard?

这一生的挚爱 提交于 2019-12-17 17:55:18
问题 With ES2015 syntax, we have the new import syntax, and I've been trying to figure out how to import everything exported from one file into another, without having it wrapped in an object, ie. available as if they were defined in the same file. So, essentially, this: // constants.js const MYAPP_BAR = 'bar' const MYAPP_FOO = 'foo' // reducers.js import * from './constants' console.log(MYAPP_FOO) This does not work, at least according to my Babel/Webpack setup, this syntax is not valid.

Can't export reducer with Babel

北城余情 提交于 2019-12-13 07:11:37
问题 This is most likely some typo but I've been trying to fix it for the last hour and came up with nothing. I have a file called app/reducers/index.js : export viewportSize from "./viewportSize"; app/reducers/viewportSize.js is simply: export default function viewportSize (state = {}) { return state; } And in app/app.js I do: import reducers from "./reducers"; Babel is giving me back this error ERROR in ./app/reducers/index.js 1:8 error Parsing error: Unexpected token viewportSize I have other

import() breaks in Angular 7.2.3 + Webpack 4.28

孤人 提交于 2019-12-13 03:56:54
问题 I have the following code : var path = "./relative/path/to/" + fileName + ".json"; import(path).then(cb); The import works as expected in my Electron demo (which uses Webpack 3.12). It breaks in my Angular demo (which uses Webpack 4.28). My Angular demo has the following Webpack config : module.exports = { node: { fs: 'empty' } }; It produces the following error at runtime : Unhandled Promise rejection: Cannot find module './resources/symbology/labelTemplates/labelTemplates.json' ; Zone:

es6 equivalent for module.exports

岁酱吖の 提交于 2019-12-12 02:34:32
问题 What's the ES6 equivalent for module.exports I want to get the value of foo from an import statement module.exports = { foo: function (a) { } } Tried: export default { foo: function (a) { } } The way first one is imported is using: var file; var filename = root + "/" + fileStats.name; file = require(path.resolve(filename)); I want to use ES6 import statement. I read somewhere that this isn't supported however would like to still know if there's a work around this. 回答1: Not sure what you're

Difference between simple import statement and System.import in ES6 Module Loader

吃可爱长大的小学妹 提交于 2019-12-11 02:41:45
问题 Is anybody able to explain the difference between a simple import and a System.import statement of the ES6 Module Loader (or Polyfills like System.js, Webpack etc.) Something like System.import('https://code.jquery.com/jquery.js').then(); seems to be possible, as well as a simple import 'jquery'; Is System.import the only possibility to have a callback after the import statement? 回答1: You can use the System.import inside <script> tags where import aren't supported, and you can also load

TypeScript inheritance and circular dependencies in SystemJS

感情迁移 提交于 2019-12-10 15:56:42
问题 I'm using TypeScript with --module system (SystemJS) in a very large project. SystemJS supports cyclic dependencies, and most of the time it works fine. However, when TypeScript inheritance gets involved, things begin to break. For example, if a class A depends on class B , and class B inherits from class A , then if class A gets loaded first: It will pause class A's resolution and will try to load the class B dependency class B will think its dependencies are resolved, since class A has been