8000 fixes for older webpack 4 · NathanaelA/nativescript-sqlite@06f862f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 06f862f

Browse files
committed
fixes for older webpack 4
1 parent 150a3e7 commit 06f862f

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

src/changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ v2.8.0 - Fixes for Webpack / Webworkers
4343
v2.8.1 - More fixes for WebWorker/Webpacking issues
4444
v2.8.2 - Fixes for iOS 14.5+ issues on opening database
4545
v2.8.3 - Add missing Commercial feature exclusion to Webpack 5
46+
v2.8.4 - Webpack 4 (Older NS support)
47+

src/nativescript.webpack.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* and/or if you require a commercial licensing
55
*
66
* Any questions please feel free to put a issue up on github
7-
* Nathan@master-technology.com http://nativescript.tools
7+
* Nathan@master.technology http://nativescript.tools
88
*************************************************************************************/
99

1010
/* global require, module */
@@ -17,9 +17,8 @@ module.exports = webpack => {
1717
webpack.Utils.addCopyRule('**/*.sqlite');
1818
webpack.Utils.addCopyRule('**/*.db');
1919

20-
// Used to update any existing configurations with more rules...
2120
webpack.chainWebpack((config, env) => {
22-
// Update Externals to eliminate any warnings during building
21+
// Update Externals to eliminate any warnings/errors during building
2322
const externals = config.get('externals');
2423
let hasSync = false, hasCom = false, hasEnc = false, hasKey = false;
2524

@@ -44,12 +43,18 @@ module.exports = webpack => {
4443
hasEnc = true;
4544
}
4645
if (!fs.existsSync(dirname+"/nativescript-sqlite-nosql")) {
47-
console.warn("NativeScript-SQLite NoSQL not detected, disabling support!");
46+
console.warn("NativeScript-SQLite NoSQL/Keystore not detected, disabling support!");
4847
externals.push('nativescript-sqlite-keystore');
4948
} else {
5049
hasKey = true;
5150
}
5251

< 8000 /div>
52+
if (!hasCom && !hasSync && !hasEnc) {
53+
// Are you really that self centered to delete this code
54+
// after using our hard work for free in your project?
55+
advertise();
56+
}
57+
5358
config.set('externals', externals);
5459

5560
config.module
@@ -64,3 +69,24 @@ module.exports = webpack => {
6469
});
6570
});
6671
}
72+
73+
// Time is money, We have spent a huge amount of time developing and testing this plugin.
74+
// This time is time you did not have to spend.
75+
// If you can't support us, financially at this point.
76+
// At least let our advertisements live so that maybe in the future when you get rich,
77+
// you will remember upon what foundations you built your empire. ;-)
78+
function advertise() {
79+
console.log("\r\n\r\n");
80+
console.log("***********************************************************************************");
81+
console.log("* Please support the developer of this open source plugins you are using. *");
82+
console.log("* *");
83+
console.log("* NativeScript-Sqlite *");
84+
console.log("* *");
85+
console.log("* You can purchase a commercial version (which also removes this message) at: *")
86+
console.log("* https://nativescript.tools *");
87+
console.log("***********************************************************************************");
88+
console.log("\r\n\r\n");
89+
90+
// Are you really going to be so selfish, to delete any of our ad code now?
91+
for (let time = Date.now() + 5000; Date.now() < time; );
92+
}

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-sqlite",
3-
"version": "2.8.3",
3+
"version": "2.8.4",
44
"description": "A sqlite NativeScript module for Android and iOS",
55
"main": "sqlite",
66
"nativescript": {

src/sqlite.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ function Database(dbname, options, callback) {
2323
}
2424

2525
if (options && options.multithreading && typeof global.Worker === 'function') {
26-
// We don't want this passed into the worker; to try and start another worker (which would fail).
26+
// We don't want this value passed into the worker; to try and start another worker (which would fail).
2727
delete options.multithreading;
2828
if (!DBInternal.HAS_COMMERCIAL) {
29-
throw new Error("Commercial only feature; see https://nativescript.tools/product/10");
29+
throw new Error("Multithreading is a commercial only feature; see https://nativescript.tools/product/10");
30+
}
31+
// We have to wrap this in a try/catch because of Webpack 4
32+
try {
33+
const multiSQL = require("nativescript-sqlite-commercial/commercial-multi");
34+
return new multiSQL(dbname, options, callback);
35+
} catch (err) {
36+
console.warn("Multithreading is a commercial only feature; see https://nativescript.tools/product/10");
3037
}
31-
const multiSQL = require("nativescript-sqlite-commercial/commercial-multi");
32-
return new multiSQL(dbname, options, callback);
3338
}
3439
return new DBInternal(dbname, options, callback);
3540
}

0 commit comments

Comments
 (0)
0