Skip to content

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Sep 24, 2019

Work in progress.

I'll move to Trac as soon as Travis turns green :)

@sirreal
Copy link
Member

sirreal commented Sep 24, 2019

You'll want to delete these lines so the DependencyExtractionWebpackPlugin finds the externals.

const externals = {
react: 'React',
'react-dom': 'ReactDOM',
tinymce: 'tinymce',
moment: 'moment',
jquery: 'jQuery',
lodash: 'lodash',
'lodash-es': 'lodash',
};
packages.forEach( ( name ) => {
externals[ `@wordpress/${ name }` ] = {
this: [ 'wp', camelCaseDash( name ) ],
};
} );

@gziolo
Copy link
Member Author

gziolo commented Sep 24, 2019

@sirreal, thanks for pointers. It solved the issue 🎉

I had to include @wordpress/block-directory as a dependency. We will have to fix it on Gutenberg side first as it's hidden behind the flag and it shouldn't be necessary to be registered and enqueued in WordPress 5.3. /cc @youknowriad

@omarreiss, we add a number of PHP files for each JS script. Is it fine to keep them next to distribution version of JS files as presented on the screenshot?

Screen Shot 2019-09-24 at 17 27 29

The same structure is present in both build and src folders.

@gziolo
Copy link
Member Author

gziolo commented Sep 26, 2019

The discussion should continue on WordPress Trac: https://core.trac.wordpress.org/ticket/48154.

@gziolo
Copy link
Member Author

gziolo commented Dec 4, 2019

I updated the patch with the latest changes from the master branch.

In addition, I switched the output format for asset files to JSON.

Screen Shot 2019-12-04 at 11 23 24

It also looks like JSON is now required to run WordPress so we can take advantage of it:
https://make.wordpress.org/core/2019/10/15/php-native-json-extension-now-required/

WORKING_DIR + 'wp-includes/js/'
],
assets: [
WORKING_DIR + 'wp-includes/js/**/*.asset.php'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the core trac image the php assets are now stored in the /src/wp-includes/assets/dist folder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more complex than that.

This is where webpack generates those PHP assets, we move them to /src/wp-includes/assets/dist or /build/wp-includes/assets/dist depending where webpack operates. It's even more hard to follow when you take into account that npm run build:dev operates in src folder, but npm run build uses build folder ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name should probably be updated to webpack-generated-assets :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntwb I included some tweaks to make it easier to follow. I hope it helps:

ba91cc1

@gziolo
Copy link
Member Author

gziolo commented Jan 3, 2020

Resolved with https://core.trac.wordpress.org/changeset/47035.

@gziolo gziolo closed this Jan 3, 2020
@gziolo gziolo deleted the try/dependency-extraction-webpack-plugin branch January 3, 2020 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants