You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I would like to switch my project to vite.js instead of react-scripts but I can't because of a dependency of ketcher-react.
Steps to Reproduce
Replace react-scripts by vite.js
Configure vite
exportdefaultdefineConfig(({ mode })=>{return{plugins: [react(),viteTsconfigPaths(),svgrPlugin()],optimizeDeps: {esbuildOptions: {// Node.js global to browser globalThisdefine: {global: 'globalThis',},// Enable esbuild polyfill pluginsplugins: [NodeGlobalsPolyfillPlugin({buffer: true,process: true// -> needed for some of my external packages}),NodeModulesPolyfillPlugin(),],},},build: {sourcemap: false,rollupOptions: {cache: false,plugins: [// Enable rollup polyfills plugin// used during production bundlingrollupNodePolyFill(),],},},server: {port: 3000,},};});
Uncaught SyntaxError: Identifier 'process' has already been declared (at ketcher-react.js?v=c1ad07e1:7821:5)
// node_modules/@juggle/resize-observer/lib/utils/process.js
var process; // <- process is already defined. process seems to be declare as a global var.
var init_process2 = __esm({
"node_modules/@juggle/resize-observer/lib/utils/process.js"() {
init_process();
init_buffer();
init_hasActiveObservations();
init_hasSkippedObservations();
init_deliverResizeLoopError();
init_broadcastActiveObservations();
init_gatherActiveObservationsAtDepth();
process = function() {
var depth = 0;
gatherActiveObservationsAtDepth(depth);
while (hasActiveObservations()) {
depth = broadcastActiveObservations();
gatherActiveObservationsAtDepth(depth);
}
if (hasSkippedObservations()) {
deliverResizeLoopError();
}
return depth > 0;
};
}
});
Desktop (please complete the following information):
OS: macOS 13.2.1
Browser: chrome
Version: Version 111.0.5563.64
Ketcher version
2.7.2
The text was updated successfully, but these errors were encountered:
Hi @ben-ikt thanks for reaching out! We are currently investigating using vite.js as the build tool for the project. You can follow this issue to check progress with that: #2411
Hi @KonstantinEpam23, here is how I patch @juggle/resize-observer via an esbuild plugin.
/** * HACK @juggle/resize-observer/lib/utils/process.js used by ketcher-react * 'var process' create a conflict with NodeGlobalsPolyfillPlugin({ process: true }) */constketcherReactTranspile=()=>{return{name: 'ketcher-react-transpile',setup(build){build.onLoad({filter: /@juggle\/resize-observer\/lib\/utils\/process.js/},async(args)=>{constsource=awaitreadFile(args.path,'utf8');consthackedSource=source.replace('var process =','var processTask =').replace('export { process }','export { processTask as process }');return{contents: hackedSource};});},};};
And in my vite.config.js
optimizeDeps: {esbuildOptions: {// Node.js global to browser globalThisdefine: {global: 'globalThis',},// Enable esbuild polyfill pluginsplugins: [ketcherReactTranspile(),NodeGlobalsPolyfillPlugin({process: true,}),NodeModulesPolyfillPlugin(),],},},
Hi, I would like to switch my project to vite.js instead of react-scripts but I can't because of a dependency of ketcher-react.
Steps to Reproduce
Actual behavior
Desktop (please complete the following information):
Ketcher version
2.7.2
The text was updated successfully, but these errors were encountered: