Skip to content

Commit 2b18b37

Browse files
Support webpack on Android #1
1 parent 4444662 commit 2b18b37

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# NativeScript Particle plugin
22

33
[![NPM version][npm-image]][npm-url]
4-
[![Downloads][downloads-image]][npm-url]
54
[![Twitter Follow][twitter-image]][twitter-url]
65

76
[build-status]:https://travis-ci.org/EddyVerbruggen/nativescript-particle.svg?branch=master
87
[build-url]:https://travis-ci.org/EddyVerbruggen/nativescript-particle
9-
[npm-image]:http://img.shields.io/npm/v/nativescript-particle.svg
8+
[npm-image]:https://img.shields.io/npm/v/nativescript-particle.svg
109
[npm-url]:https://npmjs.org/package/nativescript-particle
11-
[downloads-image]:http://img.shields.io/npm/dm/nativescript-particle.svg
10+
[downloads-image]:https://img.shields.io/npm/dm/nativescript-particle.svg
1211
[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
1312
[twitter-url]:https://twitter.com/eddyverbruggen
1413

src/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-particle",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Control your Particle.io devices from a NativeScript app!",
55
"main": "particle",
66
"typings": "index.d.ts",
@@ -19,7 +19,9 @@
1919
"test.ios": "npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
2020
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/platforms/**\"",
2121
"demo.ios": "npm run tsc && cd ../demo && tns run ios --syncAllFiles --emulator",
22+
"demo.ios.bundled": "npm run tsc && cd ../demo && tns run ios --bundle --syncAllFiles --emulator",
2223
"demo.android": "npm run tsc && cd ../demo && tns run android --syncAllFiles",
24+
"demo.android.bundled": "npm run tsc && cd ../demo && tns run android --bundle --syncAllFiles",
2325
"demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json",
2426
"plugin.prepare": "npm run build && cd ../demo && tns plugin remove nativescript-particle && tns plugin add ../src",
2527
"clean": "npm run demo.reset && npx rimraf -- node_modules package-lock.json && npm i",

src/particle.android.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ export class Particle implements TNSParticleAPI {
1414
}
1515

1616
public login(options: TNSParticleLoginOptions): Promise<void> {
17-
worker = new Worker("./particle-worker");
17+
if (global["TNS_WEBPACK"]) {
18+
const WorkerScript = require("nativescript-worker-loader!./particle-worker.js");
19+
worker = new WorkerScript();
20+
} else {
21+
worker = new Worker("./particle-worker.js");
22+
}
23+
1824
return new Promise((resolve, reject) => {
1925
worker.postMessage({
2026
action: "login",

0 commit comments

Comments
 (0)