The standard module system for JavaScript, introduced in ECMAScript 6 (2015).
Questions tagged [es6-modules]
2668 questions
1
vote
1 answer
Export different objects from the same file to different NgModules
Background:
I am developing an application that will utilize angular's lazy loading mechanism (I'm using 7.2.0). I have several feature-routing.module.ts that handle the routing of said lazily loaded modules.
On the AppModule side I would like to…

foxSays
- 88
- 6
1
vote
1 answer
How do I get typescript + webpack + vuejs to find packages in my node_modules/older/lib/ directory?
I'm trying to turn an older typescript project into a library for a new vue.js project. The older package is configured to output to ./lib/ with tsconfig.json, and package.json includes all of the "this is where my library is" options I can think…

joeforker
- 40,459
- 37
- 151
- 246
1
vote
0 answers
Is there any way to use the same es6 module import paths for Node and browsers without bundling?
I've been playing around with using es6 modules directly, without using Webpack, rollup, etc. After reading this article, I settled on the following:
import { MyObject } from './node_modules/module_name/index.mjs'
This works fairly well (in both…

anderspitman
- 9,230
- 10
- 40
- 61
1
vote
2 answers
NodeJS: "Unexpected identifier" when trying to import module
I am trying to use ES6 imports in Node v10.15.3 LTS, but I keep running into the same syntax error. It occurs no matter whether I use esm, babel, or the --experimental-modules flag to enable support for ES6 imports. Here is the error…

Derrick Miller
- 1,860
- 3
- 21
- 37
1
vote
0 answers
Webpack cannot import images
I am trying to use webpack for importing images. Like this:
import img from '../assets/bmo.png';
But I keep getting the error:
module not found: '../assets/bmo.png'
I have tried all kinds of different paths to the image:
import img from…

Kokodoko
- 26,167
- 33
- 120
- 197
1
vote
1 answer
Destructuring an Imported Object in JavaScript
Let's imagine that I have two files. File number one is called obj.js and looks like this:
const obj = {
item1: 'some text',
item2: 'some other text',
item3: 'more text'
...
item99: `yet more text`
}
export default obj
File number 2…

Moshe
- 6,011
- 16
- 60
- 112
1
vote
3 answers
Require module without webpack etc
How can I load a library that can be loaded only trough require without using webpack, compilation, traspilation, uglification etc.
Let's say: https://github.com/stutrek/scrollMonitor
The code is vanilla javascript and has no external dependencies,…

Isinlor
- 1,111
- 1
- 13
- 22
1
vote
2 answers
How can I pass options into an imported module?
I have a utility module that creates an instance of a multer-gridfs storage engine for uploading files to my Mongo database. I use this module inside of any API route that requires the need to upload files.
I need to be able to update the metadata…

maison.m
- 813
- 2
- 19
- 34
1
vote
1 answer
How to load ES6 module for Jupyter notebook extension?
I currently use Jupyter Notebook Server version 5.7.0. I would like to write a Jupyter notebook extension, that loads some ES6 module by adding a script tag to the document, e.g: