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

Consider using Preact for Gutenberg rendering #2732

Closed
Show file tree
Hide file tree
Changes from all 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
20 changes: 7 additions & 13 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-element',
gutenberg_url( 'element/build/index.js' ),
array( 'react', 'react-dom', 'react-dom-server' ),
array( 'preact', 'preact-compat' ),
filemtime( gutenberg_dir_path() . 'element/build/index.js' )
);
wp_register_script(
Expand Down Expand Up @@ -218,26 +218,20 @@ function gutenberg_register_vendor_scripts() {
$suffix = SCRIPT_DEBUG ? '' : '.min';

// Vendor Scripts.
$react_suffix = ( SCRIPT_DEBUG ? '.development' : '.production' ) . $suffix;
gutenberg_register_vendor_script(
'react',
'https://unpkg.com/react@next/umd/react' . $react_suffix . '.js'
'preact',
'https://unpkg.com/preact@8.2.5/dist/preact.js'
);
gutenberg_register_vendor_script(
'react-dom',
'https://unpkg.com/react-dom@next/umd/react-dom' . $react_suffix . '.js',
array( 'react' )
);
gutenberg_register_vendor_script(
'react-dom-server',
'https://unpkg.com/react-dom@next/umd/react-dom-server.browser' . $react_suffix . '.js',
array( 'react' )
'preact-compat',
'https://unpkg.com/preact-compat@3.17.0/dist/preact-compat.js',
array( 'preact' )
);
$moment_script = SCRIPT_DEBUG ? 'moment.js' : 'min/moment.min.js';
gutenberg_register_vendor_script(
'moment',
'https://unpkg.com/moment@2.18.1/' . $moment_script,
array( 'react' )
array( 'preact' )
);
$tinymce_version = '4.6.5';
gutenberg_register_vendor_script(
Expand Down
73 changes: 50 additions & 23 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"moment": "2.18.1",
"moment-timezone": "0.5.13",
"mousetrap": "1.6.1",
"preact": "8.2.5",
"preact-compat": "3.17.0",
"prop-types": "15.5.10",
"react": "15.6.1",
"react-autosize-textarea": "0.4.8",
"react-click-outside": "2.3.1",
"react-color": "2.13.4",
"react-datepicker": "0.46.0",
"react-dom": "15.6.1",
"react-redux": "5.0.6",
"react-resizable-box": "2.0.6",
"react-slot-fill": "1.0.1",
Expand Down
5 changes: 5 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ const config = {
// There are currently resolution errors on RSF's "mitt" dependency
// when imported as native ES module
'react-slot-fill': 'react-slot-fill/lib/rsf.js',

// Replace React with Preact.
'React': 'preact-compat',
'ReactDOM': 'preact-compat',
'react-dom': 'preact-compat',
},
},
module: {
Expand Down