2,881
questions
0
votes
0
answers
28
views
How can I use javascript modules in a web extension? [duplicate]
My popup.html already includes:
<script type="module" src="./popup.js"></script>
When I try to import any resource inside the script file popup.js, like:
import { ...
1
vote
0
answers
24
views
How to profile NodeJS files imports
In one of our applications, we need to optimize the startup time.
Is there a way to profile a Node.js application to see which files are being imported and how long these imports take?
Ideally, it ...
0
votes
1
answer
49
views
How to use ES2022 in Nest.js config
I'm trying to make I Nest.JS project use ES2022 cause I'm trying to use an ES module package. I have updated the tsconfig.json and paackage.json but it doesn't work as it keeps coming up with this ...
0
votes
1
answer
46
views
Universal way to use CommonJS in Javascript with ESM
ESM is the normalized way for module function in Javascript. But there are many CommonJs package in npm.
Vite is good tools for change CommonJs to ESM, I want to use protobufjs in a vue project. The ...
0
votes
1
answer
44
views
Can I create a module specifier from an object?
In JavaScript, we can import modules like so:
import defaultExport from "module-name";
import * as name from "module-name";
where module-name is the module specifier.
If I already ...
0
votes
0
answers
41
views
SyntaxError: Unexpected token 'export' from node_modules
I want to use browser-image-hash npm package in a project.
For setting up the project I did:
npm init -y
npx tsc --init
npm install browser-image-hash
I then added an index.ts file with the ...
0
votes
0
answers
31
views
what is a working way of using jest with pnpm and esm
My monorepo is trying to use pnpm, workspace protocol, ts-jest and esm and npx jest in the libraies/social-media cwd is giving the error message shown below.
See libraries/social-media/jest-config.mjs ...
-1
votes
0
answers
18
views
Vite - script and module query suffixes for imports
Based on this artcile I see that you can specify certain query suffixes to an import, however, where can I find the documentation for what these do?
The vite docs have a section which describe some of ...
0
votes
1
answer
27
views
javascript library is not loaded into an angular typescript project
We are trying to build a javascript library (dwbn-event-webcomponents), that can be imported into a typescript project (angular 17) and also used standalone. It was installed via npm from git url.
In ...
0
votes
0
answers
37
views
in node.js ESM I want to stub an exported module thats the default
I have a very simple auth middleware with an export default () anonymous function:
export default () => async (req, res, next) => {
try {
// some auth implementation... does not matter
...
2
votes
1
answer
39
views
SyntaxError: Cannot use import statement outside a module ts-jest
I'm using TypeScript, ESM, npm, and ts-jest. Unfortunately, it seems that transformIgnorePatterns isn't working.
I've tried multiple configurations, but nothing has helped me run Jest with ts-jest ...
0
votes
0
answers
20
views
CommonJS module loading in Electron
Problem:
Loading commonjs module in electron app and using it in the renderer code.
import './subc/simplewebrtc.3.1.0.js'
import './subc/adapter-8.2.2.js'
import './subc/simplewebrtc-mf.js'
// Above ...
0
votes
1
answer
35
views
dynamically import es module provided as a blob with es-mdoule-shims and angulars native federation
Problem
I am developing a plugin based architecture in angularjs.
To load a plugin in runtime I first send a request to the backend to download and store the plugins source code. This way I already ...
0
votes
1
answer
52
views
Electron store ES6 modular import, cannot initialise store object
I'm trying to use electron-store package to store values in a vue + electron application.
I've followed the examples given by the author here: https://www.npmjs.com/package/electron-store.
But im ...
1
vote
0
answers
50
views
Why is a top-level code executed twice in NodeJs?
I am modifying a project where a file contains some infrastructure variables. I executed code with side effects at the top level, but found that the side effects were repeatedly triggered during ...