Skip to content

Add ESM bundle build#2

Merged
hanayik merged 1 commit into
niivue:mainfrom
thewtex:esm-bundles
Apr 11, 2025
Merged

Add ESM bundle build#2
hanayik merged 1 commit into
niivue:mainfrom
thewtex:esm-bundles

Conversation

@thewtex
Copy link
Copy Markdown
Collaborator

@thewtex thewtex commented Apr 11, 2025

For no-build web page examples.

@thewtex
Copy link
Copy Markdown
Collaborator Author

thewtex commented Apr 11, 2025

@neurolabusc @hanayik I am looking to use this in examples, e.g. InsightSoftwareConsortium/ITK-Wasm#1375

@hanayik
Copy link
Copy Markdown
Member

hanayik commented Apr 11, 2025

@thewtex , this esbuild command with --bundle will inline all the dependencies right? For downstream projects, that's not ideal.

It might be good to use the exports field in the package.json and setup an export for the main non-bundled entry point and another for the bundled entry point to offer both options.

@thewtex
Copy link
Copy Markdown
Collaborator Author

thewtex commented Apr 11, 2025

@hanayik good catch.

My intention is to create a bundle that inline's dependencies for easy usage in the browser.

What do you think of just switching main back in *package.json` to src/loader.js?

@hanayik
Copy link
Copy Markdown
Member

hanayik commented Apr 11, 2025

@thewtex that works. Exports is probably the more modern approach but using main as it was is fine. You’ll need to add “dist” to the files field in package.json so that it is included in the npm package.

For no-build web page examples.
@thewtex
Copy link
Copy Markdown
Collaborator Author

thewtex commented Apr 11, 2025

@hanayik 👍 done

@hanayik hanayik merged commit d4c1cd1 into niivue:main Apr 11, 2025
@thewtex thewtex deleted the esm-bundles branch April 11, 2025 19:35
@neurolabusc
Copy link
Copy Markdown
Contributor

@thewtex now that ITK-WASM natively supports NIfTI voxels and MZ3 meshes, is it possible for NiiVue to use those formats (which are also native is NiiVue) without using the cbor loader? In other words, both tools can communicate in using formats that do not require a plugin loader.

@thewtex
Copy link
Copy Markdown
Collaborator Author

thewtex commented Apr 11, 2025

@neurolabusc yes, it is pretty awesome 😍

In the ITK-Wasm docs, I am going to use iwi2niiCore, etc.

It will be nice to also create Niivue loaders with the plug-in infrastructure you created recently to provide easy access to the @itk-wasm/image-io functionality

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

Successfully merging this pull request may close these issues.

3 participants