Skip to content

Commit

Permalink
#6246 - Import indigo with EXPORT_ES6 & USE_ES6_IMPORT_META options
Browse files Browse the repository at this point in the history
- added import of indigo with separate wasm using esm imports to automatically take wasm files during the build
  • Loading branch information
rrodionov91 committed Jan 17, 2025
1 parent 2778488 commit d6740d0
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 419 deletions.
27 changes: 7 additions & 20 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,14 @@ let structServiceProvider: StructServiceProvider =
new RemoteStructServiceProvider(
process.env.API_PATH || process.env.REACT_APP_API_PATH,
);

if (process.env.MODE === 'standalone') {
if (process.env.USE_SEPARATE_INDIGO_WASM === 'true') {
// It is possible to use just 'ketcher-standalone' instead of ketcher-standalone/dist/binaryWasm
// however, it will increase the size of the bundle more than two times because wasm will be
// included in ketcher bundle as base64 string.
// In case of usage ketcher-standalone/dist/binaryWasm additional build configuration required
// to copy .wasm files in build folder. Please check /example/config/webpack.config.js.
const {
StandaloneStructServiceProvider,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('ketcher-standalone/dist/binaryWasm');
structServiceProvider =
new StandaloneStructServiceProvider() as StructServiceProvider;
} else {
const {
StandaloneStructServiceProvider,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('ketcher-standalone');
structServiceProvider =
new StandaloneStructServiceProvider() as StructServiceProvider;
}
const {
StandaloneStructServiceProvider,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('ketcher-standalone');
structServiceProvider =
new StandaloneStructServiceProvider() as StructServiceProvider;
}

const App = () => {
Expand Down
9 changes: 7 additions & 2 deletions example/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { valuesToReplace as ketcherReactValues } from '../packages/ketcher-react
import ketcherReactTSConfig from '../packages/ketcher-react/tsconfig.json';
import ketcherStandaloneTSConfig from '../packages/ketcher-standalone/tsconfig.json';
import { envVariables as exampleEnv } from './config/webpack.config';
import { INDIGO_WORKER_IMPORTS } from '../packages/ketcher-standalone/rollup.config';

const dotEnv = loadEnv('development', '.', '');
Object.assign(process.env, dotEnv, exampleEnv);
Expand Down Expand Up @@ -202,13 +203,17 @@ export default defineConfig({

/** Web worker in ketcher-standalone */
{
find: 'web-worker:./indigoWorker',
replacement: './indigoWorker?worker',
find: 'web-worker:./../indigoWorker',
replacement: './../indigoWorker?worker',
},
{
find: '_indigo-ketcher-import-alias_',
replacement: 'indigo-ketcher',
},
{
find: '_indigo-worker-import-alias_',
replacement: INDIGO_WORKER_IMPORTS.WASM_LOADER,
},
],
},
customLogger: logger,
Expand Down
Loading

0 comments on commit d6740d0

Please sign in to comment.