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 Public Path to import 'itk-vtk-viewer' downstream #485

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PaulHax
Copy link
Collaborator

@PaulHax PaulHax commented May 16, 2022

To use the pre-built itk-vtk-viewer bundle as a upstream dependency we:

  • Change Webpack's publicPath to '' (document relative) rather than the default auto. publicPath as auto caused a automatic publicpath is not supported in this browser error when including itk-vtk-viewer in the bundle.
  • Lift itk-wasm's pipeline.worker.js to live at the same level as the bundle, so the document/worker.js relative publicPath still lets the worker find the .wasm files. Before, the theory is publicPath resolved to an absolute path, so .wasm files were found no matter pipeline.workers.js' location.

This change allows for a vite project to

import 'itk-vtk-viewer'
itkVtkViewer.createViewer(...

With a vite.config.js like this

import { fileURLToPath, URL } from 'url'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    include: ['itk-vtk-viewer'],
  },
  plugins: [
    viteStaticCopy({
      targets: [
        { src: 'node_modules/itk-vtk-viewer/dist/pipeline.worker.js', dest: '' },
        { src: 'node_modules/itk-vtk-viewer/dist/itk', dest: '' },
      ],
    }),
  ],

Still have to lift up the pipeline.worker.js and the .wasms =(

Inspired by #475

@PaulHax PaulHax requested review from thewtex and bnmajor May 16, 2022 22:15
@thewtex thewtex mentioned this pull request May 18, 2022
@LeviEyal
Copy link

Any idea when this branch will be released? It works great on my Vite app as described

@thewtex
Copy link
Member

thewtex commented Mar 20, 2023

If I recall correctly, there were other deployment scenario's where this configuration needed to be verified and possibly did not work?

It may take some work to rebase this on HEAD. Instead, we will do better by migrating to itk-wasm 1.0, which is improving webassembly asset configuration to runtime-calls instead of the build-time configurations. ~1 month time frame.

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