naver / babel-plugin-no-side-effect-class-properties

This plugin transforms static class properties so that side effects do not occur and tree-shaking is activated.
MIT License
11 stars 0 forks source link

Is there any way to change Class.A style to be pure #1

Open liuxinqiong opened 1 year ago

liuxinqiong commented 1 year ago

I am so sorry to write here, because i don't know whether it should be here.

My case is different with that you describe in readme file. I use one third library in my project. The code just like below

class User {}
User.className  = 'User';

Just because of the className setter, break the tree-shaking behavior.

I want to know whether this plugin can handle this. Or any advice for me? Thanks a lot!

daybrush commented 1 year ago

@liuxinqiong

You can use it like a README.

const User2 = /*#__PURE__*/(() => {
  class User {}
  User.className  = 'User';
  return User;
})();