`Symbol.iterator` should not load full `Symbol` polyfill
// Now:
arr[Symbol.iterator]();
// =>
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
arr[Symbol.iterator]();
es.symbol and es.symbol.description should not be loaded only on Symbol.iterator - it's too expensive. core-js architecture should allow to use es.symbol.iterator and iterators without those modules.
BTW looking at this output - seems after #78 modules sorted in the scope of a feature, but not a file how it should be and if Symbol.iterator would depend on Symbol - it will not work, es.symbol.js should be before the rest modules - it still could cause problems like #77.
Ok so:
- We should only inject
es.symbolif it's used not as part ofSymbol.iterator - If
es.symbolis injected, it should always come beforees.symbol.iterator.
Is this correct?
Btw, I don't think we can always fix the "implicit optional dependency" between those two polyfills:
// main.js
import "./dep1.js";
import "./dep2.js";
// dep1.js
Symbol.iterator;
// dep2.js
Symbol();
Either we always inject an import to es.symbol in dep1.js, or es.symbol.iterator will be imported before es.symbol.
@nicolo-ribaudo I mean that es.symbol before es.symbol.iterator in the recommended modules order. It's not related to this issue, it's related #77 and #78. It should work at least on the file's layer - different files are another problem.
@nicolo-ribaudo Since #192 is closed does it mean that this issue can be closed?
It's another issue.
Working on this
@nicolo-ribaudo note that it also requires some other changes, for example, take a look at
export default function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
that on typeof Symbol !== "undefined" will also load full symbol polyfill, or regeneratorRuntime:
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
It's an extended version of something like #199 and changes of some helpers.