Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Unit Test",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceRoot}/src/node_modules/mocha/bin/_mocha",
"sourceMaps": true,
"autoAttachChildProcesses": true,
"cwd": "${workspaceRoot}/src",
"args": [
"test/test.es5.js"
]
}
]
}
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ const worker = new Worker("./worker-script");

```

## Demo apps
For usage with NativeScript Angular, check out [`demo-angular`](./demo-angular) in this repo.

For usage with NativeScript apps written in plain JavaScript, check out this repo: https://github.com/NativeScript/demo-workers.

## Related docs

1. [Workers in NativeScript](https://docs.nativescript.org/core-concepts/multithreading-model)
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports.pitch = function pitch(request) {
};

const plugins = (pluginOptions.plugins || []).map(plugin => {
if (typeof plugin !== 'string') {
if (typeof plugin !== "string") {
return plugin;
}
const found = compilerOptions.plugins.find(p => p.constructor.name === plugin);
Expand Down Expand Up @@ -109,7 +109,7 @@ module.exports.pitch = function pitch(request) {
if (entries[0]) {
const fileDeps = Array.from(childCompilation.fileDependencies);
this.clearDependencies();
fileDeps.map(fileName => {
fileDeps.forEach(fileName => {
this.addDependency(fileName);
});
/**
Expand Down
7 changes: 5 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"pretest": "babel ./test/test.es6.js --out-file ./test/test.es5.js",
"test": "mocha test/test.es5.js",
"posttest": "eslint ."
"posttest": "eslint .",
"prepare": "npm run test"
},
"eslintConfig": {
"extends": "webpack",
Expand All @@ -29,6 +30,7 @@
"functions": "never"
}
],
"no-console": 0,
"arrow-parens": 0,
"func-names": 0,
"import/no-extraneous-dependencies": 0,
Expand All @@ -48,7 +50,8 @@
"babel-cli": "^6.26.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"del": "^2.2.2",
"eslint": "^3.16.0",
"eslint": "^6.6.0",
"webpack": "~4.27.0",
"eslint-config-webpack": "^1.0.0",
"eslint-plugin-import": "^2.2.0",
"mocha": "^5.2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/symbol.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

const NATIVESCRIPT_WORKER_PLUGIN_SYMBOL = Symbol('NATIVESCRIPT_WORKER_PLUGIN_SYMBOL');
const NATIVESCRIPT_WORKER_PLUGIN_SYMBOL = Symbol("NATIVESCRIPT_WORKER_PLUGIN_SYMBOL");
module.exports = NATIVESCRIPT_WORKER_PLUGIN_SYMBOL;
2 changes: 1 addition & 1 deletion src/test/fixtures/inline-fallbacks/w1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w1 inlined with fallback
console.log("w1 inlined with fallback");
2 changes: 1 addition & 1 deletion src/test/fixtures/inline-fallbacks/w2.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w2 inlined with fallback
console.log("w2 inlined with fallback");
2 changes: 1 addition & 1 deletion src/test/fixtures/inline-options/w1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w1 inlined via options
console.log("w1 inlined via options");
2 changes: 1 addition & 1 deletion src/test/fixtures/inline-options/w2.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w2 inlined via options
console.log("w2 inlined via options");
2 changes: 1 addition & 1 deletion src/test/fixtures/inline-query/worker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// inlined worker test mark
console.log("inlined worker test mark");
2 changes: 1 addition & 1 deletion src/test/fixtures/name-options/w1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w1 via worker options
console.log("w1 via worker options");
2 changes: 1 addition & 1 deletion src/test/fixtures/name-options/w2.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w2 via worker options
console.log("w2 via worker options");
2 changes: 1 addition & 1 deletion src/test/fixtures/name-query/worker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// named worker test mark
console.log("named worker test mark");
2 changes: 1 addition & 1 deletion src/test/fixtures/no-fallbacks/w1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w1 inlined without fallback
console.log("w1 inlined without fallback");
2 changes: 1 addition & 1 deletion src/test/fixtures/no-fallbacks/w2.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// w2 inlined without fallback
console.log("w2 inlined without fallback");
2 changes: 1 addition & 1 deletion src/test/fixtures/worker/worker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// worker test mark
console.log("worker test mark");
12 changes: 6 additions & 6 deletions src/test/test.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("worker-loader", () => {
assert.equal(files.length, 1);

const content = await readFile(files[0]);
await assert.contains(content, "// worker test mark");
await assert.contains(content, "worker test mark");

assert.ok(await statsFileIsCorrect(stats, testName));
});
Expand All @@ -90,7 +90,7 @@ describe("worker-loader", () => {
assert.equal(file, `expected/${testName}/namedWorker.js`);

const content = await readFile(file);
await assert.contains(content, "// named worker test mark");
await assert.contains(content, "named worker test mark");

assert.ok(await statsFileIsCorrect(stats, testName));
});
Expand Down Expand Up @@ -121,8 +121,8 @@ describe("worker-loader", () => {

const [firstContent, secondContent] = files.map(readFile);

await assert.contains(firstContent, "// w1 via worker options");
await assert.contains(secondContent, "// w2 via worker options");
await assert.contains(firstContent, "w1 via worker options");
await assert.contains(secondContent, "w2 via worker options");

assert.ok(await statsFileIsCorrect(stats, testName));
});
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("worker-loader", () => {
}).catch(error => assert.contains(error.message, noFallbackOptionErrorMessage))
);

["node", "async-node", "node-webkit", "atom", "electron", "electron-main", "electron-renderer"].forEach((target) => {
["node", "async-node", "node-webkit", "electron-main", "electron-renderer"].forEach((target) => {
it(`should not have missing dependencies (${target})`, () =>
makeBundle("nodejs-core-modules", {
target,
Expand All @@ -181,7 +181,7 @@ describe("worker-loader", () => {
],
},
}).then((stats) => {
assert.equal(stats.compilation.missingDependencies.length, 0);
assert.equal(stats.compilation.missingDependencies.size, 0);
})
);
});
Expand Down