Problems using the module build
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 389
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
We're trying to embed Neuroglancer (master) into an Angular project.
## Attempt: Consume the _module_ build
Building the module with `npm run build-module` worked fine. But following the [readme from examples/dependent-project](https://github.com/google/neuroglancer/tree/master/examples/dependent-project#readme) I was unable to get the example to work. I think it's because the example uses webpack, while the main project has switched to esbuild.
So the dependent-project seems unmaintained? (If so, maybe add a note about that?)
Importing and calling `setupDefaultViewer()` from Angular (via `npm link`) didn't work:
- Got many different typescript and build errors. After fixing includes and tsconfig, the main issue was css/svg import statements in the built module dependencies. Angular's Webpack didn't want to resolve those (build errors). Plus some issues with the `codemirror` dependency that emitted compatibility-import statements that work in the browser, but caused errors from when bundling with Angular. After fixing those directly in node_modules, `@babel/runtime` was missing, etc.
- Also types didn't work, but that's easy to ignore for now. I understand we cannot generate type definitions because of this [typescript issue with mixins](https://github.com/microsoft/TypeScript/issues/35822).
- Conclusion: We probably should consume a build already bundled by `esbuild`.
- Which implies that the Angular project shouldn't depend on `neuroglancer`'s dependencies (`package.json`) any more.
- Attempted to change `config/esbuild/` to create a module build with `bundle: true,`. Got it to build, but didn't find the module entry point in the bundled result.
Do you think it is useful to proceed with that approach? (Would you want a PR doing a bundled module build?)
## Alternative: Embed the _main_ build via
This is described in [this comment from issue 324](https://github.com/google/neuroglancer/issues/324#issuecomment-867703126) and works just fine so far. We can access the `viewer` object from the `<iframe>`'s window, configure it, even subscribe to events.
The main drawback seems to be that we cannot import and control the initial config / viewer creation.
Contributor guide
Assessment
This issue has not been assessed yet.