Questions tagged [esmodules]
57 questions
1
vote
2 answers
Why is importing an icon named ImportExport breaking other dependencies?
I added a Material-UI icon to one of my react components like so:
import { ImportExport } from '@material-ui/icons';
Thereafter, on my production site (but not my localhost dev server), I started getting an error on pageload whereby my socket-io…

temporary_user_name
- 35,956
- 47
- 141
- 220
1
vote
2 answers
Why does webpack use script tag for dynamic import when dynamic "import()" is already supported?
Lately I've been deep diving more about JS modules, Webpack, the difference between ES modules and CommonJS, and I came across the dynamic import topic. I was curious on how Webpack converts the dynamic import() statement and when I take a look at…

hskris
- 101
- 4
1
vote
0 answers
Monorepo Typescript how to build package together?
I have Pacakage 'A'
And app 'B'
'Package A'
index.ts
export default "foo"
A's package.json
main: index.ts
types: index.ts
A's tsconfig.json
"module": "commonjs",
'APP B'
import value from "A"
B's pacakge.json
"type": "commonjs",
B's…

MINJA KIM
- 876
- 1
- 8
- 22
1
vote
0 answers
Different behaviour with Mocha between `pnpm ln -g ` and `pnpm add github:`
Some quite complex problem I am having here that I can't find a solution :
Context
I would like to use the ts version of the library algebrite : https://github.com/davidedc/Algebrite
But I required also some internal types and structure, so I forked…

hl037_
- 3,520
- 1
- 27
- 58
1
vote
0 answers
How to print what files are transformed by babel or babel plugin?
I am writing babel and jest configuration that should transform one of node_modules. At the moment is does not work and I would like to know if the error that I am getting is because the files are not transformed. Unfortunately I didn't yet found a…

Žilvinas Rudžionis
- 1,954
- 20
- 28
1
vote
1 answer
Can't set up amcharts5 as a plugin in nuxt 3
I'm currently trying to use amcharts 5 in a Nuxt3 app, and had a couple of graphs working fine. However at some point amcharts has randomly stopped working and I get the following error:
[h3] [unhandled] H3Error: am5 is not defined
at…

John
- 31
- 3
1
vote
0 answers
ES Module error encountered when testing npm package locally
Background:
I am trying to test an npm package that I am developing: a React Component that manages a SVG filter animation. In verifying that it works as expected, I have used npm pack to generate a tarball, which I have then installed as a…

slackermorris
- 368
- 3
- 11
1
vote
1 answer
ERR_REQUIRE_ESM require of of ES Module not supported how can I fix this? on file-type package
I've a outdated app that uses very older few packages those doesn't support ES Module as an example file-type package. So if you setup babel and node HTTP server with and then install file-type package then start building and running will throw…

Code Cooker
- 881
- 14
- 19
1
vote
1 answer
How to get Typescript to compile CommonJS imports?
I have written a TS file, that loads in a 3rd party package, using import XXX { YYY, ABC, 123 }from 'XXX';
It will compile to CommonJS no issue, and thats OK. But I'd like to compile it to an ESModule. I changed the target and module settings to…

Mr Pablo
- 4,109
- 8
- 51
- 104
0
votes
0 answers
Getting CORS error while working with OpenLayers v7.5.2
Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at file:///C:/Users/kalam/Documents/my-ol-app/main.js.
(Reason: CORS request not http).
Module source URI is not allowed in this document:…
0
votes
1 answer
how to import custom js modules using es module imports
When using the commonjs I used to import custom modules like this:-
const date = require(__dirname + "/date.js");
after switching to es module type I can no longer use the __dirname without creating one manually
import { fileURLToPath } from…

G Ajeet
- 27
- 5
0
votes
3 answers
NodeJS - How do I call separate imports based on 'if' condition for ES Modules?
Followed a tutorial that uses CommonJS to export/require different keys based on the environment. How do I get it to work with ES Modules import/export?
This was the code he used:
if (process.env.NODE_ENV === "production") {
module.exports =…

Meaetin
- 3
- 1
0
votes
0 answers
Trouble with ES Modules when using Swiper.js in an Nx Monorepo with Next.js
In my current project, which utilizes the Nx monorepo environment combined with Next.js, I've encountered an issue related to ES modules. The problem is specifically tied to the Swiper.js library.
After the Swiper.js library was updated and switched…

Ksenia
- 950
- 6
- 24
0
votes
1 answer
After switching to ESM import in .ts files no longer supports files without extension
After switching from CommonJS to esnext module, import of other .ts files from .ts file is no longer possible.
My getButton.ts imports this:
import { Button } from "../../../objects/Button";
ts.config:
{
"extends": "..",
"compilerOptions":…

John
- 230
- 2
- 12
0
votes
1 answer
Named export 'YoutubeVue3' not found. The requested module is a CommonJS module, which may not support all module.exports as named exports
I have a problem with youtube-vue3 plugin that I use in Nuxt3 project. It causes me problem with prerender on yarn generate. Here is how it looks: