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

Webpack and node-wot Browser bundle #324

Open
relu91 opened this issue Sep 10, 2020 · 3 comments
Open

Webpack and node-wot Browser bundle #324

relu91 opened this issue Sep 10, 2020 · 3 comments
Labels
browser-bundle Issues related to the browser distribution of node-wot bug Something isn't working good first issue Good for newcomers

Comments

@relu91
Copy link
Member

relu91 commented Sep 10, 2020

I am trying to use node-wot as a client in a webpack application. The library can be only loaded using a dynamic import (i.e. const wot = await import("@node-wot/browser-bundle")) and it seems that it misses some node built-ins. In fact, subscribing to an event throws the following error:

app.js:175 Uncaught (in promise) TypeError: _$punycode_37.toASCII is not a function
    at Url../node_modules/@node-wot/browser-bundle/dist/wot-bundle.min.js.Url.parse (app.js:175)
    at Object.urlParse [as parse] (app.js:175)
    at Function.e.extractScheme (app.js:175)
    at app.js:175
    at Array.map (<anonymous>)
    at Object.t.getClientFor (app.js:175)
    at app.js:175
    at new Promise (<anonymous>)
    at Object.t.subscribeEvent (app.js:175)
    at app.js:10052

AFIK The punycode library should be a builtin of node.js, but here it misses the toASCII function. However, if you require node-wot as an html script it works.

Does somebody have more experience with webpack and node-wot?

p.s. I also want to add that for the browser bundle we don't have a valid typescript type definition file.

@danielpeintner
Copy link
Member

In fact, subscribing to an event throws the following error:

I did try to reproduce the issue by

exposing counter sample

node packages\cli\dist\cli.js examples\scripts\counter.js

loading HTML in one browser

.../thingweb.node-wot/examples/browser/counter.html?url=http://localhost:8080/counter

load the same HTML in another browser/tab

.../thingweb.node-wot/examples/browser/counter.html?url=http://localhost:8080/counter

subscribe to event "change" in one tab and increment in the other and both counts should be in sync. In my case this still works.

@relu91
Copy link
Member Author

relu91 commented Sep 11, 2020

yes, indeed.

However, if you require node-wot as an html script it works.

it only happens with webpack.

@danielpeintner
Copy link
Member

Sorry I didn’t read it carefully enough...

Having said that, I wonder whether it make sense to have some kind of "manual tests". e.g. by creating a directory "<thingweb.node-wot>/manual-tests" and having sub-directories like "issue-324" where we can put the test and a README how it can be tested or sample code.

Do you think you can provide such a manual test?
Or do you/others think this is a stupid idea. I wouldn't mind ;-)

@relu91 relu91 added browser-bundle Issues related to the browser distribution of node-wot bug Something isn't working good first issue Good for newcomers labels Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser-bundle Issues related to the browser distribution of node-wot bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants