emberjs / ember-cli-babel

Ember CLI plugin for Babel
MIT License
153 stars 119 forks source link

Size increase with patch increments (7.20.1+) #347

Closed mydea closed 3 years ago

mydea commented 4 years ago

Not sure if this is to be expected, so I thought I'd bring it up just to be sure. I just noticed that the latest patch-level increases brought some small-but-noticeable size increases for our app.

It's not the end of the world, but I was a bit surprised :)

rwjblue commented 4 years ago

Just to confirm, these are the production build sizes?

rwjblue commented 4 years ago

@mydea - Can you test with ember-cli-babel@7.20.5? The issue mentioned in #348 would increase the total size of your build output (because it would be using Ember.whatever.apply in all cases (if any needed .apply). I'm not 100% sure that is the cause of the growth, but it seems like a plausible guess.


In general, the basic thing being done doesn't change (we just do it more correctly now than we did in ember-cli-babel@7.20.0 and older). So if #348 is not bringing the sizes back in line with the 7.20.0 numbers, the cause may be in changes in Babel transpilation due to getting Babel 7.10.

boris-petrov commented 4 years ago

@rwjblue - I also noticed the boost in bundle sizes. 7.20.5 doesn't fix the issue - it's similar to 7.20.1+.

mydea commented 4 years ago

Yeah, that is production builds.

With 7.20.5, I see the same increase.

rwjblue commented 4 years ago

Can y’all confirm what your @babel/preset-env versions are in both the comparisons? Like I mentioned above, the transpilation output from our Babel plugins did not substantially change so some other change (barring bugs) is causing this.

It would be useful if you could do a diff of the production build output without minification, to actually see what the changes are (don’t have to share the whole diff but you should be able to share snippets that are representative of the inceases).

boris-petrov commented 4 years ago

@rwjblue - I just made 2 non-minified production builds, one with latest everything and the other with babel-plugin-ember-modules-api-polyfill@2.13.0 and ember-cli-babel@7.20.0. This is what you wanted, right? There are a bunch of differences like this:

var _class2, _descriptor, _descriptor2, _temp;

let _class = (_class2 = (_temp = class _class2 extends _baseOperation.default {
var _dec, _dec2, _class2, _descriptor, _descriptor2, _temp;

let _class = (_dec = Ember.inject.service, _dec2 = Ember.inject.service, (_class2 = (_temp = class _class2 extends _baseOperation.default {

The second one being the one with all versions at their latest.

P.S. Below, these seem to be used respectively like so:

  }, _temp), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "foo", [Ember.inject.service], {
    configurable: true,
    enumerable: true,
    writable: true,
    initializer: null
  }), _descriptor2 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "bar", [Ember.inject.service], {
    configurable: true,
    enumerable: true,
    writable: true,
    initializer: null
  })), _class2);
  }, _temp), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "foo", [_dec], {
    configurable: true,
    enumerable: true,
    writable: true,
    initializer: null
  }), _descriptor2 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "bar", [_dec2], {
    configurable: true,
    enumerable: true,
    writable: true,
    initializer: null
  })), _class2));
rwjblue commented 4 years ago

Gotcha, if the cause of the size increase is a change in the output like the ones you've shown above @boris-petrov then this isn't really an ember-cli-babel issue itself. Instead it is a change in the @babel/preset-env + @babel/plugin-proposal-decorators output.

@boris-petrov / @mydea - Can you share the yarn why @babel/preset-env and yarn why @babel/plugin-proposal-decorators output for both the "before" and "after"? This info will help us track down which change in babel/babel introduced the change in output...

boris-petrov commented 4 years ago

@rwjblue - I think I'm doing this right. "Before":

% yarn why @babel/preset-env
yarn why v1.22.4
[1/4] Why do we have the module "@babel/preset-env"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/preset-env@7.10.0"
info Reasons this module exists
   - "ember-auto-import" depends on it
   - Hoisted from "ember-auto-import#@babel#preset-env"
   - Hoisted from "ember-cli-babel#@babel#preset-env"
info Disk size without dependencies: "224KB"
info Disk size with unique dependencies: "3.66MB"
info Disk size with transitive dependencies: "18.84MB"
info Number of shared dependencies: 110
Done in 1.08s.

% yarn why @babel/plugin-proposal-decorators
yarn why v1.22.4
[1/4] Why do we have the module "@babel/plugin-proposal-decorators"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/plugin-proposal-decorators@7.10.0"
info Reasons this module exists
   - "ember-cli-babel" depends on it
   - Hoisted from "ember-cli-babel#@babel#plugin-proposal-decorators"
info Disk size without dependencies: "28KB"
info Disk size with unique dependencies: "144KB"
info Disk size with transitive dependencies: "10.45MB"
info Number of shared dependencies: 29
Done in 1.04s.

"After":

% yarn why @babel/preset-env
yarn why v1.22.4
[1/4] Why do we have the module "@babel/preset-env"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/preset-env@7.10.2"
info Reasons this module exists
   - "ember-auto-import" depends on it
   - Hoisted from "ember-auto-import#@babel#preset-env"
   - Hoisted from "ember-cli-babel#@babel#preset-env"
info Disk size without dependencies: "224KB"
info Disk size with unique dependencies: "3.67MB"
info Disk size with transitive dependencies: "18.85MB"
info Number of shared dependencies: 110
Done in 1.14s.

% yarn why @babel/plugin-proposal-decorators
yarn why v1.22.4
[1/4] Why do we have the module "@babel/plugin-proposal-decorators"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/plugin-proposal-decorators@7.10.1"
info Reasons this module exists
   - "ember-cli-babel" depends on it
   - Hoisted from "ember-cli-babel#@babel#plugin-proposal-decorators"
info Disk size without dependencies: "28KB"
info Disk size with unique dependencies: "148KB"
info Disk size with transitive dependencies: "10.45MB"
info Number of shared dependencies: 29
Done in 1.01s.
mydea commented 4 years ago

Before:

yarn why @babel/preset-env
yarn why v1.22.4
[1/4] Why do we have the module "@babel/preset-env"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/preset-env@7.9.5"
info Reasons this module exists
   - "ember-auto-import" depends on it
   - Hoisted from "ember-auto-import#@babel#preset-env"
   - Hoisted from "ember-cli-babel#@babel#preset-env"
   - Hoisted from "ember-a11y-testing#ember-cli-babel#@babel#preset-env"
info Disk size without dependencies: "1.31MB"
info Disk size with unique dependencies: "12.93MB"
info Disk size with transitive dependencies: "39.18MB"
info Number of shared dependencies: 115
Done in 1.48s.

yarn why @babel/plugin-proposal-decorators
yarn why v1.22.4
[1/4] Why do we have the module "@babel/plugin-proposal-decorators"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/plugin-proposal-decorators@7.8.3"
info Reasons this module exists
   - "ember-cli-babel" depends on it
   - Hoisted from "ember-cli-babel#@babel#plugin-proposal-decorators"
   - Hoisted from "ember-a11y-testing#ember-cli-babel#@babel#plugin-proposal-decorators"
info Disk size without dependencies: "28KB"
info Disk size with unique dependencies: "140KB"
info Disk size with transitive dependencies: "12.8MB"
info Number of shared dependencies: 31
Done in 0.79s.

After:

yarn why @babel/preset-env
yarn why v1.22.4
[1/4] Why do we have the module "@babel/preset-env"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/preset-env@7.9.5"
info Reasons this module exists
   - "ember-auto-import" depends on it
   - Hoisted from "ember-auto-import#@babel#preset-env"
   - Hoisted from "ember-cli-babel#@babel#preset-env"
   - Hoisted from "ember-a11y-testing#ember-cli-babel#@babel#preset-env"
info Disk size without dependencies: "1.31MB"
info Disk size with unique dependencies: "12.93MB"
info Disk size with transitive dependencies: "39.18MB"
info Number of shared dependencies: 115
Done in 1.54s.

yarn why @babel/plugin-proposal-decorators
yarn why v1.22.4
[1/4] Why do we have the module "@babel/plugin-proposal-decorators"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/plugin-proposal-decorators@7.8.3"
info Reasons this module exists
   - "ember-cli-babel" depends on it
   - Hoisted from "ember-cli-babel#@babel#plugin-proposal-decorators"
   - Hoisted from "ember-a11y-testing#ember-cli-babel#@babel#plugin-proposal-decorators"
info Disk size without dependencies: "28KB"
info Disk size with unique dependencies: "140KB"
info Disk size with transitive dependencies: "12.8MB"
info Number of shared dependencies: 31
Done in 0.79s.

So they don't seem to change for me when only updating ember-cli-babel (via dependabot).