Skip to content
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

make rx-stomp-rpc ESM conform #549

Open
Michael-Stade opened this issue Feb 9, 2024 · 2 comments
Open

make rx-stomp-rpc ESM conform #549

Michael-Stade opened this issue Feb 9, 2024 · 2 comments

Comments

@Michael-Stade
Copy link

Including @stomp into an Angular17 project is leading to following warning:

  • [WARNING] Module 'uuid' used by 'node_modules/@stomp/rx-stomp/esm6/rx-stomp-rpc.js' is not ESM
  • CommonJS or AMD dependencies can cause optimization bailouts.
  • For more information see: https://angular.io/guide/build#configuring-commonjs-dependencies
    I could fix this in file rx-stomp-rpc.js by replacing:
  • import { v4 as uuid } from 'uuid';
    by insert the v4() function from the uuid module (and rename it to "uuid").
    But because the files in the esm6 folder are not subject of changes here, please find a solution to fix it
    Best regards
    Michael Stade
@kum-deepak
Copy link
Member

Thank you for your report. I need clarification about your changes. Please let me know the older version and what you replaced it with. Better yet, please submit a PR (even if you directly update the files in the esm6 folder).

@Michael-Stade
Copy link
Author

@kum-deepak
Because the token I created didn't got accepted, here what I did:
In rx-stomp project: file esm6/rx-stomp-rpc.js:

import { filter, first, Observable } from 'rxjs';
//import { v4 as uuid } from 'uuid';

/**

  • This uuid() function is a copy (and re-naming) of the the v4() function from uuid/v4.js
  • it removes the following warning by Angular17:
  • [WARNING] Module 'uuid' used by 'node_modules/@stomp/rx-stomp/esm6/rx-stomp-rpc.js' is not ESM
  • CommonJS or AMD dependencies can cause optimization bailouts.
  • For more information see: https://angular.io/guide/build#configuring-commonjs-dependencies
  • make rx-stomp-rpc ESM conform make rx-stomp-rpc ESM conform #549
    */function uuid(options, buf, offset) {
    var i = buf && offset || 0;

if (typeof(options) == 'string') {
buf = options === 'binary' ? new Array(16) : null;
options = null;
}
options = options || {};

var rnds = options.random || (options.rng || rng)();

// Per 4.4, set bits for version and clock_seq_hi_and_reserved
rnds[6] = (rnds[6] & 0x0f) | 0x40;
rnds[8] = (rnds[8] & 0x3f) | 0x80;

// Copy bytes to buffer, if provided
if (buf) {
for (var ii = 0; ii < 16; ++ii) {
buf[i + ii] = rnds[ii];
}
}

return buf || bytesToUuid(rnds);
}

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

No branches or pull requests

2 participants