es6-modules Questions

1

The following code will always log the same message even if the module has changed on the server, regardless of Cache-Control headers sent: import('http://example.com/script.mjs').then(m => con...
Anhydrite asked 18/10, 2019 at 14:48

4

Solved

I am working on a package that depends on a ESM only library: unified and I exposed my npm package as CommonJS library. When I called my package in an application, node gives me this error message:...
Protease asked 31/12, 2021 at 19:20

1

I have a project where I want to use ES modules and use import instead of require. So I have added in package.json "type": "module". There is a case now where I have to import s...
Bugaboo asked 10/1, 2021 at 16:36

2

Solved

This is our project structure: - project - a.js - b.js In a.js I want to import b.js file using root path in the way like this: import c from '~/b.js'; but not using relative path like this: impo...
Riccio asked 15/10, 2021 at 16:20

2

I am using the Visx library to build charts in Nextjs. I am using the Visx scales, for which I import them as follows: import { scaleBand, scaleLinear, scaleOrdinal } from "@visx/scale" I...
Heyduck asked 8/2, 2023 at 15:39

2

I maintain a library, written in Typescript and I want to target both CommonJS and ESM. To do this I run the build twice. This requires me to write code (in Typescript) that's valid for both. One i...
Panslavism asked 5/2, 2023 at 19:2

8

Solved

In a JavaScript ES6-module, there may be many, small, easy-to-test functions that should be tested, but shouldn't be exported. How do I test functions in a module without exporting them? (without u...
Sofia asked 9/1, 2019 at 18:13

4

I have a plain old NodeJS project (with Typescript) and I'm really struggling to find out how to do ES6 imports for local files without having to do "../../../foo/bar" all the time. There...
Heraclitean asked 27/11, 2020 at 15:53

2

Solved

The standard way to expose node package modules is to list them in the index.ts, like so: export * from './module1'; export * from './module2'; However, this loads the content of both modules imme...
Aesthetics asked 26/10, 2021 at 20:29

4

Solved

I am trying to use VeeValidate and the examples show the usage of ES6 import like this: import { Validator } from 'vee-validate'; My understanding is that this works only with npm and not with C...
Borborygmus asked 2/3, 2018 at 21:19

0

Recently I had to migrate my project to ESM, mainly because many dependencies I'm using are not compatible with CommonJS anymore. By doing so I had a lot of troubles that I solved step by step. How...
Skinner asked 21/2, 2023 at 11:35

2

Solved

How i can get ownerDocument in script type="module"? <template> text </template> <script type="module"> let owner = document.currentScript.ownerDocument // is null...
Vina asked 21/7, 2017 at 4:11

4

Solved

I'm building a small application, and planning to use web components (rather than use a UI library). I don't plan to use any bundlers etc., as this is going to be a small personal site. I would lik...
Oteliaotero asked 3/10, 2022 at 12:33

4

Solved

I came upon this error when trying to use ky in a Next.js project: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /foo/node_modules/ky/index.js I think the problem is that Webpack (o...
Conform asked 30/1, 2021 at 23:47

3

Solved

I'm using AVA + sinon to build my unit test. Since I need ES6 modules and I don't like babel, I'm using mjs files all over my project, including the test files. I use "--experimental-modules" argum...
Mark asked 8/6, 2018 at 14:54

3

Solved

I've found at least two ways to import functions in from a module like Ramda for example. There are probably a few more ways to do something very similar like const R = require('ramda'); Option 1 ...

2

Solved

I am trying to import a module generated with emscripten as a es6 module. I am trying with the basic example from emscripten doc. This is the command I am using to generate the js module from the ...
Paper asked 14/11, 2018 at 21:37

1

Solved

I'm trying to build a small project node.js + ts using webpack. tsconfig.json { "compilerOptions": { "lib": ["ESNext"], "target": "ES2020", &qu...
Incursive asked 20/1, 2023 at 7:38

6

Solved

Is it possible to import javascript module from external url in ES6? I tried (using babel-node): import mymodule from 'http://...mysite.../myscript.js'; // Error: Cannot find module 'http://...my...
Rhapsody asked 5/1, 2016 at 8:33

3

Old situation Previously, I used the following method to force the browser to reload my JavaScript file if there was a new version available. <script src="common.js?version=1337"></scrip...
Pearson asked 29/8, 2017 at 16:21

2

Solved

I understand you can clear files from cache while using CommonJS simply by deleteing from require.cache and requireing the file again. However I've been unable to find an equivalent option when usi...
Parkway asked 6/3, 2020 at 5:38

2

Solved

Current Javascript adopts import from ES6 as a standard way to import modules. However, I sometimes see codes using CommonJS require instead of import. I first wondered whether two can be used toge...
Circumcise asked 13/1, 2022 at 4:37

4

I've got a problem to load rxjs into a simple webpack setup (without angular). I'm running: ./node_modules/.bin/webpack --config webpack.config.js --watch to start webpack. The only file with th...
Heronry asked 5/6, 2017 at 20:54

1

Solved

What is happning On vue2.6 + webpack, an application as follow is working well. <template> <v-app> <QR/> <v-main> </v-main> </v-app> </template> <sc...
Orography asked 19/12, 2022 at 0:34

10

I just started to learn React today. How do I get rid of that error message on my Console in the Terminal in Visual Studio. (node: 9374)Warning: To load an ES module, set "type": "m...
Substrate asked 26/8, 2020 at 0:3

© 2022 - 2024 — McMap. All rights reserved.