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

@wordpress/scripts 27.0.0 does not create correct build output #58074

Closed
andreaslindahl opened this issue Jan 22, 2024 · 2 comments
Closed

@wordpress/scripts 27.0.0 does not create correct build output #58074

andreaslindahl opened this issue Jan 22, 2024 · 2 comments
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@andreaslindahl
Copy link

Description

I have a plugin where I keep a large number of blocks and use @wordpress/scripts.

My webpack.config.js looks like this:

const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const { getWebpackEntryPoints } = require('@wordpress/scripts/utils');

module.exports = {
    ...defaultConfig,
	entry: {
		... getWebpackEntryPoints(),
		blocks: { import: "./src/js/blocks.js", filename: "js/[name].js" },
		documentation: { import: "./src/js/documentation.js", filename: "js/[name].js" },
		frontend: { import: "./src/js/frontend.js", filename: "js/[name].js" }
	}
};

As you can see, I use getWebpackEntryPoints to add entry points for each block in the plugin.

Using version 26.19.0 the correct files for each block are copied and/or compiled on build (i.e. render.php, index.js, style-index.css etc).

When updating to version 27.0.0 this no longer works. Only block.json and render.php are added to the build folder for each block.

And printing out the output of getWebpackEntryPoints only prints out "[Function (anonymous)]" instead of the object with entry points (as in version 26.19.0)

Step-by-step reproduction instructions

N/A

Screenshots, screen recording, code snippet

No response

Environment info

Wordpress 6.4.2
@wordpress/scripts 27.0.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@andreaslindahl andreaslindahl added the [Type] Bug An existing feature does not function as intended label Jan 22, 2024
@gziolo gziolo added the [Package] Scripts /packages/scripts label Jan 25, 2024
@capybara-aficionado
Copy link

I was able to temporarily bypass this issue by swapping:
...getWebpackEntryPoints(),
with
...defaultConfig.entry(),

@gziolo
Copy link
Member

gziolo commented Mar 1, 2024

Using package internal methods from @wordpress/scripts/utils is risky as we never committed to making it public API. I’m glad you made it work by updating the webpack config. By the way, we only made an exception for documenting how to extend the default webpack config due to high demand, but it’s very hard iterating on it without introducing some unintentional issues from time to time.

@gziolo gziolo closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants