-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade to core-js@3. This entails not only updating the package, but also: - Setting the core-js version in the babel config. - Dropping @babel/polyfill and using core-js directly. - Removing superfluous polyfills (e.g. URL). - Removing superfluous runtime module replacements in evergreen. - Modifying several entry points to use boot/polyfills rather than their own code, including the server entry point. - Minor lint fixes. Remove polyfill-specific lib/url tests. Don't use boot in standalone notifications. Don't depend on boot from packages. Update core-js to 3.6.2 to fix regex bugs. Switch corejs option in preset-env to `3`. Update core-js to 3.6.3. * Explicitly include `globalThis` polyfill. For some reason, it's not included in `stable` as it should be. Also ensure that gridicons are transpiled. * Switch back to core-js: 3.6 in config. This helps avoid the globalThis workaround. * Update corejs for dependencies too. * Turn polyfills into a package. * Changes after review. * Remove gridicons transpilation whitelisting. * Include calypso-polyfills in transpilation list. * Add slash to package name in transpilation list.
- Loading branch information
Showing
17 changed files
with
182 additions
and
100 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
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,24 +1,13 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import '@babel/polyfill'; | ||
import svg4everybody from 'svg4everybody'; | ||
import '@webcomponents/url'; | ||
import URLSearchParamsPolyfill from '@ungap/url-search-params'; | ||
import 'isomorphic-fetch'; | ||
import 'globalthis/auto'; | ||
import '@automattic/calypso-polyfills'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import localStoragePolyfill from 'lib/local-storage-polyfill'; | ||
|
||
// Only used in Calypso proper, so no need to turn into a package | ||
// and add to calypso-polyfills for now. | ||
localStoragePolyfill(); | ||
|
||
const isBrowser = typeof window !== 'undefined'; | ||
if ( isBrowser ) { | ||
// Polyfill SVG external content support. Noop in the evergreen build. | ||
svg4everybody(); | ||
// Polyfill URLSearchParams. | ||
window.URLSearchParams = window.URLSearchParams || URLSearchParamsPolyfill; | ||
} |
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
rules: { | ||
'import/no-extraneous-dependencies': [ 'error', { packageDir: __dirname } ], | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Calypso Polyfills | ||
|
||
This package includes several configurations for required polyfills for Calypso, targeting three different environments: node, evergreen (newer browsers) and fallback (older browsers). | ||
|
||
## Features | ||
|
||
`calypso-polyfills` ties into the Calypso build process, to ensure that only the required polyfills for each build target are needed. Through the use of Babel's `preset-env` and `browserslist` configurations, we strip out any polyfills that are supported for all browsers that are supported by that build target. | ||
|
||
See the root directory's `package.json` for the list of supported browsers for each build target. | ||
|
||
## Usage | ||
|
||
In Node.js, simply require the package: | ||
|
||
```js | ||
require( '@automattic/calypso-polyfills' ); | ||
``` | ||
|
||
In a browser, a similar naked import will include the polyfills (defaulting to the `fallback` set): | ||
|
||
```js | ||
import from '@automattic/calypso-polyfills'; | ||
``` | ||
|
||
If you want to explicitly include the `evergreen` or `fallback` polyfills, you can append to the import path: | ||
|
||
```js | ||
import from '@automattic/calypso-polyfills/browser-evergreen'; | ||
import from '@automattic/calypso-polyfills/browser-fallback'; | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Polyfills required for the "evergreen" build of Calypso. | ||
// Note that these polyfills will not necessarily be included in the build, | ||
// since Calypso makes use of @babel/preset-env and browserslist configs to | ||
// avoid including polyfills for features that are supported acroll all target | ||
// browsers. | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import 'core-js/stable'; | ||
import 'regenerator-runtime/runtime'; |
Oops, something went wrong.