Skip to content

Commit

Permalink
Create a Babel polyfill entry script
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 10, 2017
1 parent 94b8fce commit 7a2fd0c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"presets": [
[ "env", {
"modules": false,
"useBuiltIns": true,
"targets": {
"browsers": [
"last 2 Chrome versions",
Expand Down
29 changes: 25 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,30 @@ function gutenberg_register_scripts() {

// Editor Scripts.
wp_register_script( 'tinymce-nightly', 'https://fiddle.azurewebsites.net/tinymce/nightly/tinymce' . $suffix . '.js' );
wp_register_script( 'wp-i18n', plugins_url( 'i18n/build/index.js', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'i18n/build/index.js' ) );
wp_register_script( 'wp-element', plugins_url( 'element/build/index.js', __FILE__ ), array( 'react', 'react-dom', 'react-dom-server' ), filemtime( plugin_dir_path( __FILE__ ) . 'element/build/index.js' ) );
wp_register_script( 'wp-blocks', plugins_url( 'blocks/build/index.js', __FILE__ ), array( 'wp-element', 'tinymce-nightly' ), filemtime( plugin_dir_path( __FILE__ ) . 'blocks/build/index.js' ) );
wp_register_script(
'wp-esnext-polyfill',
plugins_url( 'polyfill/build/index.js', __FILE__ ),
array(),
filemtime( plugin_dir_path( __FILE__ ) . 'polyfill/build/index.js' )
);
wp_register_script(
'wp-i18n',
plugins_url( 'i18n/build/index.js', __FILE__ ),
array( 'wp-esnext-polyfill' ),
filemtime( plugin_dir_path( __FILE__ ) . 'i18n/build/index.js' )
);
wp_register_script(
'wp-element',
plugins_url( 'element/build/index.js', __FILE__ ),
array( 'wp-esnext-polyfill', 'react', 'react-dom', 'react-dom-server' ),
filemtime( plugin_dir_path( __FILE__ ) . 'element/build/index.js' )
);
wp_register_script(
'wp-blocks',
plugins_url( 'blocks/build/index.js', __FILE__ ),
array( 'wp-esnext-polyfill', 'wp-element', 'tinymce-nightly' ),
filemtime( plugin_dir_path( __FILE__ ) . 'blocks/build/index.js' )
);

// Editor Styles.
wp_register_style( 'wp-blocks', plugins_url( 'blocks/build/style.css', __FILE__ ), array(), filemtime( plugin_dir_path( __FILE__ ) . 'blocks/build/style.css' ) );
Expand Down Expand Up @@ -287,7 +308,7 @@ function gutenberg_scripts_and_styles( $hook ) {
wp_enqueue_script(
'wp-editor',
plugins_url( 'editor/build/index.js', __FILE__ ),
array( 'wp-api', 'wp-i18n', 'wp-blocks', 'wp-element' ),
array( 'wp-esnext-polyfill', 'wp-api', 'wp-i18n', 'wp-blocks', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'editor/build/index.js' ),
true // enqueue in the footer.
);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.23.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.4.0",
"chai": "^3.5.0",
"concurrently": "^3.4.0",
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );

const config = {
entry: {
polyfill: 'babel-polyfill',
i18n: './i18n/index.js',
blocks: './blocks/index.js',
editor: './editor/index.js',
Expand Down

0 comments on commit 7a2fd0c

Please sign in to comment.