Skip to content
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

[5.0] Drop es5 js files #39618

Merged
merged 32 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7103caf
remove es5 js
dgrammatiko Jan 12, 2023
65e5f1f
cs
dgrammatiko Jan 12, 2023
c7b782c
Merge branch '5.0-dev' into 5.0-dev-drop-es5
laoneo Jan 13, 2023
3280d50
programmatically
dgrammatiko Jan 13, 2023
829fe90
remove unused import
dgrammatiko Jan 13, 2023
df8925d
Remove dead code
dgrammatiko Jan 13, 2023
583b916
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Mar 7, 2023
3eaf264
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Mar 8, 2023
5051668
Restore focus-visible, rollup-commonjs
dgrammatiko Mar 8, 2023
3c0f127
PHP CS
dgrammatiko Mar 8, 2023
cce0647
modify the browserlist
dgrammatiko Mar 8, 2023
d1c2cb9
revert chosen
dgrammatiko Mar 8, 2023
d0f4105
oops
dgrammatiko Mar 8, 2023
b6e4cf4
revert chosen
dgrammatiko Mar 8, 2023
a1c8419
ignore <1%, opera mino
dgrammatiko Mar 10, 2023
fd5c33f
clean up
dgrammatiko Mar 10, 2023
0b9b67c
CS
dgrammatiko Mar 10, 2023
193cfdc
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Mar 10, 2023
5ea2528
Update minify-vendor.es6.js
dgrammatiko Mar 10, 2023
377837a
Merge branch '5.0-dev' into 5.0-dev-drop-es5
HLeithner Mar 11, 2023
ea725dd
Merge branch '5.0-dev' into 5.0-dev-drop-es5
HLeithner Mar 12, 2023
59d23be
Remove remaining es5 defintions
dgrammatiko Mar 12, 2023
32c4085
CS
dgrammatiko Mar 13, 2023
257c034
Merge branch '5.0-dev' into pr/5/5.0-dev-drop-es5
HLeithner Apr 2, 2023
05abf5e
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko May 10, 2023
1dee25c
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko May 21, 2023
6a30ee4
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Jun 2, 2023
a20287e
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Jun 16, 2023
3dd73b9
Merge branch '5.0-dev' into 5.0-dev-drop-es5
dgrammatiko Jun 23, 2023
d0a1029
Keep the es5 references for b/c
dgrammatiko Jun 23, 2023
81c5964
don’t depend on es5
dgrammatiko Jun 23, 2023
5d37905
missed
dgrammatiko Jun 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions administrator/templates/atum/joomla.asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,13 @@
"template.active.language"
]
},
{
"name": "template.atum-es5",
"description": "The file containing the javascript for this template.",
"type": "script",
"uri": "media/templates/administrator/atum/js/template-es5.min.js",
"dependencies": [
"core"
],
"attributes": {
"nomodule": true,
"defer": true
}
},
{
"name": "template.atum",
"description": "The file containing the javascript for this template.",
"type": "script",
"uri": "media/templates/administrator/atum/js/template.min.js",
"dependencies": [
"template.atum-es5"
"core"
],
"attributes": {
"type": "module"
Expand Down
1 change: 0 additions & 1 deletion build/build-modules-js/init/minify-vendor.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const RootPath = process.cwd();

const folders = [
'media/vendor/accessibility/js',
'media/vendor/chosen/js',
'media/vendor/codemirror',
'media/vendor/debugbar',
'media/vendor/diff/js',
Expand Down
12 changes: 1 addition & 11 deletions build/build-modules-js/init/patches.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ const RootPath = process.cwd();
module.exports.patchPackages = async (options) => {
const mediaVendorPath = join(RootPath, 'media/vendor');

// Joomla's hack to expose the chosen base classes so we can extend it ourselves
// (it was better than the many hacks we had before. But I'm still ashamed of myself).
let dest = join(mediaVendorPath, 'chosen');
const chosenPath = `${dest}/${options.settings.vendors['chosen-js'].js['chosen.jquery.js']}`;
let ChosenJs = await readFile(chosenPath, { encoding: 'utf8' });
ChosenJs = ChosenJs.replace('}).call(this);', ` document.AbstractChosen = AbstractChosen;
document.Chosen = Chosen;
}).call(this);`);
await writeFile(chosenPath, ChosenJs, { encoding: 'utf8', mode: 0o644 });

// Append initialising code to the end of the Short-and-Sweet javascript
dest = join(mediaVendorPath, 'short-and-sweet');
const dest = join(mediaVendorPath, 'short-and-sweet');
const shortandsweetPath = `${dest}/${options.settings.vendors['short-and-sweet'].js['dist/short-and-sweet.min.js']}`;
let ShortandsweetJs = await readFile(shortandsweetPath, { encoding: 'utf8' });
ShortandsweetJs = ShortandsweetJs.concat(`
Expand Down
82 changes: 6 additions & 76 deletions build/build-modules-js/javascript/build-bootstrap-js.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const rollup = require('rollup');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const replace = require('@rollup/plugin-replace');
const { babel } = require('@rollup/plugin-babel');
const commonjs = require('@rollup/plugin-commonjs');
const bsVersion = require('../../../package.json').dependencies.bootstrap.replace(/^\^|~/, '');

const tasks = [];
Expand Down Expand Up @@ -47,22 +46,18 @@ const build = async () => {
{
targets: {
browsers: [
'> 1%',
'not ie 11',
'not op_mini all',
/** https://caniuse.com/es6-module */
'chrome 61',
dgrammatiko marked this conversation as resolved.
Show resolved Hide resolved
'safari 11',
'edge 16',
'Firefox 60',
],
},
},
],
],
}),
],
external: [
'./base-component.js',
...domImports.map((file) => `./dom/${file}`),
...domImports.map((file) => `./${file}`),
...utilImports.map((file) => `./util/${file}`),
],
manualChunks: {
alert: ['build/media_source/vendor/bootstrap/js/alert.es6.js'],
button: ['build/media_source/vendor/bootstrap/js/button.es6.js'],
Expand Down Expand Up @@ -95,55 +90,6 @@ const build = async () => {
await bundle.close();
};

const buildLegacy = async () => {
// eslint-disable-next-line no-console
console.log('Building Legacy...');

const bundle = await rollup.rollup({
input: resolve(inputFolder, 'index.es6.js'),
plugins: [
commonjs(),
nodeResolve(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': '\'production\'',
}),
babel({
exclude: 'node_modules/core-js/**',
babelHelpers: 'bundled',
babelrc: false,
presets: [
[
'@babel/preset-env',
{
corejs: '3.8',
useBuiltIns: 'usage',
targets: {
chrome: '58',
ie: '11',
},
loose: true,
bugfixes: true,
modules: false,
},
],
],
}),
],
external: [],
});

await bundle.write({
format: 'iife',
sourcemap: false,
name: 'bootstrap',
file: resolve(outputFolder, 'bootstrap-es5.js'),
});

// closes the bundle
await bundle.close();
};

module.exports.bootstrapJs = async () => {
rimraf.sync(resolve(outputFolder));

Expand All @@ -160,23 +106,7 @@ module.exports.bootstrapJs = async () => {
tasks.push(createMinified(file));
});

return Promise.all(tasks).then(async () => {
// eslint-disable-next-line no-console
console.log('✅ ES6 components ready');

try {
await buildLegacy(inputFolder, 'index.es6.js');
const es5File = await readFile(resolve(outputFolder, 'bootstrap-es5.js'), { encoding: 'utf8' });
const mini = await minify(es5File, { sourceMap: false, format: { comments: false } });
await writeFile(resolve(outputFolder, 'bootstrap-es5.min.js'), mini.code, { encoding: 'utf8', mode: 0o644 });
// eslint-disable-next-line no-console
console.log('✅ Legacy done!');
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
process.exit(1);
}
}).catch((er) => {
return Promise.all(tasks).catch((er) => {
// eslint-disable-next-line no-console
console.log(er);
process.exit(1);
Expand Down
73 changes: 10 additions & 63 deletions build/build-modules-js/javascript/build-com_media-js.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,10 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve');
const replace = require('@rollup/plugin-replace');
const { babel } = require('@rollup/plugin-babel');
const VuePlugin = require('rollup-plugin-vue');
const commonjs = require('@rollup/plugin-commonjs');
const { minifyJsCode } = require('./minify.es6.js');

const inputJS = 'administrator/components/com_media/resources/scripts/mediamanager.es6.js';

const buildLegacy = async (file) => {
// eslint-disable-next-line no-console
console.log('Building Legacy Media Manager...');

const bundle = await rollup.rollup({
input: file,
plugins: [
nodeResolve(),
commonjs(),
babel({
exclude: 'node_modules/core-js/**',
babelHelpers: 'bundled',
babelrc: false,
presets: [
[
'@babel/preset-env',
{
corejs: '3.8',
useBuiltIns: 'usage',
targets: {
ie: '11',
},
loose: true,
bugfixes: true,
modules: false,
ignoreBrowserslistConfig: true,
},
],
],
}),
],
external: [],
});

await bundle.write({
format: 'iife',
sourcemap: false,
name: 'JoomlaMediaManager',
file: 'media/com_media/js/media-manager-es5.js',
})
.then((value) => minifyJsCode(value.output[0].code))
.then((content) => {
// eslint-disable-next-line no-console
console.log('✅ Legacy Media Manager ready');
return writeFile(resolve('media/com_media/js/media-manager-es5.min.js'), content.code, { encoding: 'utf8', mode: 0o644 });
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error);
});

// closes the bundle
await bundle.close();
};

module.exports.mediaManager = async () => {
// eslint-disable-next-line no-console
console.log('Building Media Manager ES Module...');
Expand Down Expand Up @@ -95,9 +39,11 @@ module.exports.mediaManager = async () => {
{
targets: {
browsers: [
'> 1%',
'not ie 11',
'not op_mini all',
/** https://caniuse.com/es6-module */
'chrome 61',
'safari 11',
'edge 16',
'Firefox 60',
],
},
loose: true,
Expand All @@ -122,7 +68,6 @@ module.exports.mediaManager = async () => {

return writeFile(resolve('media/com_media/js/media-manager.min.js'), content.code, { encoding: 'utf8', mode: 0o644 });
})
.then(() => buildLegacy(resolve('media/com_media/js/media-manager.js')))
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error);
Expand Down Expand Up @@ -164,9 +109,11 @@ module.exports.watchMediaManager = async () => {
{
targets: {
browsers: [
'> 1%',
'not ie 11',
'not op_mini all',
/** https://caniuse.com/es6-module */
'chrome 61',
'safari 11',
'edge 16',
'Firefox 60',
],
},
loose: true,
Expand Down
12 changes: 7 additions & 5 deletions build/build-modules-js/javascript/compile-to-es2017.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { babel } = require('@rollup/plugin-babel');
const Postcss = require('postcss');
const { renderSync } = require('sass-embedded');
const { minifyJsCode } = require('./minify.es6.js');
const { handleESMToLegacy } = require('./compile-to-es5.es6.js');
// const { handleESMToLegacy } = require('./compile-to-es5.es6.js');

const getWcMinifiedCss = async (file) => {
let scssFileExists = false;
Expand Down Expand Up @@ -72,9 +72,11 @@ module.exports.handleESMFile = async (file) => {
{
targets: {
browsers: [
'> 1%',
'not ie 11',
'not op_mini all',
/** https://caniuse.com/es6-module */
'chrome 61',
'safari 11',
'edge 16',
'Firefox 60',
],
},
bugfixes: true,
Expand All @@ -99,7 +101,7 @@ module.exports.handleESMFile = async (file) => {

return writeFile(resolve(`${newPath}.min.js`), content.code, { encoding: 'utf8', mode: 0o644 });
})
.then(() => handleESMToLegacy(resolve(`${newPath}.js`)))
// .then(() => handleESMToLegacy(resolve(`${newPath}.js`)))
dgrammatiko marked this conversation as resolved.
Show resolved Hide resolved
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error);
Expand Down
Loading