|
1 | | -See /src/utils/rdkit for implementation details. |
| 1 | +### About RDKit |
| 2 | + |
| 3 | +RDKit is used for rendering molecule structures. |
| 4 | + |
| 5 | +### About RDKit implementation |
| 6 | + |
| 7 | +The RDKit library is not loaded from the npm package but instead from |
| 8 | +a copy hosted by us, in the public folder, per the official instructions: |
| 9 | +https://github.com/rdkit/rdkit-js?tab=readme-ov-file#option-1-use-the-npm-package-distribution-files |
| 10 | + |
| 11 | +The RDKit library uses WebAssembly to run its C++ code in the browser. |
| 12 | +However, due to security restrictions, WebAssembly modules must be |
| 13 | +loaded from the same origin as the hosting webpage, or from an origin |
| 14 | +that allows cross-origin resource sharing (CORS). |
| 15 | + |
| 16 | +When you import a JavaScript module using import or require, the module's |
| 17 | +code is bundled with your application's code by your build tool (like |
| 18 | +Webpack or Rollup). This is fine for regular JavaScript modules, but it |
| 19 | +doesn't work for WebAssembly modules because they need to be fetched |
| 20 | +separately by the browser. |
| 21 | + |
| 22 | +That's why the RDKit library instructs you to copy the .js and .wasm |
| 23 | +files to your public assets directory and load the .js file with a |
| 24 | + |
| 25 | +<script> tag. This way, the .js file can fetch the .wasm file from the |
| 26 | +same origin, satisfying the security restrictions. |
| 27 | + |
| 28 | +### Links |
| 29 | + |
| 30 | +https://github.com/rdkit/rdkit-js |
| 31 | +https://vue.rdkitjs.com/ |
0 commit comments