Skip to content

Commit e5b58b6

Browse files
committed
Integrate objectbox-js & objectbox-dart - make webpack export as a global object (namespace)
1 parent 4b9f4de commit e5b58b6

File tree

7 files changed

+16
-4
lines changed

7 files changed

+16
-4
lines changed

objectbox-js/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@
33
This is a very basic ObjectBox implementation for JavaScript/TypeScript, based on IndexedDB instead of the native objectbox-c API.
44

55
### Build and copy to objectbox-dart
6+
67
The following code builds TypeScript files into `build` folder, uses `webpack` to create a single JS,
78
copies the JS (and sourcemap) to `../objectbox/lib/`, and generates dart binding code in `../objectbox/lib/src/web/`.
8-
```
9+
```shell
910
npm run build:main
1011
npm run install
1112
npm run generate:dart
1213
```
1314

15+
Or run a single action to do it all:
16+
```shell
17+
npm run all:dart
18+
```
19+
1420
### Notes and useful links about the compilation/integration:
21+
1522
* modules are not supported, we need to compile to a single JS file (using `webpack`)
1623
* example: https://github.com/google/chartjs.dart/
1724
* example: https://github.com/matanlurey/dart_js_interop
1825
* modules issue: https://github.com/dart-lang/sdk/issues/25059
1926

2027
### IndexedDB resources
28+
2129
* https://developers.google.com/web/ilt/pwa/working-with-indexeddb
2230
* https://www.tutorialspoint.com/html5/html5_indexeddb.htm
2331
* https://javascript.info/indexeddb

objectbox-js/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"build:module": "tsc -p tsconfig.module.json",
1515
"install": "cp build/objectbox.js* ../objectbox/lib/",
1616
"generate:dart": "cd build/main/lib && dart_js_facade_gen --destination=../../../../objectbox/lib/src/web/ number.d.ts",
17+
"all:dart": "run-p build:main && run-p install && run-p generate:dart",
1718
"fix": "run-s fix:*",
1819
"fix:prettier": "prettier \"src/**/*.ts\" --write",
1920
"fix:lint": "eslint src --ext .ts --fix",

objectbox-js/webpack.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ module.exports = {
1919
output: {
2020
filename: 'objectbox.js',
2121
path: path.resolve(__dirname, 'build'),
22+
library: 'objectbox',
23+
libraryTarget: 'window'
2224
},
2325
};

objectbox/lib/objectbox.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objectbox/lib/objectbox.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objectbox/lib/src/web/number.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@JS()
1+
@JS('objectbox')
22
library number;
33

44
import "package:js/js.dart";

objectbox/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies:
1616
# flat_buffers: 1.12.0
1717
ffi: ^0.1.3
1818
meta: ^1.2.4
19+
js: ^0.6.2
1920

2021
dev_dependencies:
2122
build_runner: ^1.0.0

0 commit comments

Comments
 (0)