The standard module system for JavaScript, introduced in ECMAScript 6 (2015).
Questions tagged [es6-modules]
2668 questions
1
vote
0 answers
Subresource integrity for ES6 module import
Considering one may want to import JS modules from CDNs or so, it may be important to ensure the integrity of the delivered JS modules.
Fortunately, in the "old" integration method, we already had solved that problem with Subresource…

rugk
- 4,755
- 2
- 28
- 55
1
vote
1 answer
Module instance filename is null, but why?
I have this code which creates a Node.js module from memory:
function requireFromString(src, filename) {
var Module = module.constructor;
var m = new Module(filename);
m._compile(src, filename);
return m;
}
console.log(
…

Alexander Mills
- 90,741
- 139
- 482
- 817
1
vote
2 answers
How to define typescript/Oracledb npm connection in class and method format?
I'm trying to connect with npm Oracledb using typescript and in the format of class and module using typescript. For example,
Import {Oracledb} from 'oracledb'
class ConnectDAO{
public ConnectionDB(): connection{
let connection =…

Murali
- 23
- 2
- 8
1
vote
0 answers
Is imported code in webpack guarantee to fully execute before anything else?
Let's say I have a module A that is imported by module B in a webpack project.
A.js
const variable = synchronousGetData()
export function exportedFunction() {
// do some work with variable
}
B.js
import { exportedFunction } from…

Adam Thompson
- 3,278
- 3
- 22
- 37
1
vote
0 answers
SyntaxError: Unexpected token export when testing typescript code with ES2015 module imports with jest
Im struggeling to get some code I work with tested.
In all my projects I use jest for testing. it works fine as long as I have javascript files but I do work with some packages containing typescript code. The code contains dependencies with ES2015…

Magnus Siverbrant
- 113
- 1
- 1
- 7
1
vote
1 answer
Webpack load native ES6 modules in the browser with bundled fallback
Given most browsers now support native ES6 modules and coupled with HTTP/2 capabilities it is practical to load unbundled ES6 modules in these browsers but with a fallback using the script tag nomodule attribute for other browsers.
Based on this I…

RichTurner
- 797
- 7
- 14
1
vote
2 answers
Destructured variable value not persisting between modules
I'm getting inconsistent results when passing objects between modules in a Node JS application, or probably just misunderstanding what is going on!
In my app, written out in pseudo-code below, a lib file is first required into the application root,…

Toomy
- 318
- 2
- 10
1
vote
2 answers
How to detect if script is running in a module?
I have a program with a fallback for browsers that do not support web workers. The reason I'm doing this is because I want to deploy it to cocoon's canvas+, which does not support web workers. The non web worker code can access the script…

Legomite
- 99
- 2
- 7
1
vote
0 answers
babel-preset-react-app NODE_ENV production v test
I am using preset react-app to build my component and publish for other projects to use. When built with env production it transpiles the code but still keeps import and export and not convert it to exports. and require. However when I pass env test…

anivas
- 6,437
- 6
- 37
- 45
1
vote
1 answer
when to combining multiple imports into a single file
As I understand then combine multiple export statement into a single file is considered a good practice iff source file comes under the same directory
so
import { Observable } from 'rxjs/Observable';
import { Observable, BehaviorSubject, Subject,…

xkeshav
- 53,360
- 44
- 177
- 245
1
vote
0 answers
d3.event is null in modular d3 project
Note: I found an answer to this question
here. The problem is
solved; no need for more answers!
I am doing a project with the following structure:
root
|
|____js
| |__index.js
|
|__node_modules
| |__d3-*
| …

jrook
- 3,459
- 1
- 16
- 33
1
vote
1 answer
Importing TS typings with ES6 modules for JS loaded from CDN
Using:
Typescript with ES6 output (target and modules)
Vue loaded from CDN
TS typings of Vue installed by NPM
I'm trying to get types working in source .ts files and still use Vue loaded by the CDN. Vue from the CDN isn't a module (and that wouldn't…

Noein
- 522
- 1
- 6
- 16
1
vote
2 answers
How do I avoid adding JavaScript ES6 module exports to global scope for use in normal script blocks?
I've so far managed to avoid hardcore JavaScript programming but it looks like that is coming to an end. In gearing up for a major new project, I'm trying to get my head around best practices in 2018. I've been reading a lot about different module…

Jim Hanks
- 13
- 4
1
vote
0 answers
Webpack optimization module concatenation: multi referenced from single entry bailout
I am trying to wrap my head around module concatenation with Webpack 4.
I have an entry.js script which uses imports from multiple modules which in turn import multiple modules.
Using optimizationBailout warnings when bundeling throws following…

Dennis Bauszus
- 1,624
- 2
- 19
- 44
1
vote
0 answers
React Native WebView And Local Html Issue
So, basically, i'm experimenting with React Native and i have imported a local file with react native's WebView. It works! Within the local file, i have a javascript script which creates a canvas element.
Now, I need the javascript script from the…

Cole Mangio
- 79
- 1
- 13