From d54af0ac16490d354a728c503759bb4bd250556e Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Wed, 4 May 2022 18:37:45 +0300 Subject: [PATCH] **BREAKING**: Stop publishing an unminified browser bundle Resolves: #1222 Change-type: major Signed-off-by: Thodoris Greasidis --- DOCUMENTATION.md | 2 +- README.md | 4 ++-- doc/DOCUMENTATION.hbs | 2 +- gulpfile.js | 5 ----- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 1bb472333..e31eb3ebc 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -10,7 +10,7 @@ $ npm install --save balena-sdk ### Bundling for browsers -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.js` bundle. +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: diff --git a/README.md b/README.md index 4ed96d837..301813442 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,11 @@ The following features are node-only: - OS image streaming download (`balena.models.os.download`), - balena settings client (`balena.settings`). -In Node you can simply `require('balena-sdk')`, but in the browser things are more complicated. The balena SDK provides a bundled single file for browsers, which allows you to include a single file with all dependencies included, available as [balena-browser.min.js](https://unpkg.com/balena-sdk/es2015/balena-browser.min.js) (or [balena-browser.js](https://unpkg.com/balena-sdk/es2015/balena-browser.js) if you'd like the much larger unminified version). This uses the [UMD format](https://github.com/umdjs/umd), and will register itself as either a CommonJS or AMD module called `balena-sdk` if possible, or create a `balenaSdk` global if not. You can also use the `es2018` version if desired. +In Node you can simply `require('balena-sdk')`, but in the browser things are more complicated. The balena SDK provides a bundled single file for browsers, which allows you to include a single file with all dependencies included, available as [balena-browser.min.js](https://unpkg.com/balena-sdk/es2015/balena-browser.min.js). This uses the [UMD format](https://github.com/umdjs/umd), and will register itself as either a CommonJS or AMD module called `balena-sdk` if possible, or create a `balenaSdk` global if not. You can also use the `es2018` version if desired. ### Bundling for browsers -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.js` bundle. If you do that, you should be aware that you may pick up some dependencies that are actually unnecessary in the browser, because they're only used in Node environments. You can safely exclude these dependencies, if you're not using them yourself, and significantly reduce the size of your resulting bundle. +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. If you do that, you should be aware that you may pick up some dependencies that are actually unnecessary in the browser, because they're only used in Node environments. You can safely exclude these dependencies, if you're not using them yourself, and significantly reduce the size of your resulting bundle. In the browser the balena SDK doesn't use the following dependencies: diff --git a/doc/DOCUMENTATION.hbs b/doc/DOCUMENTATION.hbs index 7e15769b8..b3ca772b2 100644 --- a/doc/DOCUMENTATION.hbs +++ b/doc/DOCUMENTATION.hbs @@ -10,7 +10,7 @@ $ npm install --save balena-sdk ### Bundling for browsers -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.js` bundle. +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: diff --git a/gulpfile.js b/gulpfile.js index 9066e8e33..b146a1790 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -24,7 +24,6 @@ const OPTIONS = { files: { tests: ['tests/**/*.spec.js', 'tests/**/*.spec.ts'], browserEntry: 'index.js', - browserOutput: 'balena-browser.js', browserMinifiedOutput: 'balena-browser.min.js', }, directories: { @@ -75,10 +74,6 @@ gulp.task('pack-browser', function () { .exclude('node-localstorage') .bundle(); - bundle - .pipe(source(OPTIONS.files.browserOutput)) - .pipe(gulp.dest(OPTIONS.directories.build)); - return bundle .pipe(source(OPTIONS.files.browserMinifiedOutput)) .pipe(buffer())