nise cannot be used standalone in pure ESM environments #2655
Unanswered
mohamedmansour
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
Hi, some more info could be helpful, as I just did a 5 minute test that proved succesful: First, set up a projectCreate a minimal program that consumes
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I am using ES Modules for my test infra, and once Sinon v20 removed
useFakeServerand asked us to useniseit doesn't work forESMsince it isCommonJSExpected behavior:
Actual Behavior
Root Cause Analysis
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}...package.jsondeclares "module": "nise.js" but this file is a UMD bundle, not a true ES moduleAttempted solutions that failed:
import nise from "nise"import { fakeServer } from "nise"await import("nise")→ Returns empty object {}@rollup/plugin-commonjsimport * as nise from "nise"Workaround
Created a custom loader that dynamically loads nise as a script tag:
Recommended fixes
dist/nise.esm.js- Pure ESM with proper exports"module": "dist/nise.esm.js"Thank you!
Beta Was this translation helpful? Give feedback.
All reactions