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

Fixes umd build for non-web targets #4050

Closed
wants to merge 5 commits into from
Closed

Conversation

rigor789
Copy link
Contributor

Starting with axios@0.21.2 - it fails to run in a NativeScript app. We can work around the issue by aliasing/defining window, but perhaps this affects more projects than just NativeScript.


In #3401 webpack has been updated to 4.x, which slightly modified the axios/dist/axios umd build:

/* axios v0.21.1 | (c) 2020 by Matt Zabriskie */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["axios"] = factory();
	else
		root["axios"] = factory();
})(this, function() {
// ^^^^ - this has changed between 0.21.1 and 0.21.2
/* axios v0.21.2 | (c) 2021 by Matt Zabriskie */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["axios"] = factory();
	else
		root["axios"] = factory();
})(window, function() {
// ^^^^^^ - this has changed between 0.21.1 and 0.21.2

After some searching, I found this issue in the webpack repo: webpack/webpack#6522 that describes the same scenario, and the proposed solution is to add globalObject: 'this' to preserve the old behavior.

With this fix, running npm run build correctly uses this as it used to.

@rigor789
Copy link
Contributor Author

Hey @jasonsaayman, is there anything I can help with to get this fix merged/released? Thanks!

@rigor789
Copy link
Contributor Author

Looks like this has already been landed in e52cd3a - closing.

@rigor789 rigor789 closed this Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant