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

Draft: Unbundle dependencies #2254

Closed
wants to merge 1 commit into from

Conversation

joshkel
Copy link

@joshkel joshkel commented Jul 19, 2023

Instead of bundling all dependencies into docx's built JS (which is a common approach for browser environments), this lets them be imported through import / require (as is typical with NPM). This reduces the size of docx's builds from ~711kB each to ~250kB each and avoids duplicating code for applications that are already using dependencies such as jszip. It also avoids any Node.js polyfills, which is a mixed bag - that prevents problems such as #2237 but leaves it up to users to provide polyfills themselves if using a browser environment.

Code for listing dependencies is based on https://stackoverflow.com/a/74578129/25507

Instead of bundling all dependencies into docx's built JS (which is a common approach for browser environments), this lets them be imported through import / require (as is typical with NPM).  This reduces the size of docx's builds from ~711kB each to ~250kB each and avoids duplicating code for applications that are already using dependencies such as jszip.  It also avoids any Node.js polyfills, which is a mixed bag - that prevents problems such as dolanmiu#2237 but leaves it up to users to provide polyfills themselves if using a browser environment.

Code for listing dependencies is based on https://stackoverflow.com/a/74578129/25507
@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (95f8e37) 99.93% compared to head (8ac3f2c) 99.93%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2254   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files         329      329           
  Lines       13149    13149           
  Branches     1365     1365           
=======================================
  Hits        13141    13141           
  Misses          8        8           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dolanmiu
Copy link
Owner

What would happen to the umd version of the library?

https://www.unpkg.com/[email protected]/build/index.umd.js

It needs to be bundled for umd i think, so it can be used like so:

https://github.com/dolanmiu/docx/blob/master/demo/browser-demo.html

@dolanmiu
Copy link
Owner

Yeah thought so:

image

Anyway to fix this you think?

@dolanmiu
Copy link
Owner

Closing this

@dolanmiu dolanmiu closed this Jul 21, 2023
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.

2 participants