nats-io / nats.ws

WebSocket NATS
Apache License 2.0
329 stars 29 forks source link

Support for ECMAScript Modules ES2017 and Later #257

Closed Ramesh-Mu closed 3 weeks ago

Ramesh-Mu commented 2 months ago

Proposed change

nats.ws should support ECMA Script module ES2017 and later

Use case

I have integrated nats.ws with Angular 12. When I set the target to ES2017 or later in tsconfig, it throws an error. Using a lower version of ES modules may prevent fully leveraging the latest ECMAScript features, potentially resulting in less efficient performance optimizations and limited utilization of new features.

./node_modules/nats.ws/esm/nats.js:7472:16 - Error: Module parse failed: Unexpected token (7472:16)
File was processed with these loaders:

./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
| _asyncToGenerator(function* () {
| try {
        for await (const b of _this12.transport) {
| _this12.parser.parse(b);
| }

Contribution

No response

aricart commented 3 weeks ago

it actually does - and it is bundled with an esm file already

https://github.com/nats-io/nats.ws/blob/40f64a842e34f2b02fdd9acb473a26922fcf0fba/package.json#L10