I was investigating Magento 2’s TinyMCE implementation the other day, and came across this
#File: vendor/magento//magento2-base/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js
define([
'jquery',
'underscore',
'tinymce',
'mage/translate',
'prototype',
'mage/adminhtml/events',
'mage/adminhtml/browser'
], function(jQuery, _, tinyMCE) {
tinyMceWysiwygSetup = Class.create();
//...
});
The TinyMCE RequireJS setup module was referencing a Class
object – but there was no such object imported in the list of module dependencies.
I was flummoxed as to where this came from for a few minutes – did I miss some modern javascript addition where classes are something more than an alias to a function constructor?
Then I looked again at the list of RequireJS dependencies and saw this
'prototype',
A quick search through the requirejs-config.js
files revealed this was an alias for the legacy-build.min
module
vendor/magento/module-theme/view/base/requirejs-config.js
45: "prototype": "legacy-build.min",
and peek at that module’s source revealed –
#File: vendor/magento/magento2-base/lib/web/legacy-build.min.js
var Prototype={Version:"1.7",Browser:...
a minified version of PrototypeJS, which defines a globally available Class
object.
As a programmer, I actually like Javascript. It’s a small language, with an interesting non-class based object system, and powerful first-class-functions that support closure.
As a developer though, dealing with the variety of different userland created object systems within the same project can be a bit maddening.