When JS is aggregated, the transitions field config form is broken and shows an error.

Uncaught SyntaxError: identifier starts immediately after numeric literal

Field States Transitions js aggregation error

The issue is in the 2.0.0 version, which is the latest available to drupal 10.x users.

It can be fixed by recompiling the state_machine assets, or setting the library files as minified.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mortona2k created an issue. See original summary.

mortona2k’s picture

Version: 2.x-dev » 2.0.0

I'm still on drupal 10.x, which is compatible up to 2.0.0.

mortona2k’s picture

Status: Active » Needs review

Seems to be working now.

lazzyvn’s picture

Status: Needs review » Closed (cannot reproduce)

Your merge request simply changes the value of `minified: true` in the libraries. But for the CDN, this makes no difference. I test on drupal 11 it works fine i dont see any error in log

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mortona2k’s picture

Status: Closed (cannot reproduce) » Needs work
StatusFileSize
new2.85 MB

You may be right about the external libraries, but there are also some internal libraries in the module that are causing issues.

Here is the aggregated js snippet that is causing the reported error:

eme=Xge(1.toString)

This causes:
Uncaught SyntaxError: identifier starts immediately after numeric literal

This is coming from state_machine/dist/state-machine.umd.js:

eme=Xge(1 .toString)

Notice the space between 1 and .toString.

I don't know what that code is supposed to mean anyway, it doesn't make sense with a space either.

I was able to fix it by recompiling the assets in /state_machine.

Funnily, the newly generated code has this, which seems to be ok:
tme=Jge(1.1.toString)

Other changes to the libraries file were not needed.

I can't tell if this issue was really caused by aggregation, or triggered by it on a bad build?
The 2.0.0 build works when js is not aggregated, but breaks when it is.

Here is a patch for 2.0.0 that just recompiles the assets, and seems to work with/without aggregation.
This is likely necessary for any drupal 10.x users, and we might need a separate dev branch for it.

mortona2k’s picture

On a fresh Drupal 11 install, any of these things fixed the error I got with the 2.0.0 release.

1. Disabling js aggregation.
2. Setting minified: true on state-machine.umd.js.
3. Recompiling state_machine assets.

mortona2k’s picture

Title: Error when JS is aggregated » Error when JS is aggregated v2.0.0/10.x
Issue summary: View changes

  • lazzyvn committed 425641e2 on 2.x
    feat: #3577762 Error when JS is aggregated v2.0.0/10.x
    
lazzyvn’s picture

try dev version i use newsest version
error because Vite/esbuild build (1 .toString) and drupal remove space.