canjs icon indicating copy to clipboard operation
canjs copied to clipboard

Reduce the size of the `can` package

Open justinbmeyer opened this issue 7 years ago • 12 comments

The can package is over 80MB. Most of this (~72MB) is from the doc folder.

For CanJS 5, I think we should remove the doc folder from what we publish. This was ok before 5 because no one really installed the can package.

Now, we are encouraging that.

We can figure out how to provide the docs for a specific version later. For now I think we should .npmignore:

  • doc/ 70MB
  • index.html 37K
  • demos/ 0.5MB
  • dev-bundle.js 4MB

Useful: https://docs.npmjs.com/misc/developers#testing-whether-your-npmignore-or-files-config-works

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

Here are the sizes of our dependencies in KB:

du -sk * | sort -n | tail -r

81976	can
3316	can-debug
1132	validate.js
860	can-connect
856	can-util
800	can-ndjson-stream
780	kefir
728	can-stache
588	can-query-logic
564	can-define
412	can-simple-dom
384	can-connect-feathers
340	can-queues
320	can-component
312	can-observe
272	can-stache-bindings
268	can-fixture
260	can-reflect
256	feathers-authentication-popups
232	simple-html-tokenizer
232	can-validate-legacy
220	can-route
216	can-set-legacy
212	feathers-errors
208	can-symbol
208	can-event-queue
200	can-value
188	can-bind
184	can-key
180	can-view-scope
172	can-compute
164	can-view-live
152	can-globals
148	can-map-define
148	can-map
144	can-diff
132	can-view-parser
124	can-stache-converters
124	can-list
124	can-key-tree
124	can-control
120	can-dom-events
116	he
112	can-ajax
108	can-view-import
108	can-kefir
104	events
104	debug
104	can-simple-observable
104	can-observation
100	can-view-callbacks
100	can-validate
100	can-route-pushstate
100	can-fixture-socket
96	can-stream
88	can-observation-recorder
84	can-zone-storage
84	can-view-nodelist
84	can-view-autorender
84	can-rest-model
84	can-local-store
84	can-construct
84	can-connect-tag
84	can-attribute-observable
80	can-vdom
80	can-super-model
80	can-realtime-rest-model
80	can-memory-store
80	can-data-types
80	can-cid
76	jwt-decode
76	can-reflect-dependencies
76	can-define-stream-kefir
76	can-define-stream
72	steal-stache
72	can-single-reference
72	can-log
72	can-fragment
72	can-event-dom-enter
72	can-dom-mutate
72	can-child-nodes
68	can-string-to-any
68	can-stache-key
68	can-param
68	can-join-uris
64	can-stache-ast
64	can-simple-map
64	can-parse-uri
64	can-import-module
64	can-deparam
64	can-define-lazy-value
60	can-stream-kefir
60	can-stache-route-helpers
60	can-reflect-promise
60	can-dom-data
60	can-define-validate-validatejs
60	can-define-backup
56	can-make-rest
56	can-construct-super
56	can-assign
52	can-view-target
52	can-validate-validatejs
52	can-types
52	can-string
52	can-event-dom-radiochange
48	can-view-model
48	can-stache-helpers
48	can-sort-object
48	can-dom-data-state
48	can-attribute-encoder
44	steal-config-utils
44	can-validate-interface
40	symbol-observable
32	can-namespace
24	micro-location
16	ms

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

@m-mujica should it be possible to decrease the size of can-debug?

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

https://github.com/canjs/can-ndjson-stream/issues/35

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

We should probably take a look at anything we own > 250k. It probably means it has a build still:

  • [ ] 81976 can
  • [ ] 3316 can-debug
  • [ ] 1132 validate.js
  • [ ] 860 can-connect
  • [ ] 856 can-util
  • [ ] 800 can-ndjson-stream
  • [ ] 780 kefir
  • [ ] 728 can-stache
  • [ ] 588 can-query-logic
  • [ ] 564 can-define
  • [ ] 412 can-simple-dom
  • [ ] 384 can-connect-feathers
  • [ ] 340 can-queues
  • [ ] 320 can-component
  • [ ] 312 can-observe
  • [ ] 272 can-stache-bindings
  • [ ] 268 can-fixture
  • [ ] 260 can-reflect

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

I wish we could ignore test files. In the case of can-component it was 124k of its 320k

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

ugg ... I just realized we can't ignore docs because they are used to build the site ...

I wonder if canjs/canjs should eventually work differently ... install from github tags to build its site.

justinbmeyer avatar Jul 03 '18 00:07 justinbmeyer

Perfect use case for submodules!

matthewp avatar Jul 03 '18 00:07 matthewp

Yeah, we used to use submodules. I'm not sure how I feel about going back to that. Packages are more explicit.

justinbmeyer avatar Jul 04 '18 01:07 justinbmeyer

There's also https://github.com/lerna/lerna . Something to consider.

green3g avatar Sep 12 '18 14:09 green3g

There's also https://github.com/lerna/lerna . Something to consider.

Related: https://github.com/canjs/canjs/issues/4235

bmomberger-bitovi avatar Sep 12 '18 16:09 bmomberger-bitovi

To solve this:

  1. have a script copy git tag into node_modules.
  2. Run tests and produce docs

Then go back individual packages and .npmignore tests and docs.

One possible issue ... "git" install might take a LONG time on travis

justinbmeyer avatar Oct 17 '18 21:10 justinbmeyer

the documentation should simply be in a extra repository and that should simply be able to checkout any version of canjs/canjs and create the documentation.

frank-dspeed avatar Apr 17 '19 05:04 frank-dspeed