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: use enum to replace const enum #9261

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

xiaoxiangmoe
Copy link
Contributor

@xiaoxiangmoe xiaoxiangmoe commented Sep 21, 2023

  • change const enum to enum
  • change const-enum plugin to inline-enum plugin
  • add more types for plugin

@netlify
Copy link

netlify bot commented Sep 21, 2023

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit 884bbce
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/650be692896ec10009cc7a04

@netlify
Copy link

netlify bot commented Sep 21, 2023

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 884bbce
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/650be692703bf70009bf6286

@xiaoxiangmoe xiaoxiangmoe force-pushed the remove-const-enum branch 3 times, most recently from 601be9e to 1b49736 Compare September 21, 2023 07:18
@github-actions
Copy link

github-actions bot commented Sep 21, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 88.8 kB (+2.34 kB) 33.8 kB (+920 B) 30.4 kB (+779 B)
vue.global.prod.js 135 kB (+2.34 kB) 50.6 kB (+934 B) 45.3 kB (+815 B)

Usages

Name Size Gzip Brotli
createApp 48 kB 18.9 kB 17.2 kB
createSSRApp 51.2 kB 20.2 kB 18.4 kB
defineCustomElement 50.4 kB 19.7 kB 18 kB
overall 61.4 kB 23.7 kB 21.6 kB

@sxzz sxzz added the ready to merge The PR is ready to be merged. label Sep 21, 2023
@yangmingshan
Copy link
Contributor

A competition PR #9263 😁

@sxzz sxzz removed the ready to merge The PR is ready to be merged. label Sep 21, 2023
@xiaoxiangmoe
Copy link
Contributor Author

@yangmingshan My PR did not consider enum reverse mapping, which is unsafe. Your PR is more safe.

@xiaoxiangmoe xiaoxiangmoe force-pushed the remove-const-enum branch 4 times, most recently from c045410 to f3092e5 Compare September 26, 2023 06:23
yangmingshan

This comment was marked as resolved.

yangmingshan

This comment was marked as resolved.

@xiaoxiangmoe xiaoxiangmoe force-pushed the remove-const-enum branch 2 times, most recently from 24471b9 to 9992964 Compare September 26, 2023 10:07
@yangmingshan
Copy link
Contributor

yangmingshan commented Sep 26, 2023

@sxzz Can we rerun the size bot? So we can compare the size.

@xiaoxiangmoe
Copy link
Contributor Author

@yangmingshan It's not about vue's size. It's about the size of application which using the new export enum.

@yangmingshan
Copy link
Contributor

@yangmingshan It's not about vue's size. It's about the size of application which using the new export enum.

I think this has a very slight impact on the size of the application.

@xiaoxiangmoe
Copy link
Contributor Author

xiaoxiangmoe commented Sep 26, 2023

Some source code in packages/compiler-core/src/errors.ts
export enum ErrorCodes {
  // parse errors
  ABRUPT_CLOSING_OF_EMPTY_COMMENT,
  CDATA_IN_HTML_CONTENT,
  DUPLICATE_ATTRIBUTE,
  END_TAG_WITH_ATTRIBUTES,
  END_TAG_WITH_TRAILING_SOLIDUS,
  EOF_BEFORE_TAG_NAME,
  EOF_IN_CDATA,
  EOF_IN_COMMENT,
  EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT,
  EOF_IN_TAG,
  INCORRECTLY_CLOSED_COMMENT,
  INCORRECTLY_OPENED_COMMENT,
  INVALID_FIRST_CHARACTER_OF_TAG_NAME,
  MISSING_ATTRIBUTE_VALUE,
  MISSING_END_TAG_NAME,
  MISSING_WHITESPACE_BETWEEN_ATTRIBUTES,
  NESTED_COMMENT,
  UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
  UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
  UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
  UNEXPECTED_NULL_CHARACTER,
  UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,
  UNEXPECTED_SOLIDUS_IN_TAG,

  // Vue-specific parse errors
  X_INVALID_END_TAG,
  X_MISSING_END_TAG,
  X_MISSING_INTERPOLATION_END,
  X_MISSING_DIRECTIVE_NAME,
  X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END,

  // transform errors
  X_V_IF_NO_EXPRESSION,
  X_V_IF_SAME_KEY,
  X_V_ELSE_NO_ADJACENT_IF,
  X_V_FOR_NO_EXPRESSION,
  X_V_FOR_MALFORMED_EXPRESSION,
  X_V_FOR_TEMPLATE_KEY_PLACEMENT,
  X_V_BIND_NO_EXPRESSION,
  X_V_ON_NO_EXPRESSION,
  X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
  X_V_SLOT_MIXED_SLOT_USAGE,
  X_V_SLOT_DUPLICATE_SLOT_NAMES,
  X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN,
  X_V_SLOT_MISPLACED,
  X_V_MODEL_NO_EXPRESSION,
  X_V_MODEL_MALFORMED_EXPRESSION,
  X_V_MODEL_ON_SCOPE_VARIABLE,
  X_V_MODEL_ON_PROPS,
  X_INVALID_EXPRESSION,
  X_KEEP_ALIVE_INVALID_CHILDREN,

  // generic errors
  X_PREFIX_ID_NOT_SUPPORTED,
  X_MODULE_MODE_NOT_SUPPORTED,
  X_CACHE_HANDLER_NOT_SUPPORTED,
  X_SCOPE_ID_NOT_SUPPORTED,

  // deprecations
  DEPRECATION_VNODE_HOOKS,
  DEPRECATION_V_IS,

  // Special value for higher-order compilers to pick up the last code
  // to avoid collision of error codes. This should always be kept as the last
  // item.
  __EXTEND_POINT__
}

Try to code code below to here

https://try.terser.org/

const ErrorCodesObject = {
  "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  "CDATA_IN_HTML_CONTENT": 1,
  "1": "CDATA_IN_HTML_CONTENT",
  "DUPLICATE_ATTRIBUTE": 2,
  "2": "DUPLICATE_ATTRIBUTE",
  "END_TAG_WITH_ATTRIBUTES": 3,
  "3": "END_TAG_WITH_ATTRIBUTES",
  "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  "EOF_BEFORE_TAG_NAME": 5,
  "5": "EOF_BEFORE_TAG_NAME",
  "EOF_IN_CDATA": 6,
  "6": "EOF_IN_CDATA",
  "EOF_IN_COMMENT": 7,
  "7": "EOF_IN_COMMENT",
  "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  "EOF_IN_TAG": 9,
  "9": "EOF_IN_TAG",
  "INCORRECTLY_CLOSED_COMMENT": 10,
  "10": "INCORRECTLY_CLOSED_COMMENT",
  "INCORRECTLY_OPENED_COMMENT": 11,
  "11": "INCORRECTLY_OPENED_COMMENT",
  "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  "MISSING_ATTRIBUTE_VALUE": 13,
  "13": "MISSING_ATTRIBUTE_VALUE",
  "MISSING_END_TAG_NAME": 14,
  "14": "MISSING_END_TAG_NAME",
  "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  "NESTED_COMMENT": 16,
  "16": "NESTED_COMMENT",
  "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  "UNEXPECTED_NULL_CHARACTER": 20,
  "20": "UNEXPECTED_NULL_CHARACTER",
  "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  "X_INVALID_END_TAG": 23,
  "23": "X_INVALID_END_TAG",
  "X_MISSING_END_TAG": 24,
  "24": "X_MISSING_END_TAG",
  "X_MISSING_INTERPOLATION_END": 25,
  "25": "X_MISSING_INTERPOLATION_END",
  "X_MISSING_DIRECTIVE_NAME": 26,
  "26": "X_MISSING_DIRECTIVE_NAME",
  "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  "X_V_IF_NO_EXPRESSION": 28,
  "28": "X_V_IF_NO_EXPRESSION",
  "X_V_IF_SAME_KEY": 29,
  "29": "X_V_IF_SAME_KEY",
  "X_V_ELSE_NO_ADJACENT_IF": 30,
  "30": "X_V_ELSE_NO_ADJACENT_IF",
  "X_V_FOR_NO_EXPRESSION": 31,
  "31": "X_V_FOR_NO_EXPRESSION",
  "X_V_FOR_MALFORMED_EXPRESSION": 32,
  "32": "X_V_FOR_MALFORMED_EXPRESSION",
  "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  "X_V_BIND_NO_EXPRESSION": 34,
  "34": "X_V_BIND_NO_EXPRESSION",
  "X_V_ON_NO_EXPRESSION": 35,
  "35": "X_V_ON_NO_EXPRESSION",
  "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  "X_V_SLOT_MISPLACED": 40,
  "40": "X_V_SLOT_MISPLACED",
  "X_V_MODEL_NO_EXPRESSION": 41,
  "41": "X_V_MODEL_NO_EXPRESSION",
  "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  "X_V_MODEL_ON_PROPS": 44,
  "44": "X_V_MODEL_ON_PROPS",
  "X_INVALID_EXPRESSION": 45,
  "45": "X_INVALID_EXPRESSION",
  "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  "X_PREFIX_ID_NOT_SUPPORTED": 47,
  "47": "X_PREFIX_ID_NOT_SUPPORTED",
  "X_MODULE_MODE_NOT_SUPPORTED": 48,
  "48": "X_MODULE_MODE_NOT_SUPPORTED",
  "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  "X_SCOPE_ID_NOT_SUPPORTED": 50,
  "50": "X_SCOPE_ID_NOT_SUPPORTED",
  "DEPRECATION_VNODE_HOOKS": 51,
  "51": "DEPRECATION_VNODE_HOOKS",
  "DEPRECATION_V_IS": 52,
  "52": "DEPRECATION_V_IS",
  "__EXTEND_POINT__": 53,
  "53": "__EXTEND_POINT__"
};

var ErrorCodes;
(function (ErrorCodes) {
    // parse errors
    ErrorCodes[ErrorCodes["ABRUPT_CLOSING_OF_EMPTY_COMMENT"] = 0] = "ABRUPT_CLOSING_OF_EMPTY_COMMENT";
    ErrorCodes[ErrorCodes["CDATA_IN_HTML_CONTENT"] = 1] = "CDATA_IN_HTML_CONTENT";
    ErrorCodes[ErrorCodes["DUPLICATE_ATTRIBUTE"] = 2] = "DUPLICATE_ATTRIBUTE";
    ErrorCodes[ErrorCodes["END_TAG_WITH_ATTRIBUTES"] = 3] = "END_TAG_WITH_ATTRIBUTES";
    ErrorCodes[ErrorCodes["END_TAG_WITH_TRAILING_SOLIDUS"] = 4] = "END_TAG_WITH_TRAILING_SOLIDUS";
    ErrorCodes[ErrorCodes["EOF_BEFORE_TAG_NAME"] = 5] = "EOF_BEFORE_TAG_NAME";
    ErrorCodes[ErrorCodes["EOF_IN_CDATA"] = 6] = "EOF_IN_CDATA";
    ErrorCodes[ErrorCodes["EOF_IN_COMMENT"] = 7] = "EOF_IN_COMMENT";
    ErrorCodes[ErrorCodes["EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT"] = 8] = "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT";
    ErrorCodes[ErrorCodes["EOF_IN_TAG"] = 9] = "EOF_IN_TAG";
    ErrorCodes[ErrorCodes["INCORRECTLY_CLOSED_COMMENT"] = 10] = "INCORRECTLY_CLOSED_COMMENT";
    ErrorCodes[ErrorCodes["INCORRECTLY_OPENED_COMMENT"] = 11] = "INCORRECTLY_OPENED_COMMENT";
    ErrorCodes[ErrorCodes["INVALID_FIRST_CHARACTER_OF_TAG_NAME"] = 12] = "INVALID_FIRST_CHARACTER_OF_TAG_NAME";
    ErrorCodes[ErrorCodes["MISSING_ATTRIBUTE_VALUE"] = 13] = "MISSING_ATTRIBUTE_VALUE";
    ErrorCodes[ErrorCodes["MISSING_END_TAG_NAME"] = 14] = "MISSING_END_TAG_NAME";
    ErrorCodes[ErrorCodes["MISSING_WHITESPACE_BETWEEN_ATTRIBUTES"] = 15] = "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES";
    ErrorCodes[ErrorCodes["NESTED_COMMENT"] = 16] = "NESTED_COMMENT";
    ErrorCodes[ErrorCodes["UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME"] = 17] = "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME";
    ErrorCodes[ErrorCodes["UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE"] = 18] = "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE";
    ErrorCodes[ErrorCodes["UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME"] = 19] = "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME";
    ErrorCodes[ErrorCodes["UNEXPECTED_NULL_CHARACTER"] = 20] = "UNEXPECTED_NULL_CHARACTER";
    ErrorCodes[ErrorCodes["UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME"] = 21] = "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME";
    ErrorCodes[ErrorCodes["UNEXPECTED_SOLIDUS_IN_TAG"] = 22] = "UNEXPECTED_SOLIDUS_IN_TAG";
    // Vue-specific parse errors
    ErrorCodes[ErrorCodes["X_INVALID_END_TAG"] = 23] = "X_INVALID_END_TAG";
    ErrorCodes[ErrorCodes["X_MISSING_END_TAG"] = 24] = "X_MISSING_END_TAG";
    ErrorCodes[ErrorCodes["X_MISSING_INTERPOLATION_END"] = 25] = "X_MISSING_INTERPOLATION_END";
    ErrorCodes[ErrorCodes["X_MISSING_DIRECTIVE_NAME"] = 26] = "X_MISSING_DIRECTIVE_NAME";
    ErrorCodes[ErrorCodes["X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END"] = 27] = "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END";
    // transform errors
    ErrorCodes[ErrorCodes["X_V_IF_NO_EXPRESSION"] = 28] = "X_V_IF_NO_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_IF_SAME_KEY"] = 29] = "X_V_IF_SAME_KEY";
    ErrorCodes[ErrorCodes["X_V_ELSE_NO_ADJACENT_IF"] = 30] = "X_V_ELSE_NO_ADJACENT_IF";
    ErrorCodes[ErrorCodes["X_V_FOR_NO_EXPRESSION"] = 31] = "X_V_FOR_NO_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_FOR_MALFORMED_EXPRESSION"] = 32] = "X_V_FOR_MALFORMED_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_FOR_TEMPLATE_KEY_PLACEMENT"] = 33] = "X_V_FOR_TEMPLATE_KEY_PLACEMENT";
    ErrorCodes[ErrorCodes["X_V_BIND_NO_EXPRESSION"] = 34] = "X_V_BIND_NO_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_ON_NO_EXPRESSION"] = 35] = "X_V_ON_NO_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET"] = 36] = "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET";
    ErrorCodes[ErrorCodes["X_V_SLOT_MIXED_SLOT_USAGE"] = 37] = "X_V_SLOT_MIXED_SLOT_USAGE";
    ErrorCodes[ErrorCodes["X_V_SLOT_DUPLICATE_SLOT_NAMES"] = 38] = "X_V_SLOT_DUPLICATE_SLOT_NAMES";
    ErrorCodes[ErrorCodes["X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN"] = 39] = "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN";
    ErrorCodes[ErrorCodes["X_V_SLOT_MISPLACED"] = 40] = "X_V_SLOT_MISPLACED";
    ErrorCodes[ErrorCodes["X_V_MODEL_NO_EXPRESSION"] = 41] = "X_V_MODEL_NO_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_MODEL_MALFORMED_EXPRESSION"] = 42] = "X_V_MODEL_MALFORMED_EXPRESSION";
    ErrorCodes[ErrorCodes["X_V_MODEL_ON_SCOPE_VARIABLE"] = 43] = "X_V_MODEL_ON_SCOPE_VARIABLE";
    ErrorCodes[ErrorCodes["X_V_MODEL_ON_PROPS"] = 44] = "X_V_MODEL_ON_PROPS";
    ErrorCodes[ErrorCodes["X_INVALID_EXPRESSION"] = 45] = "X_INVALID_EXPRESSION";
    ErrorCodes[ErrorCodes["X_KEEP_ALIVE_INVALID_CHILDREN"] = 46] = "X_KEEP_ALIVE_INVALID_CHILDREN";
    // generic errors
    ErrorCodes[ErrorCodes["X_PREFIX_ID_NOT_SUPPORTED"] = 47] = "X_PREFIX_ID_NOT_SUPPORTED";
    ErrorCodes[ErrorCodes["X_MODULE_MODE_NOT_SUPPORTED"] = 48] = "X_MODULE_MODE_NOT_SUPPORTED";
    ErrorCodes[ErrorCodes["X_CACHE_HANDLER_NOT_SUPPORTED"] = 49] = "X_CACHE_HANDLER_NOT_SUPPORTED";
    ErrorCodes[ErrorCodes["X_SCOPE_ID_NOT_SUPPORTED"] = 50] = "X_SCOPE_ID_NOT_SUPPORTED";
    // deprecations
    ErrorCodes[ErrorCodes["DEPRECATION_VNODE_HOOKS"] = 51] = "DEPRECATION_VNODE_HOOKS";
    ErrorCodes[ErrorCodes["DEPRECATION_V_IS"] = 52] = "DEPRECATION_V_IS";
    // Special value for higher-order compilers to pick up the last code
    // to avoid collision of error codes. This should always be kept as the last
    // item.
    ErrorCodes[ErrorCodes["__EXTEND_POINT__"] = 53] = "__EXTEND_POINT__";
})(ErrorCodes || (ErrorCodes = {}));

console.log(ErrorCodesObject.ABRUPT_CLOSING_OF_EMPTY_COMMENT)
console.log(ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT)

Then you can see result

var _;!function(_){_[_.ABRUPT_CLOSING_OF_EMPTY_COMMENT=0]="ABRUPT_CLOSING_OF_EMPTY_COMMENT", 
// more than 3KiB size of code here
}(_||(_={})),

console.log(0),
console.log(_.ABRUPT_CLOSING_OF_EMPTY_COMMENT);

If some application user use enum export in vue, it will increase many size.
For example, it someone only use ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT in his application, it will increase more than 3KiB in his app.
So we should convert enum to object to make it uglify friendly.

@yangmingshan
Copy link
Contributor

yangmingshan commented Sep 26, 2023

I'm not sure if bundler and minifier can handle it perfectly (cross module boundary). But yeah, I get the idea.

yangmingshan

This comment was marked as resolved.

@xiaoxiangmoe
Copy link
Contributor Author

xiaoxiangmoe commented Sep 26, 2023

I'm not sure if bundler and minifier can handle it perfectly (cross module boundary). But yeah, I get the idea.

You can try it

import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [],
  build: {
    minify: 'terser'
  }
})

And add code to here
image

image

The generated result is:
image

@sxzz
Copy link
Member

sxzz commented Sep 26, 2023

@sxzz Can we rerun the size bot? So we can compare the size.

Done.

@yangmingshan
Copy link
Contributor

LGTM

scripts/simplify-enum.js Outdated Show resolved Hide resolved
@sxzz
Copy link
Member

sxzz commented Sep 28, 2023

Should we always export enums? The bundle size of the browser version increased ~750b
/cc @yyx990803

@xiaoxiangmoe xiaoxiangmoe requested a review from sxzz October 4, 2023 09:54
@sxzz sxzz added 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews labels Nov 2, 2023
@xiaoxiangmoe xiaoxiangmoe force-pushed the remove-const-enum branch 3 times, most recently from 07c6b95 to 48ce2e2 Compare November 8, 2023 09:30
@yyx990803 yyx990803 changed the base branch from main to minor November 29, 2023 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants