Problem/Motivation

Javascript errors
Uncaught SyntaxError: Identifier 'r' has already been declared
index.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'Fragment')
Uncaught TypeError: $(...).find(...).drupalSetSummary is not a function

Appears in a working enviroment for Drupal 10.0 that was upgraded to Drupal 10.1

Same problem happens with other components, Maybe is something related to Drupal 10.1 instead of Gutenberg project.
https://www.drupal.org/project/acquia_cms_site_studio/issues/3371531

Steps to reproduce

Install Drupal 10.0 with Gutenberg 2.7. working environment
Upgrade to Drupal 10.1, Blank page appears in gutenberg content
Upgrade component to 2.7 dev, same errors.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

gabykule created an issue. See original summary.

gabykule’s picture

Same problem happens with other components, I guess is something related to Drupal 10.1 instead of Gutenberg project.
https://www.drupal.org/project/acquia_cms_site_studio/issues/3371531

gabykule’s picture

Issue summary: View changes
patryk padus’s picture

@gabykule
One of solution is to update core drupal as patch fix weight of dependencies in aggregation engine
There is 10.1 update too.
I combine too #2990907 issue if this can help.
Pleas check if this two patch fix issue

rajeshreeputra’s picture

This is happening because Drupal 10.1 trying to aggregate the minified/aggregated js files from modules/projects.

stefan.butura’s picture

This seems to only occur with JS aggregation on. Here is quick workaround to disable JS aggregation only for Gutenberg libraries until there is an official solution.

/**
 * Implements hook_library_info_alter().
 */
function MODULENAME_library_info_alter(&$libraries, $extension) {
  if ($extension === 'gutenberg') {
    foreach ($libraries as $name => &$library) {
      if (empty($library['js'])) {
        continue;
      }

      foreach ($library['js'] as $file => &$properties) {
        $properties['minified'] = TRUE;
        $properties['preprocess'] = FALSE;
      }
    }
  }
}
ken hawkins’s picture

yustintr’s picture

The solution stefan.butura suggested worked fine for our project

rushikesh raval’s picture

Issue tags: +JS aggregation

This is issue related to Drupal Core issue/bug in JS aggregation. May be resolved in next update. Till that it can be used without any code or patch by disabling Aggregate JavaScript files.

Step: Administration-> Configuration ->Development -> Performance and disable Aggregate JavaScript files.

szeidler’s picture

Status: Active » Needs review
StatusFileSize
new852 bytes

It indeed seems to be related to the Drupal core issue in #2990907: JsOptimizer preg_replace gives null as return.

Since it's not recommendable to disable JS aggregation for the whole site the workaround in #6 just seem to be perfect. Here's a patch for it.

Since Drupal core issue has not gotten much attention, we might need to add this workaround to the module. Since it only affects the backend, it sounds absolutely alright to just disable aggregation for them.

Thanks for your contributions.

gold’s picture

Status: Needs review » Reviewed & tested by the community

The patch at #10 is looking good. I'm running with it in 2 environments at the moment and both apply fine.

+1 for RTBC.

leomontenegro6’s picture

Just tried the patch that disables JS aggregation for Gutenberg libraries, and I confirm it worked for resolving JS Errors when using Gutenberg in Drupal 10.

+1 for RTBC as well.

  • szeidler committed 1d1fe5ff on 8.x-2.x
    Issue #3372307 by szeidler, gabykule, stefan.butura: Javascript Errors...
szeidler’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for your contributions. This has been committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

leksat’s picture

Thanks for the fix!

How about a release for this one? Isn't it critical if the editor does not load at all?

szeidler’s picture

We have been hoping for bigger attention on the underlying core issue, but it ended up in a new Gutenberg release 8.x-2.8 now :)