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

fix(PEER-752): reproduce type error #28

Merged
merged 1 commit into from
Aug 29, 2024
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
11 changes: 10 additions & 1 deletion apps/kernel/management-shell-browser/src/app-router.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { lazy } from 'react';
import { RouteObject, createBrowserRouter } from 'react-router-dom';
import { ErrorBoundary } from '../../shared-ui-components/src/lib/errors/error-boundary';
import { reduxUserSessionRepository } from './domains/people/user-session/adapters/redux-repository';
Expand All @@ -10,16 +11,22 @@ import { HomePage } from './domains/search/pages/home';
import { Layout } from './domains/shared/components/layout';
import { Dashboard } from './domains/shared/pages/dashboard';

const PublicPage = lazy(() => import('./domains/shared/pages/public'));

export const routes: Array<RouteObject> = [
{
path: '/',
element: <Layout />,
errorElement: <ErrorBoundary fallback={null} />,
errorElement: <ErrorBoundary fallback={<h1>Router Error Boundary</h1>} />,
children: [
{
index: true,
element: <HomePage />,
},
{
path: 'public',
element: <PublicPage />,
},
{
path: 'auth/sign-in',
element: <SignInPage />,
Expand All @@ -46,3 +53,5 @@ export type IRouter = typeof browserRouter;
if (import.meta.hot) {
import.meta.hot.dispose(() => browserRouter.dispose());
}

// Give me a docker command to run a docker container with node 18 image and serve the index.html file under dist/apps/kernel/management-shell-browser folder
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const Layout = () => {
<li>
<Link to="workspaces">Workspaces Dashboard</Link>
</li>
<li>
<Link to="public">Public Page</Link>
</li>
{auth.isAuthenticated && <button onClick={() => auth.removeUser()}>Log out</button>}
</ul>
</nav>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const PublicPage = () => {
return <h1>Dynamic Public Page V1</h1>;
};

export default PublicPage;
22 changes: 22 additions & 0 deletions apps/kernel/management-shell-browser/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ import path from 'node:path';
import { defineConfig, searchForWorkspaceRoot } from 'vite';
import viteTsConfigPaths from 'vite-tsconfig-paths';

const deriveFileNameFromChunkInfo = (chunkInfo: { facadeModuleId: string | null }): string => {
if (!chunkInfo.facadeModuleId) {
return 'assets/js/[name]-[hash].js';
}

const basename = path.basename(chunkInfo.facadeModuleId);
if (basename.startsWith('@')) {
return 'assets/js/[name]-[hash].js';
}

const ext = path.extname(chunkInfo.facadeModuleId);
const outputFileName = chunkInfo.facadeModuleId.replace(__dirname, 'assets/js').replace(ext, '.js');
return outputFileName;
};

export default defineConfig({
root: __dirname,
build: {
Expand All @@ -12,6 +27,13 @@ export default defineConfig({
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
output: {
chunkFileNames: deriveFileNameFromChunkInfo,
entryFileNames: deriveFileNameFromChunkInfo,
assetFileNames: 'assets/[ext]/[name].[ext]',
},
},
},
cacheDir: '../../../node_modules/.vite/kernel-management-shell-browser',
server: {
Expand Down
Loading