Skip to content

docs: fix esm loader options in ESM stubbing guide - #2767

Open
alorentiar wants to merge 1 commit into
sinonjs:mainfrom
alorentiar:docs/fix-esm-loader-options
Open

docs: fix esm loader options in ESM stubbing guide#2767
alorentiar wants to merge 1 commit into
sinonjs:mainfrom
alorentiar:docs/fix-esm-loader-options

Conversation

@alorentiar

Copy link
Copy Markdown

The loader example in this guide passes mutableNamespace as a top-level
esm option:

require = require("esm")(module, {
  cjs: true,
  mutableNamespace: true,
});

esm only reads it under cjs (see the options table in its README), and it
rejects unknown top-level keys, so this loader actually fails on startup with
Unknown esm@3.2.25 option: mutableNamespace. I reproduced that with mocha +
esm on an older Node (esm only runs there), then confirmed the corrected
options load cleanly.

Moved the flag under cjs in both places it appears. Keeping it scoped to
the reported config issue.

Refs #2714

mutableNamespace is a cjs sub-option according to the esm docs. Passed as a top-level key, esm refuses it at startup (Unknown esm option: mutableNamespace), so the loader file in the example never ran. Fixes sinonjs#2714.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant