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

Webpack build process is overridding wp.utils #1569

Closed
ryanwelcher opened this issue Jun 28, 2017 · 4 comments
Closed

Webpack build process is overridding wp.utils #1569

ryanwelcher opened this issue Jun 28, 2017 · 4 comments

Comments

@ryanwelcher
Copy link
Contributor

I was working on #1557 and noticed that even though word-count.js was added as a dependency, it was not available at window.wp.utils. The entire object is being overridden by the following portion of webpack.config.js

const entryPointNames = [
	'element',
	'i18n',
	'components',
	'utils',
	'blocks',
	'date',
	'editor',
]


entryPointNames.forEach( entryPointName => {
	externals[ entryPointName ] = {
		'this': [ 'wp', entryPointName ],
	};
} );

Essentially, any items in entryPointNames will be added to thewp object and override anything already exisiting with the same name.

Can we namespace this to wp-gb or something similar?

@ryanwelcher
Copy link
Contributor Author

ryanwelcher commented Jun 28, 2017

I've added a PR for this #1571. The approach I took was to rename the utils folder and references to utils-gb

@nylen
Copy link
Member

nylen commented Jun 28, 2017

See previous discussion around #940 (comment):

word-count.js doesn't clobber window.wp.utils

So this means that the webpack version needs to be loaded first. We can accomplish this by adding wp-utils as a dependency of word-count.

@ryanwelcher
Copy link
Contributor Author

@nylen thanks for your support on this!

I have put together a PR for the Word Count feature ( #1624 ) and am running into an issue where WordCounter is not available when the component initializes as it is loaded after Gutenberg. I have accommodated for that in the component but it would be better if the core items were loaded first. However, this puts us back to the issue of the namespace being overridden when Gutenberg loads.

We could address this by changing the namespace in Gutenberg from uilts to gb.utils or something to that effect. Do you have any suggestions for the best way to address this?

@nylen
Copy link
Member

nylen commented Jul 1, 2017

I think the utils thing is a good first exercise in integrating with the rest of core's JavaScript. I'll see about fixing it over on your PR.

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

No branches or pull requests

2 participants