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

JS API should be built as an ES6 module #2735

Closed
niloc132 opened this issue Aug 16, 2022 · 2 comments · Fixed by #2733
Closed

JS API should be built as an ES6 module #2735

niloc132 opened this issue Aug 16, 2022 · 2 comments · Fixed by #2733
Assignees
Labels
feature request New feature or request javascript Pull requests that update Javascript code jsapi

Comments

@niloc132
Copy link
Member

niloc132 commented Aug 16, 2022

As a javascript developer, I want to be able to import the deephaven-core JS API as an es6 module, and avoid other window scope pollution.

Presently, two script files are required to be added, and they each pollute scope in their own way - dh-internal.js creates a window.dhinternal object with its contents, and dh-core.js creates a window.dh object.

CORS: Any <script type=module> tags loaded from a different domain must have CORS headers, so before this is useful as a script loaded from another site, we should add a CORS policy for this file. Note that grpc/websocket calls also don't work without CORS, so this isn't a huge deal right now, but early efforts show this might be interrupting UI dev work. See whatwg/html#1888 for more discussion (short version: by making a script use import or export, it can't be loaded with non-module script tags, so is a way for a server to be secure-by-default for these scripts, and as such, it must opt-in to allowing remote servers to load files).

NPM deployment: This will also be handled in another ticket, after dh-internal is addressed. At this time, it will likely be necessary to include a third package.json just for the sake of examples, which then will have a different copy of the api than what the actual web ide uses. This task, when it is worked on, will also require sourcemaps to be functioning.

@niloc132 niloc132 added feature request New feature or request jsapi javascript Pull requests that update Javascript code labels Aug 16, 2022
@mofojed
Copy link
Member

mofojed commented Aug 17, 2022

@niloc132 on Enterprise, I know JS API version needed to match the server version exactly for it to work. Is that still the case with community? Just wondering as that would mean we'd need to publish a new UI every time a new JS API is published then.

@niloc132
Copy link
Member Author

No, we only have the usual problem of keeping up with API changes and features/bugfixes. By using protobuf and grpc, we are as decoupled as any json api - stuff could be missing/extra/changed, but api authors should try to prevent that where possible.

niloc132 pushed a commit that referenced this issue Feb 9, 2023
Both dh-core and dh-internal here have been changed, through the use of
a custom GWT linker.

Also updates html samples and web-client-ui to use the new module
packaging. Note that the web-client-ui build is an alpha release, but
will switch to a stable release soon.

---------
Fixes #2735
Co-authored-by: Colin Alworth <colinalworth@deephaven.io>
niloc132 added a commit that referenced this issue Apr 6, 2023
This includes more specific JsInterop annotations for nullability, and
introduces TypeScript-specific annotations to more clearly specific TS
semantics in cases where JS doesn't need to be so precise.

Fixes #2735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request javascript Pull requests that update Javascript code jsapi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants