# Class properties lassen Frontend-Kompilierung crashen (Code aus SW-Doku)

**URL:** <https://forum.shopware.com/t/class-properties-lassen-frontend-kompilierung-crashen-code-aus-sw-doku/97651>\
**Category:** Programmierung\
**Tags:** programming\
**Created:** [18. Dezember 2022 um 08:10 UTC](https://forum.shopware.com/t/class-properties-lassen-frontend-kompilierung-crashen-code-aus-sw-doku/97651 "2022-12-18T08:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstr](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jstr](https://forum.shopware.com/u/jstr)\
**Post date:** [18. Dezember 2022 um 08:10 UTC](https://forum.shopware.com/t/class-properties-lassen-frontend-kompilierung-crashen-code-aus-sw-doku/97651/1 "2022-12-18T08:10:17Z")

</div>

Hallo,

bei dem Versuch, das Beispiel aus

> **[Add custom Javascript](https://developer.shopware.com/docs/guides/plugins/plugins/storefront/add-custom-javascript#configuring-your-plugins)**

zu übernehmen, sorgt das Einfügen der static property „options“ im Code zum Absturz der Frontend-Kompilierung:

```auto
Module parse failed: Unexpected token (5:19)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| export default class MaschinenhandelMeyerProductPostMessaging extends Plugin {
|
> static options = {
| product: null
| };

```

Hier scheint das Problem zu sein, dass Klassenfelder an sich (static ist wohl irrelevant) nicht vom Interpreter verstanden werden.

Bisher habe ich das hier dazu gefunden:

> <https://github.com/webpack/webpack/issues/9708>
>
> \# Bug report
> 
> 
> 
> 
> 
> 
> \*\*What is the current behavior?\*\*
> 
> Webpack fails wit…h error:
> 
> \`\`\`
> ERROR in /var/app/src/util/bunyan/logstash.js 42:8
> Module parse failed: Unexpected token (42:8)
> You may need an appropriate loader to handle this file type.
> | 
> | let LogstashStream = exports.LogstashStream = class LogstashStream extends \_events.EventEmitter {
> \> \_name = 'bunyan';
> | \_level = 'info';
> | \_server = \_os2.default.hostname();
> @ /var/app/src/util/logger.js 24:16-44
> @ ./index.js
> @ multi babel-polyfill index.js
> \`\`\`
> 
> \*\*If the current behavior is a bug, please provide the steps to reproduce.\*\*
> 
> Try compiling any file that uses class properties, for example:
> 
> \`\`\`
> class X {
> y = 1
> }
> \`\`\`
> 
> or use the Parser directly:
> 
> \`\`\`
> \> new (require('./node\_modules/webpack/lib/Parser'))().parse('class X { y = 1 }', {})
> Thrown:
> \[SyntaxError: Unexpected token (1:12)
> \] {
> pos: 12,
> loc: Position { line: 1, column: 12 },
> raisedAt: 13
> }
> \`\`\`
> 
> 
> 
> 
> 
> 
> 
> 
> \*\*What is the expected behavior?\*\*
> 
> This should not throw an error
> 
> 
> 
> 
> \*\*Other relevant information:\*\*
> webpack version: 4.40.2
> Node.js version: 12.10.0
> Operating System: Debian Buster (Debian 10)
> Additional tools:

Bei mir läuft Node 16.18.0 und Shopware 6.4.16.1.

Gruß

js

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [18. Dezember 2022 um 14:04 UTC](https://forum.shopware.com/t/class-properties-lassen-frontend-kompilierung-crashen-code-aus-sw-doku/97651/2 "2022-12-18T14:04:49Z")

</div>

Hast du irgendwelche NPM Abhängigkeiten hinzugefügt, für die einen Loader konfiguriert werden muss?

Für mich sieht es soweit in Ordnung aus.

Könntest du den Inhalt der JS-Datei hier zeigen?

Ich hatte bis jetzt nie Probleme mit irgendwelchen Properties und dem Kompilieren des Frontends.

Verwendest du storefront watch oder baust du das Storefront mit dem build-storefront Script?

---

<div class="post-metadata">

**Author:** ![jstr](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jstr](https://forum.shopware.com/u/jstr)\
**Post date:** [19. Dezember 2022 um 08:51 UTC](https://forum.shopware.com/t/class-properties-lassen-frontend-kompilierung-crashen-code-aus-sw-doku/97651/3 "2022-12-19T08:51:29Z")

</div>

Ah, hat sich hier gerade erledigt. Meine JavaScript-Plugin-Datei hatte nur die Endung „.plugin“ und nicht „.plugin.js“ 🙄
