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

#6246 - Import indigo with EXPORT_ES6 & USE_ES6_IMPORT_META options #6311

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_PATH=/v2
PUBLIC_URL=./
GENERATE_SOURCEMAP = false
GENERATE_SOURCEMAP = false
14 changes: 4 additions & 10 deletions example/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
addBundleVisualizer,
addWebpackModuleRule,
addWebpackPlugin,
addWebpackResolve,
} = require('customize-cra');
const webpack = require('webpack');
const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin');
Expand All @@ -26,6 +27,9 @@ module.exports = override(
loader: 'source-map-loader',
exclude: /node_modules/,
}),
addWebpackResolve({
fallback: { url: false },
}),
addWebpackPlugin(new webpack.EnvironmentPlugin(envVariables)),
addWebpackPlugin(
new HtmlReplaceWebpackPlugin([
Expand All @@ -35,16 +39,6 @@ module.exports = override(
},
]),
),
addWebpackPlugin(
new CopyPlugin({
patterns: [
{
from: '../node_modules/ketcher-standalone/**/*.wasm',
to: '[name][ext]',
},
],
}),
),
);

module.exports.envVariables = envVariables;
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
18 changes: 5 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions packages/ketcher-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"node": ">=14"
},
"scripts": {
"build": "cross-env NODE_ENV=production rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=wasm rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=base64WithoutRender SEPARATE_INDIGO_RENDER=true rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=wasmWithoutRender SEPARATE_INDIGO_RENDER=true rollup -c -m true",
"build": "cross-env NODE_ENV=production rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=base64Cjs rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=wasm rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=base64WithoutRender SEPARATE_INDIGO_RENDER=true rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=base64WithoutRenderCjs SEPARATE_INDIGO_RENDER=true rollup -c -m true && cross-env NODE_ENV=production INDIGO_MODULE_NAME=wasmWithoutRender SEPARATE_INDIGO_RENDER=true rollup -c -m true",
"start": "cross-env NODE_ENV=development rollup -c -m true -w",
"test": "run-s test:prettier test:eslint:quiet test:types test:unit",
"test:eslint": "eslint . --ext .ts,.js",
Expand All @@ -56,6 +56,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-strip": "^2.0.0",
"@surma/rollup-plugin-off-main-thread": "^2.2.3",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.12",
"cross-env": "^7.0.3",
Expand All @@ -79,20 +80,18 @@
],
"exports": {
".": {
"import": "./dist/index.modern.js",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/cjs/index.js"
},
"./dist/binaryWasm": {
"import": "./dist/binaryWasm/index.modern.js",
"require": "./dist/binaryWasm/index.js"
"import": "./dist/binaryWasm/index.js"
},
"./dist/jsNoRender": {
"import": "./dist/jsNoRender/index.modern.js",
"require": "./dist/jsNoRender/index.js"
"import": "./dist/jsNoRender/index.js",
"require": "./dist/cjs/jsNoRender/index.js"
},
"./dist/binaryWasmNoRender": {
"import": "./dist/binaryWasmNoRender/index.modern.js",
"require": "./dist/binaryWasmNoRender/index.js"
"import": "./dist/binaryWasmNoRender/index.js"
}
}
}
Loading
Loading