Skip to content

Commit

Permalink
[5.0] Drop es5 js files (#39618)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Allon Moritz <[email protected]>
Co-authored-by: Harald Leithner <[email protected]>
  • Loading branch information
3 people authored Jun 24, 2023
1 parent 2535bd2 commit e6518fb
Show file tree
Hide file tree
Showing 42 changed files with 325 additions and 465 deletions.
5 changes: 3 additions & 2 deletions administrator/templates/atum/joomla.asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
{
"name": "template.atum-es5",
"description": "The file containing the javascript for this template.",
"deprecated": true,
"type": "script",
"uri": "media/templates/administrator/atum/js/template-es5.min.js",
"uri": "",
"dependencies": [
"core"
],
Expand All @@ -64,7 +65,7 @@
"type": "script",
"uri": "media/templates/administrator/atum/js/template.min.js",
"dependencies": [
"template.atum-es5"
"core"
],
"attributes": {
"type": "module"
Expand Down
80 changes: 6 additions & 74 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 @@ -48,21 +47,19 @@ const build = async () => {
targets: {
browsers: [
'> 1%',
'not ie 11',
'not op_mini all',
/** https://caniuse.com/es6-module */
'chrome >= 61',
'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 +92,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 +108,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
85 changes: 12 additions & 73 deletions build/build-modules-js/javascript/build-com_media-js.es6.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { resolve } = require('path');
const { writeFile, copyFile, rm } = require('fs').promises;
const { existsSync } = require('fs');
const { writeFile, copyFile } = require('fs').promises;
const rollup = require('rollup');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const replace = require('@rollup/plugin-replace');
Expand All @@ -13,61 +12,6 @@ require('dotenv').config();
const inputJS = 'administrator/components/com_media/resources/scripts/mediamanager.es6.js';
const isProduction = process.env.NODE_ENV !== 'DEVELOPMENT';

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 @@ -102,8 +46,12 @@ 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 @@ -126,17 +74,10 @@ module.exports.mediaManager = async () => {
if (isProduction) {
// eslint-disable-next-line no-console
console.log('✅ ES2017 Media Manager ready');
writeFile(resolve('media/com_media/js/media-manager.min.js'), content.code, { encoding: 'utf8', mode: 0o644 });
return buildLegacy(resolve('media/com_media/js/media-manager.js'));
return writeFile(resolve('media/com_media/js/media-manager.min.js'), content.code, { encoding: 'utf8', mode: 0o644 });
}
// eslint-disable-next-line no-console
console.log('✅ ES2017 Media Manager ready');
if (existsSync(resolve('media/com_media/js/media-manager-es5.js'))) {
rm(resolve('media/com_media/js/media-manager-es5.js'));
}
if (existsSync(resolve('media/com_media/js/media-manager-es5.min.js'))) {
rm(resolve('media/com_media/js/media-manager-es5.min.js'));
}
return copyFile(resolve('media/com_media/js/media-manager.js'), resolve('media/com_media/js/media-manager.min.js'));
})
.catch((error) => {
Expand All @@ -149,12 +90,6 @@ module.exports.mediaManager = async () => {
};

module.exports.watchMediaManager = async () => {
if (existsSync(resolve('media/com_media/js/media-manager-es5.js'))) {
rm(resolve('media/com_media/js/media-manager-es5.js'));
}
if (existsSync(resolve('media/com_media/js/media-manager-es5.min.js'))) {
rm(resolve('media/com_media/js/media-manager-es5.min.js'));
}
// eslint-disable-next-line no-console
console.log('Watching Media Manager js+vue files...');
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -189,8 +124,12 @@ 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
8 changes: 5 additions & 3 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,6 @@ 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 getWcMinifiedCss = async (file) => {
let scssFileExists = false;
Expand Down Expand Up @@ -73,8 +72,12 @@ 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 +102,6 @@ module.exports.handleESMFile = async (file) => {

return writeFile(resolve(`${newPath}.min.js`), content.code, { encoding: 'utf8', mode: 0o644 });
})
.then(() => handleESMToLegacy(resolve(`${newPath}.js`)))
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error);
Expand Down
53 changes: 0 additions & 53 deletions build/build-modules-js/javascript/compile-to-es5.es6.js

This file was deleted.

Loading

0 comments on commit e6518fb

Please sign in to comment.