Skip to content

Commit 8b18e2c

Browse files
StencilJS library uses lazy loading (bootstrapLazy) to dynamically import component chunks
1 parent f14dbff commit 8b18e2c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ export { Components, JSX } from './components';
44

55
export const Router = createRouter();
66
import { defineCustomElements } from 'stenciljs-components/loader';
7-
defineCustomElements(window);
7+
async function initializeStencilComponents() {
8+
console.log('Initializing StencilJS components...');
9+
await defineCustomElements(window, {
10+
resourcesUrl: './build/', // Adjust based on your deployment structure
11+
}); // Pass the global `window` object
12+
console.log('StencilJS components initialized.');
13+
}
14+
initializeStencilComponents();
15+
816
import { fluidEnvironments } from '../fluid';
917
const script = document.createElement('script');
1018
/**

stencil.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export const config: Config = {
1515
{
1616
type: 'www', // Optional, for a local development server
1717
// comment the following line to disable service workers in production
18-
serviceWorker: null,
18+
// baseUrl: '/', //Adjust based on your hosting setup
19+
// baseUrl: 'https://sanjeetkumaritoutlook.github.io/',
20+
// baseUrl:'/build/', //like in fluid it opens to localhost:3333/fluid/
1921
// baseUrl: 'https://myapp.local/',
20-
// baseUrl:'/build/', like in fluid it opens to localhost:3333/fluid/
21-
// baseUrl: '/', Adjust based on your hosting setup
22+
// buildDir: 'build', // Ensure this matches the build folder
23+
serviceWorker: null,
2224
},
2325

2426
],

0 commit comments

Comments
 (0)