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

Upgrade to core-js@3. #38660

Merged
merged 9 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions apps/notifications/src/standalone/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import '@babel/polyfill';
/**
* External dependencies
*/
import '@automattic/calypso-polyfills';
import ReactDOM from 'react-dom';
import React from 'react';

/**
* Internal dependencies
*/
import Notifications, { refreshNotes } from '../panel/Notifications';
import AuthWrapper from './auth-wrapper';
import { receiveMessage, sendMessage } from './messaging';

require( '../panel/boot/stylesheets/style.scss' );
/**
* Style dependencies
*/
import '../panel/boot/stylesheets/style.scss';

const localePattern = /[&?]locale=([\w_-]+)/;
const match = localePattern.exec( document.location.search );
Expand All @@ -21,7 +30,7 @@ const customEnhancer = next => ( reducer, initialState ) =>
const customMiddleware = {
APP_IS_READY: [ () => sendMessage( { action: 'iFrameReady' } ) ],
APP_RENDER_NOTES: [
( store, { latestType, newNoteCount } ) =>
( st, { latestType, newNoteCount } ) =>
newNoteCount > 0
? sendMessage( {
action: 'render',
Expand All @@ -31,35 +40,35 @@ const customMiddleware = {
: sendMessage( { action: 'renderAllSeen' } ),
],
CLOSE_PANEL: [ () => sendMessage( { action: 'togglePanel' } ) ],
OPEN_LINK: [ ( store, { href } ) => window.open( href, '_blank' ) ],
OPEN_LINK: [ ( st, { href } ) => window.open( href, '_blank' ) ],
OPEN_SITE: [
( store, { siteId, href } ) => {
( st, { siteId, href } ) => {
sendMessage( { action: 'openSite', siteId } );
window.open( href, '_blank' );
},
],
OPEN_POST: [
( store, { siteId, postId, href } ) => {
( st, { siteId, postId, href } ) => {
sendMessage( { action: 'openPost', siteId, postId } );
window.open( href, '_blank' );
},
],
OPEN_COMMENT: [
( store, { siteId, postId, commentId, href } ) => {
( st, { siteId, postId, commentId, href } ) => {
sendMessage( { action: 'openComment', siteId, postId, commentId } );
window.open( href, '_blank' );
},
],
SET_LAYOUT: [
( store, { layout } ) =>
( st, { layout } ) =>
sendMessage( {
action: 'widescreen',
widescreen: layout === 'widescreen',
} ),
],
VIEW_SETTINGS: [ () => window.open( 'https://wordpress.com/me/notifications' ) ],
EDIT_COMMENT: [
( store, { siteId, postId, commentId, href } ) => {
( st, { siteId, postId, commentId, href } ) => {
sendMessage( { action: 'editComment', siteId, postId, commentId } );
window.open( href, '_blank' );
},
Expand Down
2 changes: 1 addition & 1 deletion babel.dependencies.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config = {
{
modules: false,
useBuiltIns: 'entry',
corejs: 2,
corejs: 3.6,
// Exclude transforms that make all code slower, see https://github.com/facebook/create-react-app/pull/5278
exclude: [ 'transform-typeof-symbol' ],
},
Expand Down
17 changes: 3 additions & 14 deletions client/boot/polyfills.js
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;
}
23 changes: 0 additions & 23 deletions client/lib/url/test/url-type-polyfill.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
/* eslint-disable import/no-nodejs-modules */

require( '@babel/polyfill' );
require( '@automattic/calypso-polyfills' );

/**
* External dependencies.
Expand Down
60 changes: 38 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
]
},
"dependencies": {
"@automattic/calypso-polyfills": "file:./packages/calypso-polyfills",
"@automattic/color-studio": "2.2.0",
"@automattic/components": "file:./packages/components",
"@automattic/composite-checkout": "file:./packages/composite-checkout",
Expand All @@ -46,14 +47,11 @@
"@automattic/tree-select": "file:./packages/tree-select",
"@babel/cli": "7.7.5",
"@babel/core": "7.7.5",
"@babel/polyfill": "7.7.0",
"@babel/runtime": "7.7.6",
"@emotion/core": "10.0.22",
"@emotion/styled": "10.0.23",
"@github/webauthn-json": "0.4.1",
"@types/react-transition-group": "4.2.3",
"@ungap/url-search-params": "0.1.4",
"@webcomponents/url": "0.7.4",
"@wordpress/api-fetch": "3.8.0",
"@wordpress/base-styles": "1.1.0",
"@wordpress/block-editor": "3.4.0",
Expand Down Expand Up @@ -98,7 +96,6 @@
"component-file-picker": "0.2.1",
"cookie": "0.4.0",
"cookie-parser": "1.4.4",
"core-js": "2.6.10",
"cpf_cnpj": "0.2.0",
"create-react-class": "15.6.3",
"creditcards": "3.1.0",
Expand Down Expand Up @@ -129,7 +126,6 @@
"flux": "3.1.3",
"fuse.js": "3.4.6",
"get-video-id": "3.1.4",
"globalthis": "1.0.0",
"globby": "10.0.1",
"gridicons": "3.3.1",
"gzip-size": "5.1.1",
Expand All @@ -145,7 +141,6 @@
"imports-loader": "0.8.0",
"inherits": "2.0.4",
"is-my-json-valid": "2.20.0",
"isomorphic-fetch": "2.2.1",
"jquery": "1.12.3",
"keymaster": "1.6.2",
"lerna": "3.18.4",
Expand Down Expand Up @@ -199,7 +194,6 @@
"store": "2.0.12",
"striptags": "3.1.1",
"superagent": "3.8.3",
"svg4everybody": "2.1.9",
"textarea-caret": "3.1.0",
"tinymce": "4.9.6",
"to-title-case": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/calypso-build/babel/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = ( api, opts ) => ( {
[
require.resolve( '@babel/preset-env' ),
{
corejs: 2,
corejs: 3.6,
blowery marked this conversation as resolved.
Show resolved Hide resolved
modules: modulesOption( opts ),
useBuiltIns: 'entry',
// Exclude transforms that make all code slower, see https://github.com/facebook/create-react-app/pull/5278
Expand Down
5 changes: 5 additions & 0 deletions packages/calypso-polyfills/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'import/no-extraneous-dependencies': [ 'error', { packageDir: __dirname } ],
},
};
30 changes: 30 additions & 0 deletions packages/calypso-polyfills/README.md
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, simply require the package:
sgomes marked this conversation as resolved.
Show resolved Hide resolved

```js
require( '@automattic/calypso-polyfills' );
```

In the client, a similar naked import will include the polyfills (defaulting to the `fallback` set):
sgomes marked this conversation as resolved.
Show resolved Hide resolved

```js
import from '@automattic/calypso-polyfills';
```

If you want to explicitly include the `evergreen` or `fallback` polyfills, you can append that to the import path:

```js
import from '@automattic/calypso-polyfills/evergreen';
import from '@automattic/calypso-polyfills/fallback';
```
11 changes: 11 additions & 0 deletions packages/calypso-polyfills/evergreen.js
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';
Loading