Ok, the first issue was fixed with changing:
webpack5 config
resolve: {
fallback: {
fs: false, //!!! Not "empty"! as it was in webpack4
browser: false,
},
},
It’s strange but now I have “File: …/node_modules/recast-detour/raycast.d.ts is not a module” on line:
import * as Recast from "recast-detour";
Tried to solve with:
webidl2ts -i https://raw.githubusercontent.com/BabylonJS/Extensions/master/recastjs/recast.idl -o recast.d.ts
it gives me an error message:
Error message
WebIDLParseError: Syntax error at line 23, since `interface rcConfig`:
attribute float[] bmin;
^ Attribute lacks a name
at Tokeniser.error (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:19433)
at parse (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:13800)
at Function.parse (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:23168)
at Function.parse (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:26441)
at i (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:32064)
at o (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:32259)
at /home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:32622
at B (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:32754)
at Module.F (/home/denis/.local/lib/node_modules/webidl2ts/node_modules/webidl2/dist/webidl2.js:1:32915)
at Object.<anonymous> (/home/denis/.local/lib/node_modules/webidl2ts/dist/parse-idl.js:47:43) {
bareMessage: 'Attribute lacks a name',
context: 'Syntax error at line 23, since `interface rcConfig`:\n' +
' attribute float[] bmin; \n' +
' ^',
line: 23,
sourceName: undefined,
input: '[] bmin; \n' +
'\n' +
" /// The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]\n" +
' attribute',
tokens: [
{ type: '[', value: '[', trivia: '', line: 23, index: 34 },
{ type: ']', value: ']', trivia: '', line: 23, index: 35 },
{
...
Node.js v17.0.1
@Cedric, don’t you know what’s wrong with my webidl2ts
attempt?
In my browser I have: Uncaught (in promise) TypeError: Recast is not a constructor
because I don’t know how to include Recast in my final js-bundle
In TS I use
the following code
import * as Recast from "recast-detour";
//<-- I removed recast.d.ts for now to flush the error "is not a module"
import { RecastJSPlugin } from '@babylonjs/core';
( async () => {
const recast = await new Recast();
const navigationPlugin = new RecastJSPlugin( recast );
navigationPlugin.setWorkerURL( "workers/navMeshWorker.js" );
} ) ();
well might be I’m having this problem because of removing recast.d.ts so it not imports into a final js bundle
If I manually download recast.js and include it as a script in my HTML file, I get this error:
Uncaught (in promise) TypeError: this.bjsRECAST.Vec3 is not a constructor