question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate core-js module in the app's prod bundle due to polyfilling

See original GitHub issue

Describe the bug

After upgrading next-i18next from version 0.18.1, I’ve started seeing two copies of core-js in my prod bundle. This may be related to the fact that it’s in next-i18next’s dependencies and is also because of @babel/polyfill in .babelrc (9c96479e).

Before / after:

screenshot 2019-02-03 at 16 53 06 screenshot 2019-02-03 at 16 53 15

The problem may be to do with the fact that core-js is now used as both an es module and a commonjs one by webpack when the app is built.

Occurs in next-i18next version

0.20.0…0.25.0

Steps to reproduce

Run bundle analyzer for the Next.js app

OS (please complete the following information)

  • Device: MBP 2017 15"
  • Browser: N/A

Additional context

Perhaps, polyfilling should be removed from the library completely – doing it only once on the app level ensures that it’s not done twice and so there are no duplicate items in the final bundle. As a replacement, the README could advise on what an app developer should do to support older browsers. Some thoughts are here: https://github.com/isaachinman/next-i18next/issues/107

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
capellinicommented, Feb 3, 2019

polyfilling for that browser can be done on the app level rather than when building the library

I agree. I think that polyfilling and determining what browsers to support should be made at the app-level.

0reactions
isaachinmancommented, Feb 4, 2019

Fixed with 4bf9d37. Hoping to release this at the same time as the rollup work so that there won’t be a lapse in ES5 support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate core-js module in the app's prod bundle due to ...
Describe the bug After upgrading next-i18next from version 0.18.1, I've started seeing two copies of core-js in my prod bundle.
Read more >
Module not found: Error: Can't resolve 'core-js/es6'
Ended up to have a file named polyfill.js in projectpath\src\polyfill.js That file only contains this line: import 'core-js'; this polyfills ...
Read more >
[AskJS] Is it just me or is core-js fundamentally broken?
Bundle growth seems to be logarithmic; the first polyfill adds a sizeable chunk of code due to its internal dependencies, but subsequent ...
Read more >
Bundle analysis deep-dive - how to remove a megabyte of ...
I deep dive into a rollup bundle to eliminate megabytes of duplicated and redundant JS code in a VueJS app.
Read more >
babel/preset-env - Babel 中文文档
This both makes your life easier and JavaScript bundles smaller! ... of those syntaxes and features to Babel transform plugins and core-js polyfills....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found