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

feat(un-es6-class): support extending super class #58

Merged
merged 3 commits into from
Nov 24, 2023
Merged

feat(un-es6-class): support extending super class #58

merged 3 commits into from
Nov 24, 2023

Conversation

g-plane
Copy link
Contributor

@g-plane g-plane commented Nov 22, 2023

This PR only handles extending class (class C extends B {}) but doesn't handle super() call. super() call should be solved in separated PR.

Copy link

vercel bot commented Nov 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wakaru ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 24, 2023 2:26am

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (4f9d9fc) 91.33% compared to head (6332c2c) 91.41%.
Report is 3 commits behind head on main.

Files Patch % Lines
...kages/unminify/src/transformations/un-es6-class.ts 93.02% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   91.33%   91.41%   +0.07%     
==========================================
  Files          82       82              
  Lines       10460    10539      +79     
  Branches     1424     1450      +26     
==========================================
+ Hits         9554     9634      +80     
+ Misses        866      864       -2     
- Partials       40       41       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pionxzh
Copy link
Owner

pionxzh commented Nov 22, 2023

At first, I thought this should be implemented in another way. Finding helper functions like _createClass and _defineProperty is unreliable because minifier will destroy them. Instead, we can do this in the runtime helper transform (code). But these helper functions are too special to be implemented in that way.

This PR can be merged, and we can have another one that adds these helpers into the module scanning, and use the minified name from the module scanning result.

@g-plane
Copy link
Contributor Author

g-plane commented Nov 22, 2023

I see. We can wait for implementing helper functions detecting before merging this PR.

@g-plane g-plane marked this pull request as draft November 22, 2023 13:38
@g-plane
Copy link
Contributor Author

g-plane commented Nov 23, 2023

Helper functions like __extends or _inherits are generated as inline, not imported as modules:

How can we detect them?

@0xdevalias
Copy link

0xdevalias commented Nov 23, 2023

@pionxzh
Copy link
Owner

pionxzh commented Nov 23, 2023

Helper functions like __extends or _inherits are generated as inline, not imported as modules:

How can we detect them?

Based on what I know, helpers can be inlined or extracted. Currently, the module scanning is based on regex matching (see babel reference) which also works for inlined helpers.

These examples have been updated to external-helper mode.

@g-plane
Copy link
Contributor Author

g-plane commented Nov 24, 2023

Babel runtime helpers detection is added.

@pionxzh
Copy link
Owner

pionxzh commented Nov 24, 2023

Seems like these helpers can also be imported from the runtime helpers.

import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";

@pionxzh
Copy link
Owner

pionxzh commented Nov 24, 2023

Oh, super will be handled in another PR, so it doesn't matter. OK OK

@pionxzh pionxzh merged commit 641d463 into pionxzh:main Nov 24, 2023
5 checks passed
@g-plane g-plane deleted the un-es6-class-2 branch November 24, 2023 08:59
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

Successfully merging this pull request may close these issues.

3 participants