
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
@httptoolkit/esm
Advanced tools
Part of HTTP Toolkit: powerful tools for building, testing & debugging HTTP(S)
This is a forked version of the esm package: the brilliantly simple, babel-less, bundle-less ECMAScript module loader (which is now unmaintained). This fork includes:
node:*
imports.const require = createRequire(...)
pattern (or declare any other global require
variable) which are otherwise unusable with esm
.exports
map in their package.json, without a main
field, which are otherwise unresolveable (reporting "Cannot find module", even though import()
works correctly).Run npm i @httptoolkit/esm
or yarn add @httptoolkit/esm
.
There are two ways to enable @httptoolkit/esm
.
Enable @httptoolkit/esm
for packages:
Use @httptoolkit/esm
to load the main ES module and export it as CommonJS.
index.js
// Set options as a parameter, environment variable, or rc file.
require = require("@httptoolkit/esm")(module/*, options*/)
module.exports = require("./main.js")
main.js
// ESM syntax is supported.
export {}
Enable @httptoolkit/esm
for local runs:
node -r @httptoolkit/esm main.js
:bulb: Omit the filename to enable @httptoolkit/esm
in the REPL.
:clap: By default, :100: percent CJS interoperability is enabled so you can get stuff done.
:lock: .mjs
files are limited to basic functionality without support for @httptoolkit/esm
options.
Out of the box @httptoolkit/esm
just works, no configuration necessary, and supports:
import
/export
import.meta
import
stdin
, --eval
, --print
flags--check
flag (Node 10+)Specify options with one of the following:
"esm"
field in package.json
.esmrc.js
, .esmrc.cjs
, or .esmrc.mjs
file.esmrc
or .esmrc.json
fileESM_OPTIONS
environment variableESM_DISABLE_CACHE
environment variable{ | |||||||||||||||||||||
"cjs":true | A boolean or object for toggling CJS features in ESM. Features
| ||||||||||||||||||||
"mainFields":["main"] | An array of fields checked when importing a package. | ||||||||||||||||||||
"mode":"auto" | A string mode:
| ||||||||||||||||||||
"await":false | A boolean for top-level | ||||||||||||||||||||
"force":false | A boolean to apply these options to all module loads. | ||||||||||||||||||||
"wasm":false | A boolean for WebAssembly module support. (Node 8+) | ||||||||||||||||||||
} |
{ | |
"cache":true | A boolean for toggling cache creation or a cache directory path. |
"sourceMap":false | A boolean for including inline source maps. |
} |
For bundlers like browserify
+esmify
,
parcel-bundler
, and webpack
add a "module"
field to package.json
pointing to the main ES module.
"main": "index.js",
"module": "main.js"
:bulb: This is automagically done with npm init esm
or yarn create esm
.
@httptoolkit/esm
for wallaby.js
following their
integration example.Load @httptoolkit/esm
before loaders/monitors like
@babel/register
,
newrelic
,
sqreen
, and
ts-node
.
Load @httptoolkit/esm
for jasmine
using the
"helpers"
field in jasmine.json
:
"helpers": [
"node_modules/@httptoolkit/esm"
]
Load @httptoolkit/esm
with “node-args" options of:
pm2
: --node-args="-r @httptoolkit/esm"
Load @httptoolkit/esm
with “require” options of
ava
,
mocha
,
nodemon
,
nyc
,
qunit
,
tape
, and
webpack
.
:bulb: Builtin require
cannot sideload .mjs
files. However, .js
files
can be sideloaded or .mjs
files may be loaded with dynamic import
.
FAQs
Tomorrow's ECMAScript modules today!
The npm package @httptoolkit/esm receives a total of 4,591 weekly downloads. As such, @httptoolkit/esm popularity was classified as popular.
We found that @httptoolkit/esm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.