-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the packager work with babel strict mode transform
At the moment we have to disable strict mode for the transform-es2015-modules-commonjs because strict mode leaks to the global scope and breaks the bridge. It was due to the way the polyfills were bundled in the package. To fix it, I wrapped the polyfill modules in an IIFE. Then when strict mode was enabled some polyfills were broken due to strict mode errors so that was fixed too. Also removed the IIFE from the polyfills that included one.
- Loading branch information
1 parent
4f37fe6
commit 9701013
Showing
15 changed files
with
955 additions
and
942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
/* eslint global-strict: 0 */ | ||
(function(GLOBAL) { | ||
/** | ||
* The document must be shimmed before anything else that might define the | ||
* `ExecutionEnvironment` module (which checks for `document.createElement`). | ||
*/ | ||
/* eslint strict: 0 */ | ||
/** | ||
* The document must be shimmed before anything else that might define the | ||
* `ExecutionEnvironment` module (which checks for `document.createElement`). | ||
*/ | ||
|
||
// The browser defines Text and Image globals by default. If you forget to | ||
// require them, then the error message is very confusing. | ||
function getInvalidGlobalUseError(name) { | ||
return new Error( | ||
'You are trying to render the global ' + name + ' variable as a ' + | ||
'React element. You probably forgot to require ' + name + '.' | ||
); | ||
// The browser defines Text and Image globals by default. If you forget to | ||
// require them, then the error message is very confusing. | ||
function getInvalidGlobalUseError(name) { | ||
return new Error( | ||
'You are trying to render the global ' + name + ' variable as a ' + | ||
'React element. You probably forgot to require ' + name + '.' | ||
); | ||
} | ||
global.Text = { | ||
get defaultProps() { | ||
throw getInvalidGlobalUseError('Text'); | ||
} | ||
GLOBAL.Text = { | ||
get defaultProps() { | ||
throw getInvalidGlobalUseError('Text'); | ||
} | ||
}; | ||
GLOBAL.Image = { | ||
get defaultProps() { | ||
throw getInvalidGlobalUseError('Image'); | ||
} | ||
}; | ||
// Force `ExecutionEnvironment.canUseDOM` to be false. | ||
if (GLOBAL.document) { | ||
GLOBAL.document.createElement = null; | ||
}; | ||
global.Image = { | ||
get defaultProps() { | ||
throw getInvalidGlobalUseError('Image'); | ||
} | ||
}; | ||
// Force `ExecutionEnvironment.canUseDOM` to be false. | ||
if (global.document) { | ||
global.document.createElement = null; | ||
} | ||
|
||
// There is no DOM so MutationObserver doesn't make sense. It is used | ||
// as feature detection in Bluebird Promise implementation | ||
GLOBAL.MutationObserver = undefined; | ||
})(this); | ||
// There is no DOM so MutationObserver doesn't make sense. It is used | ||
// as feature detection in Bluebird Promise implementation | ||
global.MutationObserver = undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.