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

Add Perl script to list JS dependencies and suggest a load order #965

Closed
wants to merge 1 commit into from

Conversation

nylen
Copy link
Member

@nylen nylen commented May 31, 2017

I wrote this script while I was working on #929 to better understand the dependencies between our various Webpack bundles. I'm not sure that we want to add this to the repo or not, but it was useful to me to determine the needed order of these modules in our Webpack config. (This is mainly important for the test build, as in the actual plugin this is handled via WP's script dependency resolution mechanism).

It's a bit unfortunate that we have to do this twice (once on the client side and once on the server side). However, I'm also thinking that this script (or something like it) will come in handy to calculate actual dependencies when we start adding more Webpack-built files to WP core.

@nylen
Copy link
Member Author

nylen commented May 31, 2017

I meant to include example output here as well:

$ bin/list-js-dependencies.pl 
'blocks' depends on 'components'
'blocks' depends on 'element'
'blocks' depends on 'i18n'
'blocks' depends on 'utils'
'components' depends on 'element'
'components' depends on 'i18n'
'editor' depends on 'blocks'
'editor' depends on 'components'
'editor' depends on 'date'
'editor' depends on 'element'
'editor' depends on 'i18n'
'editor' depends on 'utils'

Suggested load order:

element
i18n
components
utils
blocks
date
editor

A more robust version of this task would actually parse the JS files instead of just looking for a regex like from '(blocks|component|date|....

@aduth
Copy link
Member

aduth commented May 31, 2017

Are we depending on a specific load order?

@nylen
Copy link
Member Author

nylen commented Jun 1, 2017

Yes. On the server this is handled by registering script dependencies via WordPress's standard mechanism; also, the test build will break if the entry points in the Webpack config are rearranged sufficiently.

I'm fine with closing this out and saving the script that way. I opened a PR because I found it useful, and it may be more useful in the future.

@aduth
Copy link
Member

aduth commented Jun 2, 2017

I'm indifferent. Fine with merging, or as Gist territory.

@nylen
Copy link
Member Author

nylen commented Jun 5, 2017

@nylen nylen closed this Jun 5, 2017
@nylen nylen deleted the add/js-dependencies-script branch June 5, 2017 15:29
@nylen
Copy link
Member Author

nylen commented Aug 3, 2017

This script still comes in handy occasionally (#2205). I've also updated the gist above for the recent changes to our import syntax in #2172.

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.

2 participants