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

refactor: 📦 Generate version.js from package.json #23957

Merged
merged 7 commits into from
May 8, 2020
Merged

Conversation

afc163
Copy link
Member

@afc163 afc163 commented May 8, 2020

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#22698

💡 Background and solution

package.json 本身有一点体积,单独生成 version,可以降低一点包大小。

📝 Changelog

Language Changelog
🇺🇸 English Reduce bundle size via excluding package.json from source code.
🇨🇳 Chinese 源码中不再引用 package.json 从而优化了一点包体积。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

@tests-checker tests-checker bot left a comment

Choose a reason for hiding this comment

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

Could you please add tests to make sure this change works as expected?

@ant-design-bot
Copy link
Contributor

ant-design-bot commented May 8, 2020

@yoyo837
Copy link
Contributor

yoyo837 commented May 8, 2020

我当初以为 #22644 (comment) 这样可以解决。

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 8, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0857c05:

Sandbox Source
antd reproduction template Configuration

@yoyo837
Copy link
Contributor

yoyo837 commented May 8, 2020

我试试看这个方法...

@afc163
Copy link
Member Author

afc163 commented May 8, 2020

require 和 import 这样用没什么本质区别。

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 8, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bd3b9b7:

Sandbox Source
antd reproduction template Configuration

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 8, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit eee1848:

Sandbox Source
antd reproduction template Configuration

@afc163
Copy link
Member Author

afc163 commented May 8, 2020

- 302.54kB
+ 299.68kB

少了 2.8kB。

@codecov
Copy link

codecov bot commented May 8, 2020

Codecov Report

Merging #23957 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #23957   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         364      364           
  Lines        7270     7270           
  Branches     1976     2014   +38     
=======================================
  Hits         7181     7181           
  Misses         89       89           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d578c8...eee1848. Read the comment docs.

@yoyo837
Copy link
Contributor

yoyo837 commented May 8, 2020

webpack遇到require的处理方式看来不能起到tree shaking那样的效果。

@afc163 afc163 mentioned this pull request May 8, 2020
26 tasks
@afc163
Copy link
Member Author

afc163 commented May 8, 2020

是的。

@@ -277,7 +277,7 @@
"bundlesize": [
{
"path": "./dist/antd.min.js",
"maxSize": "305 kB"
"maxSize": "300 kB"
Copy link
Member Author

Choose a reason for hiding this comment

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

回到 300 kB 了。

@afc163 afc163 merged commit d221458 into master May 8, 2020
@afc163 afc163 deleted the package-version branch May 8, 2020 09:49
@pr-triage pr-triage bot removed the PR: unreviewed label May 8, 2020
@pr-triage pr-triage bot added the PR: merged label May 8, 2020
@ycjcl868 ycjcl868 mentioned this pull request May 11, 2020
@Airkro
Copy link
Contributor

Airkro commented May 18, 2020

import { xxx } from '*.json' 是可以树摇的,条件满足的情况下不需要做特别的处理

@yoyo837
Copy link
Contributor

yoyo837 commented May 18, 2020

import { xxx } from '*.json' 是可以树摇的,条件满足的情况下不需要做特别的处理

#22644,为了兼容webpack@5 改掉的

This pull request was closed.
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.

4 participants