You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been looking for similar issue, but it seems to be a pretty niche area so I wanted to discuss it here. I will try to explain it as best as I can. I am working on a fork of Kaitai Web IDE. It's environment where you can describe binary formats using YAML, then that yaml is sent to compiler that generates parsers for those binary formats in requested language. Web IDE also has functionality to get that generated code and execute it to parse data in the browser.
🔦 Context
So the workflow looks like this:
User writes grammar for a binray format(YAML)
That grammar is compiled to JS code(module with UMD like header)
Generated code gets executed in the browser to parse data and display it for the user in form of Object tree and HexViewer;
The 3rd point is executed in WebWorker, so web workers recives binary(arrayBuffer) data and generated Parsers code to execute that code on data and return parsed data. It was working fine as long as I just used plain JS file
Now I wanted to add more logic to it, do some code splitting and the best way to do it is to define that worker as a module so I can use import statements, static typing and all the Typescript goodies so I just added {type: 'module'} the way it was recommended in Parcel docs:
Is there a way to tell Parcel that this specific worker should not be able to execute CommonJS modules(should not have exports object present during execution) and how can I do it?
The text was updated successfully, but these errors were encountered:
💬 RFC
I have been looking for similar issue, but it seems to be a pretty niche area so I wanted to discuss it here. I will try to explain it as best as I can. I am working on a fork of Kaitai Web IDE. It's environment where you can describe binary formats using YAML, then that yaml is sent to compiler that generates parsers for those binary formats in requested language. Web IDE also has functionality to get that generated code and execute it to parse data in the browser.
🔦 Context
So the workflow looks like this:
The 3rd point is executed in WebWorker, so web workers recives binary(arrayBuffer) data and generated Parsers code to execute that code on data and return parsed data. It was working fine as long as I just used plain JS file
Now I wanted to add more logic to it, do some code splitting and the best way to do it is to define that worker as a module so I can use import statements, static typing and all the Typescript goodies so I just added {type: 'module'} the way it was recommended in Parcel docs:
And from this point onward, Worker is trying to execute CommonJS requires in UMD header from generated code.
The example header looks like this:
Is there a way to tell Parcel that this specific worker should not be able to execute CommonJS modules(should not have exports object present during execution) and how can I do it?
The text was updated successfully, but these errors were encountered: