Navigation Menu

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

Reduce bundle size of parser-html.js #12176

Merged
merged 2 commits into from Jan 28, 2022

Conversation

sosukesuzuki
Copy link
Member

Description

Before:

$ node ./scripts/build/build.mjs --file=parser-html.js --print-size
 Building packages 
parser-html.js..................................................179 kB    DONE  

After:

$ node ./scripts/build/build.mjs --file=parser-html.js --print-size
 Building packages 
parser-html.js..................................................156 kB    DONE  

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

const arrayToMap = require("./array-to-map.js");

const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes, arrayToMap);

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try use html-elements-attributes.evaluate.js as filename to see if the bundle became smaller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it in my local but bundle size didn't became smaller.

 Building packages 
parser-html.js..................................................156 kB    DONE  

Copy link
Sponsor Member

@fisker fisker Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it's not safe anyway, mapObject use Object.create(null), but turns to JSON will be an normal object

HTML_ELEMENT_ATTRIBUTES.prototype will be truly.


const HTML_TAGS = arrayToMap(htmlTagNames);

module.exports = HTML_TAGS;
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@fisker fisker merged commit ff78a94 into prettier:main Jan 28, 2022
@sosukesuzuki sosukesuzuki deleted the reduce-parser-html-size- branch January 28, 2022 03:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants