diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 0868cd062..6f9f1f95d 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 564e6ba03..e7de6ccd6 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 2733bfa0f..bd70928f7 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: { @@ -74,10 +73,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())