Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the library is usable in the browser #57

Closed
Drarig29 opened this issue Feb 13, 2021 · 6 comments
Closed

Check if the library is usable in the browser #57

Drarig29 opened this issue Feb 13, 2021 · 6 comments

Comments

@Drarig29
Copy link
Owner

Currently, I always use the library with Node.js.

I want the library to be usable in the browser too: need to ensure that.

@andrerivas
Copy link

andrerivas commented Oct 19, 2021

I'm really enjoying this library so far. Simple, yet complex :)

I am running into trouble importing the brackets-manager into a Vue.js application. The viewer is fine. It was giving me an error compiling the JsonDB.js file (error below).

I'm curious if anyone has been able to run the brackets-manager project inside a browser app, and if so what their bable/etc. configuration was to make that possible.

Thanks!

Module parse failed: Unexpected token (13:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const JsonDBConfig_1 = require("./lib/JsonDBConfig");
| class JsonDB {
>     loaded = false;
|     data = {};
|     config;

 @ ./node_modules/brackets-manager/dist/storage/json.js 4:23-46
 @ ./node_modules/brackets-manager/dist/index.js
 @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Brackets.vue?vue&type=script&lang=js&
 @ ./src/views/Brackets.vue?vue&type=script&lang=js&
 @ ./src/views/Brackets.vue
 @ ./src/router.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.36:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

@Drarig29
Copy link
Owner Author

Hi! It's becoming complex indeed... although I didn't want to.

About the JsonDB.js file, it's must be because it uses Node.js modules to read/write from/into files.

You should take a look at brackets-viewer.js which now imports the manager as a dependency and compiles it with webpack.

It was not implemented by me (the addition of the dependency) so I may not be able to help you with this. I think there is a better way to write the webpack config too, but it works.

@andrerivas
Copy link

now imports the manager as a dependency

Interesting. I saw that the example file uses the manager magically as part of the window object, but somehow the way I am importing the viewer in Vue.js doesn't provide the brackets-manager object. I'll keep digging around though. There must be a way!

Thanks again

@Drarig29
Copy link
Owner Author

Drarig29 commented Oct 19, 2021

Maybe you should double check that the version of the viewer you are importing is the latest one.

Screenshot_20211019-184050_Brave.jpg

The latest npm version (1.4.1) doesn't have the dependency yet. It was added after this.

And I don't want to (and can't right now because my computer is broken) to publish a new version right now, because I'd like to do some changes before this.

So either import the viewer with CDN links or with a GitHub link to this project in your package.json (cf. the viewer which does exactly that to import the manager).

"dependencies": {
    "brackets-viewer": "github:Drarig29/brackets-viewer.js"
}

@andrerivas
Copy link

That was it! Thanks :) I couldn't get imports to work right so I just downloaded the latest min.js file and that works.

@Drarig29
Copy link
Owner Author

Drarig29 commented Nov 2, 2021

I'm really enjoying this library so far. Simple, yet complex :)

I am running into trouble importing the brackets-manager into a Vue.js application. The viewer is fine. It was giving me an error compiling the JsonDB.js file (error below).

I'm curious if anyone has been able to run the brackets-manager project inside a browser app, and if so what their bable/etc. configuration was to make that possible.

Thanks!

Module parse failed: Unexpected token (13:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const JsonDBConfig_1 = require("./lib/JsonDBConfig");
| class JsonDB {
>     loaded = false;
|     data = {};
|     config;

 @ ./node_modules/brackets-manager/dist/storage/json.js 4:23-46
 @ ./node_modules/brackets-manager/dist/index.js
 @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Brackets.vue?vue&type=script&lang=js&
 @ ./src/views/Brackets.vue?vue&type=script&lang=js&
 @ ./src/views/Brackets.vue
 @ ./src/router.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.36:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

I removed node-json-db as a dependency. So it should work perfectly in the browser as of now.

@Drarig29 Drarig29 closed this as completed Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants