Questions tagged [es6-modules]

The standard module system for JavaScript, introduced in ECMAScript 6 (2015).

1761 questions
0
votes
1 answer

ES6 - import constant, but when used an Uncaught ReferenceError is thrown

I have, as part of a js app, a file like this (with the names changed to protect the innocent): export const noValue = ''; export default class ValueProcessor { ... getValue(valueId) { } ... } And another file that imports…
Craig
  • 84
  • 6
0
votes
2 answers

ES6 calling method in another class, using modules

I know there is many questions like this asked, but I have been searching for hours and can't find any answers. I have this method, which takes in a parameter, which should be ID of two selects. Using this parameter, I want to determine which select…
user5382657
0
votes
1 answer

es6 export throws Parsing error: Unexpected token

App.js: import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; class App extends Component { render() { return (
venkata
  • 320
  • 1
  • 3
  • 12
0
votes
2 answers

Transpiled code gives TypeError:is not a constructor

I have JS module which will be used inside react project (CRA). index.js looks like, export { EvtScoket } from './socket'; socket.js looks like import openSocket from 'socket.io-client'; export default class EvtSocket { constructor(socketURL)…
user2473015
  • 1,128
  • 2
  • 18
  • 37
0
votes
0 answers

How to import Fuse.js as ES6 module client side?

I use ES6 modules in my code but I cannot import Fuse on the client. In node, everything works, but in the browser (Firefox developer edition 66.0b4 on Linux), this fails (the code is in the ./js folder): import Fuse from…
Konrad Höffner
  • 8,510
  • 11
  • 50
  • 92
0
votes
1 answer

Accessing a dictionary in a separate JS file and retrieve value

I would like to keep all of error descriptions in a single .js file as a dictionary, so that I can display the appropriate description from the rest of my JavaScript web app. I am very new to JS web app development and I am wondering how to achieve…
Kourosh
  • 588
  • 1
  • 12
  • 31
0
votes
0 answers

Export symbol as "module.exports", but keep type declarations in TypeScript

I'm developing a node.js plugin in TypeScript. The requirements are to export it as module.exports directly, e.g. when compiled, the index.js should look like this: module.exports = require('./src/plugin.js').default; My plugin.ts looks like…
Slava Fomin II
  • 21,036
  • 19
  • 98
  • 176
0
votes
1 answer

How do I import the Three.js Line library as an ES6 module?

I do my development using modern JS (ES6) which means modules. Although Three.js is available as an ES6 module. The line library - LineSegmentsGeometry, LineGeometry, LineSegments2, etc. - is not. What are my options here?
dugla
  • 12,300
  • 23
  • 79
  • 127
0
votes
1 answer

namespace export from index.js

My index.js in a given directory exports several things like this: export * from 'fileOne'; export * from 'fileTwo'; export * from 'fileThree'; I want to name space the stuff from file4, something like this: export { default as mockStuff } from…
Adam
  • 41,349
  • 10
  • 58
  • 78
0
votes
1 answer

Understanding ES6 Modules import/export

I'm starting learn ES6 modules and import/export syntax and I want that my modules are executed only where they are needed. I created two simple modules that connect to a
with a particular class or id to run. For example: // product.js import…
antonio matera
  • 33
  • 2
  • 10
0
votes
1 answer

Can't import multiple modules using 'import'

I'm trying to import classes from a .js file, but when I run the program it seems to have a Syntax error. Here's my code: import { RTUser, RTEvent, RTPurchase, RTMedia } from "./defs"; and here's the error that's being shown in the…
william
  • 51
  • 1
  • 7
0
votes
1 answer

Is it possible to compile to commonjs from es6 with webpack

The question is as the title suggests- if you have written your source code as es6 modules (import ... from ...) can you then compile this source back to node.js style commonjs modules (const ... = require(...)) using Webpack?
Fergie
  • 4,643
  • 5
  • 34
  • 40
0
votes
1 answer

Using rxjs in the ES6 module system (in browser) without a module loader

I have rxjs v6 from npm. I want to use it as part of a import using ES6 modules in the browser (Chrome v71) From what I can see from here https://github.com/ReactiveX/rxjs and my general mucking about, it looks like I can't use it as part of an…
Cheetah
  • 12,515
  • 28
  • 93
  • 167
0
votes
0 answers

Polymer npm app running in express static dir causes errors when importing files

I have a node application serving API backed and application frontend. Backed uses Express and static route to serve front end from "views" directory. The front is a static app using Polymer 3. I am unable to preview the UI when serving it from my…
Pawel Psztyc
  • 3,377
  • 2
  • 16
  • 34
0
votes
0 answers

how to correctly export a complex function from one js file to another js file

i have this code, i'm trying to export it to another js file, and i can calmly say i have zero idea how to do it. here is the code below. I would like to execute this time function in another JavaScript file. So far i have tried so many forms but to…
1 2 3
99
100