Unable to run BabylonJS with Ionic(Angular)

Hi there,

I’m trying to run BabylonJS with Ionic but I’m getting an error related to VideoFrame. See below.

Packages
@ionic/angular”: “^7.0.0”,
@angular/core”
“typescript”: “~5.0.2”
@babylonjs/core”: “^6.23.1”,
@babylonjs/loaders”: “^6.23.1”,
@babylonjs/materials”: “^6.23.1”,

VideoFrame is defined in typescript’s lib.dom file. What libs are you including in your tsconfig, and what version of typescript are you using? . Your TypeScript version should support it.

See my tsconfig below. Also, this is a new Ionic project.

{
	"compileOnSave": false,
	"compilerOptions": {
		"baseUrl": "./",
		"outDir": "./dist/out-tsc",
		"forceConsistentCasingInFileNames": true,
		"strict": true,
		"noImplicitOverride": true,
		"noPropertyAccessFromIndexSignature": true,
		"noImplicitReturns": true,
		"noFallthroughCasesInSwitch": true,
		"sourceMap": true,
		"declaration": false,
		"downlevelIteration": true,
		"experimentalDecorators": true,
		"moduleResolution": "node",
		"importHelpers": true,
		"target": "es2022",
		"module": "es2020",
		"lib": ["es2018", "dom"],
		"useDefineForClassFields": false
	},
	"angularCompilerOptions": {
		"enableI18nLegacyMessageIdFormat": false,
		"strictInjectionParameters": true,
		"strictInputAccessModifiers": true,
		"strictTemplates": true
	}
}

Hi @RaananW

I still can’t get BJS to run with Ionic, please help! :slight_smile:
Is there a workaround I can add or just isolate the issue?

want to share the project?

I have created a new public repo. Ran the project and still getting the same issue.

1 Like

i’ll look into that later today

So - upgrading to typescript 5.1 fixed the issue. Of course, we should support earlier typescript versions, so we will probably duplicate the VideoFrame definition to our own polyfill for the next version. Until then - skipLibCheck and upgrading to 5.1 will solve the issue

2 Likes

Many thanks, @RaananW I will give this a go and get back to you, thanks again for the help.

1 Like

Hi @RaananW, all is now working as expected, thanks again. :smiley:

1 Like