-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESM - ECMAScript Modules with JavaScript mock data #6
Comments
Good call, we can and should fix this! |
Just released 1.1.0 RC, please give it a try with Please note this caveat as found in the changelog: per Node.js #2806, ES module data may be cached in Sandbox, which is intended to be a semi-long-lived process. If using ES modules, you may need to restart Sandbox when updating your mocks. |
Node.js configured as ESM using .JS or .MJS for my JavaScript mock file uses Node.js configured as ESM using .CJS for my JavaScript mock file uses The shared exception on this line 155.
|
Thanks, I'll take a peek this morning and figure out where the bug is! |
@ryanblock Correction, I tweaked my side and it works! RC.0 works for both .JS and .MJS with |
Describe the issue
Node.js cannot be configured to ECMAScript modules (ESM) with a JavaScript mock data file.
JavaScript mock data must use CommonJS (CJS) export syntax
module.exports
with Node.js configured to support CJS (in package.jsontype
must be omitted or set to "commonjs")If Node.js is configured to ESM then the JavaScript mock data hits an exception on this line 75
Steps to reproduce
Steps to reproduce the behaviour:
"type": "module",
sandbox-invoke-mocks.js
module.exports
as .CJS orexport default
syntax .JS or .MJSExpected behaviour
Execute lambda function with mock data
Actual behaviour
An empty mock event is passed to the Lambda function if the JavaScript mock file is a .CJS
ESM error if the JavaScript mock file is a .JS or .MJS
Screenshots
If applicable, add screenshots to help explain your problem
Environment
Please complete the following information (if appropriate):
Workaround
Node.js may be configured as ESM then use a JSON file for your mock data (to avoid the
import
/require
conflict)!The text was updated successfully, but these errors were encountered: