-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
is version 2 bigger bundle? #886
Comments
My guess is that BundlePhobia doesn't factor in lazy loading. It probably just sees the |
Ok so it seems like I haven't quite implemented lazy players correctly. Babel compiles these lines: into this: {
key: 'youtube',
canPlay: function canPlay(url) {
return _patterns.MATCH_URL_YOUTUBE.test(url);
},
lazyPlayer: (0, _react.lazy)(function () {
return Promise.resolve().then(function () {
return _interopRequireWildcard(require('./YouTube'));
});
})
} I'm guessing for lazy loading to work it need to remain as {
key: 'youtube',
canPlay: function canPlay(url) {
return _patterns.MATCH_URL_YOUTUBE.test(url);
},
lazyPlayer: (0, _react.lazy)(function () {
return import('./YouTube');
})
} The problem is that every player is then added as a chunk to the build, as there's no way of knowing at build time what players will be used. Maybe that's ok, but maybe I need to consider bringing back individual player imports… |
As far as I know, multiple chunks is the way it's supposed to be. |
@shaulgo Try building with |
Good to know! I'll work on getting this out. @shaulgo @ovbm Can you forsee any issues leaving Relevant comment: babel/babel#10273 (comment) |
Note that from I'm not considering it a breaking change as things won't actually break – the only impact will be a slightly bigger bundle size until you start importing from I've added clarification to the readme to only use it if your build pipeline supports dynamic It's also worth noting that the BundlePhobia size will now go back up to ~17kb gzipped as the default import still includes logic for all players. |
Fixes cookpete/react-player#886 @babel/preset-env@7.5 added `@babel/plugin-proposal-dynamic-import`, which transformed the `import()` statements More info: babel/babel#10273 (comment)
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
Fixes cookpete/react-player#886 @babel/preset-env@7.5 added `@babel/plugin-proposal-dynamic-import`, which transformed the `import()` statements More info: babel/babel#10273 (comment)
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
@cookpete @shaulgo I was reading the issue and new to this computer world. |
Fixes cookpete/react-player#886 @babel/preset-env@7.5 added `@babel/plugin-proposal-dynamic-import`, which transformed the `import()` statements More info: babel/babel#10273 (comment)
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
Hey, I thought version 2 came to improve bundle size by using the lazy loading of players. But bundlephobia seems to disagree. Is there more too it?
thanks :)
https://bundlephobia.com/result?p=react-player@2.0.1
The text was updated successfully, but these errors were encountered: