
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A ESM Loader for NodeJS and Browsers Allows to import modules from any source is extendible via modules.
Allows to load esm from any file formart can be seen as loader construction kit while offering precoded methods to do generic loader stuff in cross environment applications. It also can be seen as Pollyfill for importScript and dynamic import from url for NodeJS.
breaking change is deprecating strToESM its successor is ESMLoader and moduleString
Host a local or remote server with scripts or use https://unpkg directly inside nodeJS via "esm-loader" The Steps to form a Module Instance with livebindings!
String to ESModule Examples Cross Environment
import { ESMLoader } from 'esm-loader/loader.mjs'
const module = ESMLoader('export const myModule = { yellow: \'snowflakes\'}')
.then(({ myModule })=>console.log(myModule.yellow)) // Logs: snowflakes
import { moduleString } from 'esm-loader/loader.mjs'
const module = import(moduleString('export const myModule = { yellow: \'snowflakes\'}'))
.then(({ myModule })=>console.log(myModule.yellow)) // Logs: snowflakes
ESMLoader used inside NodeJS supports NodeJS Module Resolve but not relative resolve you can support it via a transformation step after loading your code you can simply replace any ./ ../ urls with correct resolved values relative to your current loaded module or the module loading path of the scipt you plan to instantiate and evaluate to ESM via ESMLoader.
ESMLoader ships with a example method to get code from a remote file via a isomorpic fetch This allows to use import with dynamic content.
// The exported fetch is cross environment Nodejs and Browser
import { ESMLoader, fetch ,fetchImport, dynamicImport } from 'esm-loader/loader.mjs'
// Creates a dynamic import from a string
// Returns a ESM Module with exports from string has resovle for Bare and Absolut Specifiers
// can easy be rewritten for your own extensions
fetchImport('url') //is a shortHand helper for fetch('https://url.to/your/js.mjs').then(ESMLoader)
.then(mod=>console.log(mod))
dynamicImport('url') // uses import in the browser and fetchImport in nodejs
CJS
const fs = require('fs')
//ESM-LOADER is ES so you need to use dynamic import
import('esm-loader/esm-loader.mjs') // NodeJS Resolve used here
.then(({ ESMLoader })=>fs.promises.readFile('path/to/file.txt,ts,any').then(ESMLoader)) // NodeJS Resolve used here
//no relativ urls can use transformations befor then(ESMLoader)
.then(myModule=>console.log(myModule)) //=> returns a real ESModule
import { ESMLoader, dynamicImport } from 'esm-loader/loader.mjs'
// Creates a dynamic import from a string
// can easy be rewritten for your own extensions
fetch('https://url.to/your/js.mjs')
.then(ESMLoader)
/**
* Returns a ESM Module with exports from string
* has resolve for Bare and Absolut Specifiers
* Your Can Easy rewrite the String that you get from
* fetch befor you use it as input to ESMLoader.
*/
.then(mod=>console.log(mod))
dynamicImport('url') // uses import in the browser and fetchImport in nodejs
https://github.com/rollup/plugins/pull/150
Lets Import a mjs file from a source and rewrite it to resolve to the right locations if relativ specifiers are used
// TODO:
FAQs
A ESM Loader for NodeJS and Browsers Allows to import modules from any source is extendible via modules.
We found that esm-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.