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

Deploying the wasm through webpack #26

Closed
damageboy opened this issue Apr 16, 2020 · 2 comments
Closed

Deploying the wasm through webpack #26

damageboy opened this issue Apr 16, 2020 · 2 comments
Labels
question Further information is requested

Comments

@damageboy
Copy link

The docs mention that:

Bundlers (RollupJS / WebPack) will ignore the WASM files, so you will need to manually ensure they are present in your final distribution (typically they are placed in the same folder as the bundled JS)

Is there some official guidelines for what needs to happen with webpack, for example to get the file pushed all the way from node_modules down to some static directory?

@GordonSmith
Copy link
Member

I suspect WebPack has plugins which will handle this for you - but what I tend to do is treat the wasm file the same as I might any asset (like png or wav file) and copy it from the node_modules folder into my "dist" or "build" folder next to where webpack is outputting its files.

At which point it may "just work", but if not you will need to call wasmFolder with the location.

Alternatively you can set the following global variable: __hpcc_wasmFolder to the same URL your pulling your webpacked files from (before any page tries to load the wasm file).

@tuckergordon
Copy link

For anyone who stumbles across this thread, I was able to deploy the wasm through rollup with by using the rollup-plugin-copy module to move the necessary files into the build folder:

// rollup.config.js
import copy from 'rollup-plugin-copy';

...
  plugins: [
    copy({
      targets: [
        { 
          src: 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm',
          dest: 'public/build'
        },
        { 
          src: 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm',
          dest: 'public/build/@hpcc-js/wasm'
        },
        {
          src: 'node_modules/@hpcc-js/wasm/dist/index.min.js',
          dest: 'public/build/@hpcc-js/wasm'
        }
      ]
    }),
    ..
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants