aws-samples / aws-sdk-js-notes-app

A simple note taking application using modular AWS SDK for JavaScript (v3)
Other
81 stars 30 forks source link

Use ESModules in notes app backend #4

Closed trivikr closed 5 months ago

trivikr commented 3 years ago

Is your feature request related to a problem? Please describe.

Not a problem, but it would be good to show Node.js using ESM as:

ESM comes with many benefits, like language-level syntax, browser support, defaults to strict mode, async loading, top-level await, improved static analysis & tree-shaking, and more.

Describe the solution you'd like

Use ESM modules in the todo app backend by setting "type": "module" in package.json. Docs: https://nodejs.org/api/esm.html#esm_enabling

Describe alternatives you've considered

Sticking with using commonjs for the backend.

trivikr commented 3 years ago

Experimental commits can be viewed in https://github.com/trivikr/aws-sdk-js-notes-app/commits/use-esm

Not going ahead right now as:

cspotcode commented 3 years ago

You probably know this, but just to clarify, ts-node's ESM support is experimental out of necessity, because node's ESM loader hooks are experimental. So there's no way we can guarantee a stable feature built on unstable node APIs.

Even though node's ESM feature is "stable," the reality is that it's still limited compared to CommonJS, due to the unstable nature of ESM loader hooks.

trivikr commented 5 months ago

No longer needed, as we now bundle through aws_cdk.aws_lambda_nodejs https://github.com/aws-samples/aws-sdk-js-notes-app/pull/122