Skip to content

Commit

Permalink
fix: cordova browserify/rollup conflict
Browse files Browse the repository at this point in the history
browserify seems to clash with rollup setup, remove browserify in favour
of rollup.
  • Loading branch information
chmelevskij committed Dec 29, 2022
1 parent 483dec9 commit 07cb098
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 586 deletions.
53 changes: 0 additions & 53 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ const del = require('del');
const NwBuilder = require('nw-builder');
const innoSetup = require('@quanle94/innosetup');
const deb = require('gulp-debian');
const conffiles = './test/configs';
const buildRpm = require('rpm-builder');
const commandExistsSync = require('command-exists').sync;
const targz = require('targz');

const gulp = require('gulp');
const rollup = require('rollup');
const concat = require('gulp-concat');
const yarn = require("gulp-yarn");
const rename = require('gulp-rename');
const replace = require('gulp-replace');
Expand All @@ -34,9 +32,6 @@ const sourcemaps = require('gulp-sourcemaps');

const cordova = require("cordova-lib").cordova;

const browserify = require('browserify');
const glob = require('glob');

const DIST_DIR = './dist/';
const APPS_DIR = './apps/';
const DEBUG_DIR = './debug/';
Expand Down Expand Up @@ -91,8 +86,6 @@ gulp.task('clean-cache', clean_cache);

gulp.task('clean-cordova', clean_cordova);

gulp.task('test-cordova', cordova_browserify);


// Function definitions are processed before function calls.

Expand Down Expand Up @@ -955,7 +948,6 @@ function cordova_dist() {
distTasks.push(cordova_manifestjson);
distTasks.push(cordova_configxml);
distTasks.push(cordova_rename_build_json);
distTasks.push(cordova_browserify);
distTasks.push(cordova_depedencies);
if (cordovaDependencies) {
distTasks.push(cordova_platforms);
Expand Down Expand Up @@ -1075,51 +1067,6 @@ function cordova_rename_build_json() {
.pipe(gulp.dest(CORDOVA_DIST_DIR));
}

function cordova_browserify(done) {
const readFile = function(file) {
return new Promise(function(resolve) {
if (!file.includes("node_modules")) {
fs.readFile(file, 'utf8', async function (err,data) {
if (data.match('require\\(.*\\)')) {
await cordova_execbrowserify(file);
}
resolve();
});
} else {
resolve();
}
});
};
glob(`${CORDOVA_DIST_DIR}www/**/*.js`, {}, function (err, files) {
const readLoop = function() {
if (files.length === 0) {
done();
} else {
const file = files.pop();
readFile(file).then(function() {
readLoop();
});
}
};
readLoop();
});
}

function cordova_execbrowserify(file) {
const filename = file.split('/').pop();
const destpath = file.replace(filename, '');
console.log(`Include required modules in ${file}`);
return browserify(file, { ignoreMissing: true })
.transform("babelify", {
presets: ["@babel/preset-env"],
sourceMaps: false,
global:true,
ignore: [/\/node_modules\/(?!md5.js\/)/] })
.bundle()
.pipe(source(filename))
.pipe(gulp.dest(destpath));
}

function cordova_depedencies() {
process.chdir(CORDOVA_DIST_DIR);
return gulp.src(['./package.json', './yarn.lock'])
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
"@storybook/vue": "^6.5.12",
"babel-loader": "^8.2.5",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"chai": "^4.3.6",
"command-exists": "^1.2.9",
"cordova-lib": "^11.0.0",
Expand All @@ -106,7 +105,6 @@
"fs-extra": "^10.1.0",
"glob": "^8.0.3",
"gulp": "^4.0.2",
"gulp-concat": "~2.6.1",
"gulp-debian": "^0.3.2",
"gulp-json-editor": "^2.5.6",
"gulp-less": "^5.0.0",
Expand Down

0 comments on commit 07cb098

Please sign in to comment.