Skip to content

Comments

Avoid use of anonymous declaration of Asynchronous Module Definition (AMD) module#12554

Open
adamshaylor wants to merge 2 commits intoemscripten-core:mainfrom
pollinate:master
Open

Avoid use of anonymous declaration of Asynchronous Module Definition (AMD) module#12554
adamshaylor wants to merge 2 commits intoemscripten-core:mainfrom
pollinate:master

Conversation

@adamshaylor
Copy link

Per the require.js docs:

Mismatched anonymous define() modules... If you manually code a script
tag in HTML to load a script with an anonymous define() call, this
error can occur.

https://requirejs.org/docs/errors.html#mismatch

That is preciesly what happens in our case when we attempt to embed a
custom build of the Draco decoder into a script loaded at runtime on a
Magento website (which uses Require.js heavily).

@welcome
Copy link

welcome bot commented Oct 20, 2020

Thank you for submitting a pull request! If this is your first PR, make sure to add yourself to AUTHORS.

adamshaylor added a commit to pollinate/emscripten that referenced this pull request Oct 20, 2020
@sbc100
Copy link
Collaborator

sbc100 commented Oct 20, 2020

The PR description could perhaps be better. A don't know anything about require.js or what AMD means so maybe I'm not best placed to come up with a better one by maybe something like "Avoid use of anonymous define() in require.js mode"?

Am I correct in understanding that only users of require.js will be effected by this change?

@adamshaylor adamshaylor changed the title De-anonymize AMD module Avoid use of anonymous declaration of Asynchronous Module Definition (AMD) Oct 20, 2020
@adamshaylor
Copy link
Author

adamshaylor commented Oct 20, 2020

@sbc100, that’s correct. AMD is the JavaScript module format used by require.js. This is a relatively obscure JS module format, especially since the advent of a native module format. Nevertheless, it is still around, and emscripten will cause it to break if the global define() is called using the anonymous signature as it was before.

Apologies for the broken unit tests. I’m looking into those. If you happen to have any pointers on those, I’d be much obliged.

@adamshaylor adamshaylor changed the title Avoid use of anonymous declaration of Asynchronous Module Definition (AMD) Avoid use of anonymous declaration of Asynchronous Module Definition (AMD) module Oct 20, 2020
@sbc100
Copy link
Collaborator

sbc100 commented Oct 20, 2020

It looks like just one test failure. You should be able to reproduce it with:

$ ./tests/runner.py other.test_define_modularize

adamshaylor added a commit to pollinate/emscripten that referenced this pull request Oct 22, 2020
Per the require.js docs:

> Mismatched anonymous define() modules... If you manually code a script
> tag in HTML to load a script with an anonymous define() call, this
> error can occur.

https://requirejs.org/docs/errors.html#mismatch

That is preciesly what happens in our case when we attempt to embed a
custom build of the Draco decoder into a script loaded at runtime on a
Magento website (which uses Require.js heavily).

Jira reference:

https://pollinate-jira.atlassian.net/browse/MTOC-3284
adamshaylor added a commit to pollinate/emscripten that referenced this pull request Jan 7, 2021
Base automatically changed from master to main March 8, 2021 23:49
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants