Particle-Network / particle-web-auth-core

Apache License 2.0
16 stars 9 forks source link

@particle-network/auth-core-modal does not work with Vite-TS #9

Open tiennguyen12g opened 1 month ago

tiennguyen12g commented 1 month ago

Hello everyone, if you know this issue, please help me fix it. I follow the tutorial, but this error:

 [ERROR] Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-pre-bundle]

    node_modules/micro-ftch/index.js:55:26:
      55 │     const https = require('https');
     ╵                           ~~~~~~~

File main.tsx

import { AuthCoreContextProvider } from '@particle-network/auth-core-modal';
import { Buffer } from 'buffer';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';

if (typeof window !== 'undefined') {
    window.Buffer = Buffer;
    window.__PARTICLE_ENVIRONMENT__ = import.meta.env.VITE_PARTICLE_ENV;
}

ReactDOM.createRoot(document.getElementById('root')!).render(
    <React.StrictMode>
        <AuthCoreContextProvider
            options={{
                projectId: import.meta.env.VITE_PROJECT_ID as string,
                clientKey: import.meta.env.VITE_CLIENT_KEY as string,
                appId: import.meta.env.VITE_APP_ID as string,
            }}
        >
            <App />
        </AuthCoreContextProvider>
    </React.StrictMode>
);
Hnng20112002 commented 1 month ago

maybe u can config alias for vite by using https-browserify or another https polyfills