Skip to content

Check for unneeded polyfills in compressed chunks? #9965

@cpcallen

Description

@cpcallen

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

While reviewing / updating #9921, I noticed that the blockly_compressed.js chunk contains about 14 .5 KiB of polyfills, beginning with

M=M||{};M.scope={};M.ASSUME_ES5=!1;M.ASSUME_ES6=!1;M.ASSUME_ES2020=!1;
M.ASSUME_NO_NATIVE_MAP=!1;M.ASSUME_NO_NATIVE_SET=!1;M.ISOLATE_POLYFILLS=!1;M.FORCE_POLYFILL_PROMISE=!1;M.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;M.INSTRUMENT_ASYNC_CONTEXT=!0;M.objectCreate=M.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(a){function b(){}b.prototype=a;return new b};M.defineProperty=M.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};

Given that build_tasks.mjs configures Closure Compiler with language_out: 'ECMASCRIPT_2015' it's not clear why it creates objectCreate and defineProperty functions that polyfill Object.create or Object.defineProperties (both of which were in ES5), though these are helper functions only used to define other polyfills for methods not in ES6 / ES2015.

The more interesting (and longer) bit is that it defines polyfills for a bunch of other language features defined in ECMAScript 2016–2020. A quick check suggests that we are actually using these features (e.g. Array.prototype.includes, but it might be worth checking.

It also might also be worth checking if language_out can be updated to a more recent ECMAScript version, which would eliminate the need to polyfill older features—though obviously this depends on what is actually supported by browsers that Blockly targets.

See also #6330.

Priority

This is a low priority item. The 14 KiB isn't nothing but it also isn't worth a great deal of effort.

This issue is filed mainly for the record; it would probably be better to devote time to #7449 instead, which envisions ceasing to publish compressed bundles entirely and instead leave leave minification decisions to app authors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugDescribes why the code or behaviour is wrongissue: triageIssues awaiting triage by a Blockly team member

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions