Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.5.1-introduced dependency he breaks AMD usage #3000

Closed
ScottFreeCode opened this issue Sep 10, 2017 · 2 comments
Closed

3.5.1-introduced dependency he breaks AMD usage #3000

ScottFreeCode opened this issue Sep 10, 2017 · 2 comments
Assignees
Labels
area: browser browser-specific type: bug a defect, confirmed by a maintainer

Comments

@ScottFreeCode
Copy link
Contributor

@FelixHenninger on Gitter reported that Mocha 3.5.1 gets a "Mismatched anonymous define" error from RequireJS. The following is my investigation of the issue.

Our define-removing script uses the regex /typeof define === ['"]function['"] && define\.amd/g but the new dependency he uses a different, multi-line check.

Would it be possible to replace the dedefine script with a proper codemod using an AST parser and get something more like "if typeof define and define.amd are both checked in any way"?

Otherwise, I guess we could update the regex to something like /typeof\s+define\s*===?\s*['"]function['"]\s*&&\s*(?:define\.amd|typeof\s+define\.amd\s*===?\s*['"]object['"])/g And then update it again if we ever run into Yoda-style "function" === typeof define. Or if we ever run into typeof define.amd !== 'undefined'. Etc.

Alternatively, we could look for a bundler, bundler flag/option or bundler plugin that handles this stuff for us. Or request that he use the standard typeof define === 'function' && define.amd check.

@ScottFreeCode ScottFreeCode added area: browser browser-specific type: bug a defect, confirmed by a maintainer confirmed labels Sep 10, 2017
@boneskull
Copy link
Contributor

I can't actually remember why I had to write that script.

@boneskull
Copy link
Contributor

I'm just gonna hack around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants