-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
global.process.env = { | ||
...global.process.env, | ||
/* | ||
Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging. | ||
The conversion to boolean is required here. Why? Package.json defines | ||
IS_GUTENBERG_PLUGIN as follows: | ||
"config": { | ||
"IS_GUTENBERG_PLUGIN": true | ||
} | ||
Webpack then replaces references to IS_GUTENBERG_PLUGIN with a literal value `true`. | ||
The file you are reading right now, however, receives a string value "true": | ||
"true" === process.env.npm_package_config_IS_GUTENBERG_PLUGIN | ||
The code can only work consistently in both environments when the value of | ||
IS_GUTENBERG_PLUGIN is consistent. For this reason, the line below turns the | ||
string representation of IS_GUTENBERG_PLUGIN into a boolean value. | ||
*/ | ||
// eslint-disable-next-line @wordpress/is-gutenberg-plugin | ||
IS_GUTENBERG_PLUGIN: | ||
String( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) === 'true', | ||
/** | ||
* Feature flag guarding features specific to WordPress core. | ||
* It's important to set it to "true" in the test environment | ||
* to ensure the Gutenberg plugin can be cleanly merged into | ||
* WordPress core. | ||
*/ | ||
IS_WORDPRESS_CORE: true, | ||
}; | ||
/* | ||
* Feature flag guarding features specific to WordPress core. | ||
* It's important to set it to "true" in the test environment | ||
* to ensure the Gutenberg plugin can be cleanly merged into | ||
* WordPress core. | ||
*/ | ||
globalThis.IS_WORDPRESS_CORE = true; | ||
|
||
// Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging. | ||
// eslint-disable-next-line @wordpress/is-gutenberg-plugin | ||
globalThis.IS_GUTENBERG_PLUGIN = | ||
String( process.env.npm_package_config_IS_GUTENBERG_PLUGIN ) === 'true'; |
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