1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-14 18:27:44 +02:00

Tools: Speed up building mobile CodeMirror when nothing has changed

This commit is contained in:
Laurent Cozic 2023-01-04 20:39:33 +00:00
parent b2d59002bb
commit 0678dad2d6
4 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1 @@
0e1c132c199587530715a478bdb29a74

View File

@ -101,6 +101,7 @@
"jest-environment-jsdom": "29.3.1",
"jetifier": "2.0.0",
"jsdom": "20.0.0",
"md5-file": "5.0.0",
"metro-react-native-babel-preset": "0.67.0",
"nodemon": "2.0.20",
"ts-jest": "29.0.3",

View File

@ -3,8 +3,9 @@
// files: First here we convert the JS file to a plain string, and that string
// is then loaded by eg. the Mermaid plugin, and finally injected in the WebView.
import { mkdirp, readFile, writeFile } from 'fs-extra';
import { mkdirp, pathExists, readFile, writeFile } from 'fs-extra';
import { dirname, extname, basename } from 'path';
const md5File = require('md5-file');
const execa = require('execa');
// We need this to be transpiled to `const webpack = require('webpack')`.
@ -77,19 +78,34 @@ class BundledFile {
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
cache: {
type: 'filesystem',
},
};
return config;
}
private async uglify() {
const md5Path = `${this.bundleOutputPath}.md5`;
const newMd5 = await md5File(this.bundleOutputPath);
const previousMd5 = await pathExists(md5Path) ? await readFile(md5Path, 'utf8') : '';
if (newMd5 === previousMd5 && await pathExists(this.bundleMinifiedPath)) {
console.info('Bundle has not changed - skipping minifying...');
return;
}
console.info(`Minifying bundle: ${this.bundleName}...`);
await execa('yarn', [
'run', 'uglifyjs',
'--compress',
'-o', this.bundleMinifiedPath,
this.bundleOutputPath,
]);
await writeFile(md5Path, newMd5, 'utf8');
}
private handleErrors(err: Error | undefined | null, stats: webpack.Stats | undefined): boolean {

View File

@ -4713,6 +4713,7 @@ __metadata:
jsc-android: 241213.1.0
jsdom: 20.0.0
md5: 2.3.0
md5-file: 5.0.0
metro-react-native-babel-preset: 0.67.0
nodemon: 2.0.20
prop-types: 15.8.1