ThatOpen / engine_web-ifc

Reading and writing IFC files with Javascript, at native speeds.
https://thatopen.github.io/engine_web-ifc/demo
Mozilla Public License 2.0
573 stars 169 forks source link

[Bug]: can't build code with browserify - invalid JS node type StaticBlock #870

Open alex-moon opened 2 weeks ago

alex-moon commented 2 weeks ago

What happened?

I am attempting to patch a fork of this library to include the IfcLoader: https://github.com/jscastro76/threebox

You can see my attempted edits here: https://github.com/placechangers/threebox/commit/3e3cacde4c20e50a9dd7e3f7748a08bfd2384767

When I try to build threebox I get this error:

Error: Unknown node type StaticBlock.
    at Controller.replace (/opt/threebox/node_modules/unassert/node_modules/estraverse/estraverse.js:632:27)
    at Object.replace (/opt/threebox/node_modules/unassert/node_modules/estraverse/estraverse.js:675:27)
    at unassertAst (/opt/threebox/node_modules/unassert/dist/index.cjs:277:21)
    at applyUnassertWithoutSourceMap (/opt/threebox/node_modules/unassertify/index.js:91:29)
    at Stream.end (/opt/threebox/node_modules/unassertify/index.js:121:20)
    at _end (/opt/threebox/node_modules/through/index.js:65:9)
    at stream.end (/opt/threebox/node_modules/through/index.js:74:5)
    at DestroyableTransform.onend (/opt/threebox/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:633:28)
    at DestroyableTransform.emit (node:events:531:35)

if I attempt to run browserify itself, I get this error:

node_modules/.bin/browserify exports.js
SyntaxError: Unexpected token (15448:11) while parsing /opt/threebox/node_modules/web-ifc/web-ifc-api-node.js while parsing file: /opt/threebox/node_modules/web-ifc/web-ifc-api-node.js
    at DestroyableTransform.end [as _flush] (/opt/threebox/node_modules/insert-module-globals/index.js:114:21)
    at DestroyableTransform.prefinish (/opt/threebox/node_modules/readable-stream/lib/_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:519:28)
    at prefinish (/opt/threebox/node_modules/readable-stream/lib/_stream_writable.js:619:14)
    at finishMaybe (/opt/threebox/node_modules/readable-stream/lib/_stream_writable.js:627:5)
    at endWritable (/opt/threebox/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at Writable.end (/opt/threebox/node_modules/readable-stream/lib/_stream_writable.js:594:22)
    at DestroyableTransform.onend (/opt/threebox/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:633:28)
    at DestroyableTransform.emit (node:events:531:35)

In a word, Browserify is having trouble with these:

static {
    this.FOO = {type: 3, value: "FOO"};
}

I have written a little Python script that simply replaces these with:

static FOO = {type: 3, value: "FOO"};

This works. I have no idea how this would be fixed properly - the build is transpiling down to an ES implementation that browserify doesn't understand...? At any rate, I thought I should let you know.

Version

0.0.55

What browsers are you seeing the problem on?

Firefox

Relevant log output

n/a

Anything else?

No response

beachtom commented 1 week ago

So that code is generated by emscripten as part of its compile process.

We have a browser version in web-ifc-api.js - can you make it use that file - is it any different?