Skip to content

Commit 43a89c8

Browse files
committed
feat: Replace Browserify with Vite for bundling
1 parent 8692022 commit 43a89c8

File tree

11 files changed

+2850
-2816
lines changed

11 files changed

+2850
-2816
lines changed

build_releases.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ console.log(`Building JavaScript SDK v${pkg.version}...\n`)
3636

3737
console.log('Cleaning up old builds...\n');
3838

39-
rmDir(path.join(__dirname, 'dist'));
4039
rmDir(path.join(__dirname, 'lib'));
4140

4241
const crossEnv = 'npm run cross-env';
@@ -54,13 +53,7 @@ const gulp = 'npm run gulp';
5453
execCommand(`${crossEnv} PARSE_BUILD=react-native ${gulp} compile`),
5554
]);
5655

57-
console.log('Bundling and minifying for CDN distribution:');
58-
await Promise.all([
59-
execCommand(`${gulp} browserify`),
60-
execCommand(`${gulp} browserify-weapp`),
61-
]);
62-
await Promise.all([
63-
execCommand(`${gulp} minify`),
64-
execCommand(`${gulp} minify-weapp`),
65-
]);
56+
console.log('Bundling and minifying for CDN distribution');
57+
await execCommand('npm run build:browser');
58+
await execCommand('npm run build:weapp');
6659
}());

gulpfile.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
const babel = require('gulp-babel');
2-
const browserify = require('browserify');
3-
const derequire = require('gulp-derequire');
42
const gulp = require('gulp');
5-
const insert = require('gulp-insert');
63
const path = require('path');
7-
const rename = require('gulp-rename');
8-
const source = require('vinyl-source-stream');
9-
const uglify = require('gulp-uglify');
104
const watch = require('gulp-watch');
115

126
const BUILD = process.env.PARSE_BUILD || 'browser';
13-
const VERSION = require('./package.json').version;
147

158
const transformRuntime = ["@babel/plugin-transform-runtime", {
169
"corejs": 3,
@@ -40,31 +33,6 @@ const PLUGINS = {
4033
'react-native': ['inline-package-json', 'transform-inline-environment-variables']
4134
};
4235

43-
const DEV_HEADER = (
44-
'/**\n' +
45-
' * Parse JavaScript SDK v' + VERSION + '\n' +
46-
' *\n' +
47-
' * The source tree of this library can be found at\n' +
48-
' * https://github.com/ParsePlatform/Parse-SDK-JS\n' +
49-
' */\n'
50-
);
51-
52-
const FULL_HEADER = (
53-
'/**\n' +
54-
' * Parse JavaScript SDK v' + VERSION + '\n' +
55-
' *\n' +
56-
' * Copyright 2015-present Parse Platform\n' +
57-
' * All rights reserved.\n' +
58-
' *\n' +
59-
' * The source tree of this library can be found at\n' +
60-
' * https://github.com/ParsePlatform/Parse-SDK-JS\n' +
61-
' *\n' +
62-
' * This source code is licensed under the license found in the LICENSE\n' +
63-
' * file in the root directory of this source tree. Additional legal\n' +
64-
' * information can be found in the NOTICE file in the same directory.\n' +
65-
' */\n'
66-
);
67-
6836
function compileTask(stream) {
6937
return stream
7038
.pipe(babel({
@@ -82,69 +50,6 @@ gulp.task('compile', function() {
8250
return compileTask(gulp.src('src/*.*(js|ts)'));
8351
});
8452

85-
gulp.task('browserify', function(cb) {
86-
const stream = browserify({
87-
builtins: ['_process', 'events'],
88-
entries: 'lib/browser/Parse.js',
89-
standalone: 'Parse'
90-
})
91-
.exclude('xmlhttprequest')
92-
.ignore('_process')
93-
.bundle();
94-
stream.on('end', () => {
95-
cb();
96-
});
97-
return stream.pipe(source('parse.js'))
98-
.pipe(derequire())
99-
.pipe(insert.prepend(DEV_HEADER))
100-
.pipe(gulp.dest('./dist'));
101-
});
102-
103-
104-
gulp.task('browserify-weapp', function(cb) {
105-
const stream = browserify({
106-
builtins: ['_process', 'events'],
107-
entries: 'lib/weapp/Parse.js',
108-
standalone: 'Parse'
109-
})
110-
.exclude('xmlhttprequest')
111-
.ignore('_process')
112-
.bundle();
113-
stream.on('end', () => {
114-
cb();
115-
});
116-
return stream.pipe(source('parse.weapp.js'))
117-
.pipe(derequire())
118-
.pipe(insert.prepend(DEV_HEADER))
119-
.pipe(gulp.dest('./dist'));
120-
});
121-
122-
gulp.task('minify', function() {
123-
return gulp.src('dist/parse.js')
124-
.pipe(uglify())
125-
.pipe(insert.prepend(FULL_HEADER))
126-
.pipe(rename({ extname: '.min.js' }))
127-
.pipe(gulp.dest('./dist'))
128-
});
129-
130-
gulp.task('minify-weapp', function() {
131-
return gulp.src('dist/parse.weapp.js')
132-
.pipe(uglify())
133-
.pipe(insert.prepend(FULL_HEADER))
134-
.pipe(rename({ extname: '.min.js' }))
135-
.pipe(gulp.dest('./dist'))
136-
});
137-
13853
gulp.task('watch', function() {
139-
if (BUILD === 'browser') {
140-
const watcher = gulp.watch('src/*.*(js|ts)', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
141-
watcher.on('add', function(path) {
142-
console.log(`File ${path} was added`);
143-
});
144-
watcher.on('change', function(path) {
145-
console.log(`File ${path} was changed`);
146-
});
147-
return watcher;
148-
}
14954
return compileTask(watch('src/*.*(js|ts)', { ignoreInitial: false, verbose: true }));
15055
});

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./lib/browser/Parse.js');
1+
module.exports = require('./lib/browser/Parse.js').default;

node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./lib/node/Parse.js');
1+
module.exports = require('./lib/node/Parse.js').default;

0 commit comments

Comments
 (0)