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

Blocks: Spike on webpack plugin to externalize WP deps #31486

Closed
sirreal opened this issue Mar 15, 2019 · 4 comments · Fixed by #31513
Closed

Blocks: Spike on webpack plugin to externalize WP deps #31486

sirreal opened this issue Mar 15, 2019 · 4 comments · Fixed by #31513
Assignees
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg Jetpack

Comments

@sirreal
Copy link
Member

sirreal commented Mar 15, 2019

  • Externalize known WP deps
  • Provide a json describing the WP deps

Something like:

// Webpack plugin config
new ExternalizeWpScriptDeps( someConfig );

// entry.js
import { Component } from '@wordpress/element';

// output.js
// …whatever that webpack magic looks like
const Component = wp.element;

// output.deps.json
[ 'wp-element' ]

Enqueue would be aware of WP deps, no more disconnect!

wp_enqueue_script( 'entry.js', json_decode( 'path/to/output.deps.json' ) );
@sirreal sirreal added Jetpack [Goal] Gutenberg Working towards full integration with Gutenberg [Type] New feature labels Mar 15, 2019
@sirreal sirreal self-assigned this Mar 15, 2019
@roccotripaldi
Copy link
Member

I love this!

@simison
Copy link
Member

simison commented Mar 18, 2019

Provide a json describing the WP deps

How should we take wp-polyfill into account?

@sirreal
Copy link
Member Author

sirreal commented Mar 18, 2019

Provide a json describing the WP deps

How should we take wp-polyfill into account?

Initially, I was thinking of just adding it all the time. Gutenberg does just that.

Importing the polyfill import '@wordpress/polyfill' should work just fine with this approach, the polyfill would be flagged as an external dependency and added to the dependencies list. We could manually do that.

A short-term enhancement would be to make the polyfill configurable in some way, whether to add it automatically to some entry points and a way of overriding that.

In the future, part of our toolchain might handle adding the polyfill when unsupported language features are encountered. I expect that is significantly more complicated than we want here.

@simison
Copy link
Member

simison commented Mar 18, 2019

Including the polyfill dependency all the time sounds like a sensible first step.

In the future, part of our toolchain might handle adding the polyfill when unsupported language features are encountered. I expect that is significantly more complicated than we want here.

Issue for tracking this #31231 Automattic/jetpack#11793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg Jetpack
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants