tsparticles / vue2

tsParticles Official Vue 2 component library
MIT License
16 stars 0 forks source link

Not working with nuxt 2.17 #15

Closed vDk3 closed 1 year ago

vDk3 commented 1 year ago

tsparticles is broken after upgrading to nuxt 2.17 (I also created fresh nuxt app and got same error).

console output for build:

>  ERROR  Failed to compile with 26 errors                                                            friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/ColorUtils.js                                friendly-errors 11:20:03

Module parse failed: Unexpected token (116:31)                                                      friendly-errors 11:20:03
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 function stringToAlpha(input) {
>     return stringToRgba(input)?.a;
| }
| export function stringToRgb(input) {
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/index.js 4:0-53 7:0-15 8:0-15
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/NumberUtils.js                               friendly-errors 11:20:03

Module parse failed: Unexpected token (120:27)                                                      friendly-errors 11:20:03
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 function calcPositionOrRandomFromSize(data) {
|     return {
>         x: ((data.position?.x ?? getRandom() * 100) * data.size.width) / 100,
|         y: ((data.position?.y ?? getRandom() * 100) * data.size.height) / 100,
|     };
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/Core/Utils/Circle.js 2:0-54 9:15-26
 @ ./node_modules/tsparticles-engine/esm/exports.js
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Move/OutModes.js         friendly-errors 11:20:03

Module parse failed: Unexpected token (12:35)                                                       friendly-errors 11:20:03
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
|             this.default = data.default;
|         }
>         this.bottom = data.bottom ?? data.default;
|         this.left = data.left ?? data.default;
|         this.right = data.right ?? data.default;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 67:0-58 67:0-58
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Options.js                         friendly-errors 11:20:03

Module parse failed: Unexpected token (14:101)                                                      friendly-errors 11:20:03
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
|     constructor(engine, container) {
|         this._findDefaultTheme = (mode) => {
>             return (this.themes.find((theme) => theme.default.value && theme.default.mode === mode) ??
|                 this.themes.find((theme) => theme.default.value && theme.default.mode === "any"));
|         };
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 52:0-42 52:0-42
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js

Module parse failed: Unexpected token (15:17)                                                       friendly-errors 11:20:03
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
|     }
|     load(data) {
>         if (data?.opacity_min !== undefined && data.minimumValue === undefined) {
|             data.minimumValue = data.opacity_min;
|         }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 74:0-69 74:0-69
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Size/SizeAnimation.js    friendly-errors 11:20:03

Module parse failed: Unexpected token (15:17)                                                       friendly-errors 11:20:03
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
|     }
|     load(data) {
>         if (data?.size_min !== undefined && data.minimumValue === undefined) {
|             data.minimumValue = data.size_min;
|         }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 77:0-63 77:0-63
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/CanvasUtils.js                               friendly-errors 11:20:03

Module parse failed: Unexpected token (16:35)                                                       friendly-errors 11:20:03
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 function paintBase(context, dimension, baseColor) {
>     context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
|     context.fillRect(0, 0, dimension.width, dimension.height);
| }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 83:0-36 83:0-36
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Shape/Shape.js           friendly-errors 11:20:03

Module parse failed: Unexpected token (16:70)                                                       friendly-errors 11:20:03
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
|                 this.options[altKey] = emptyValue;
|             }
>             this.options[mainKey] = deepExtend(this.options[mainKey] ?? emptyValue, item);
|             if (!this.options[altKey] || altOverride) {
|                 this.options[altKey] = deepExtend(this.options[altKey] ?? emptyValue, item);
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 75:0-56 75:0-56
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Core/Utils/Vector3d.js                             friendly-errors 11:20:03

Module parse failed: Unexpected token (17:24)                                                       friendly-errors 11:20:03
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
|             this.x = xOrCoords;
|             this.y = y;
>             this.z = z ?? 0;
|         }
|         else {
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 9:0-38 9:0-38
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/OptionsColor.js                    friendly-errors 11:20:03

Module parse failed: Unexpected token (19:17)                                                       friendly-errors 11:20:03
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
|     }
|     load(data) {
>         if (data?.value === undefined) {
|             return;
|         }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 53:0-47 53:0-47
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Number/ParticlesNumber.js

Module parse failed: Unexpected token (19:34)                                                       friendly-errors 11:20:03
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
|         }
|         this.density.load(data.density);
>         const limit = data.limit ?? data.max;
|         if (limit !== undefined) {
|             this.limit = limit;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 71:0-67 71:0-67
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Interactivity/Interactivity.js     friendly-errors 11:20:03

Module parse failed: Unexpected token (19:42)                                                       friendly-errors 11:20:03
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
|             return;
|         }
>         const detectsOn = data.detectsOn ?? data.detect_on;
|         if (detectsOn !== undefined) {
|             this.detectsOn = detectsOn;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 49:0-62 49:0-62
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Size/Size.js             friendly-errors 11:20:03

Module parse failed: Unexpected token (22:42)                                                       friendly-errors 11:20:03
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
|             return;
|         }
>         const animation = data.animation ?? data.anim;
|         if (animation !== undefined) {
|             this.animation.load(animation);
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 76:0-54 76:0-54
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Opacity/Opacity.js       friendly-errors 11:20:03

Module parse failed: Unexpected token (22:42)                                                       friendly-errors 11:20:03
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
|         }
|         super.load(data);
>         const animation = data.animation ?? data.anim;
|         if (animation !== undefined) {
|             this.animation.load(animation);
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 73:0-60 73:0-60
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Interactivity/Events/DivEvent.js   friendly-errors 11:20:03

Module parse failed: Unexpected token (31:30)                                                       friendly-errors 11:20:03
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
|             return;
|         }
>         const ids = data.ids ?? data.elementId ?? data.el;
|         if (ids !== undefined) {
|             this.ids = ids;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 42:0-64 42:0-64 44:0-64 44:0-64
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Number/ParticlesDensity.js

Module parse failed: Unexpected token (32:34)                                                       friendly-errors 11:20:03
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
|             this.enable = data.enable;
|         }
>         const width = data.width ?? data.area ?? data.value_area;
|         if (width !== undefined) {
|             this.width = width;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 72:0-68 72:0-68
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/engine.js                                          friendly-errors 11:20:03

Module parse failed: Unexpected token (32:49)                                                       friendly-errors 11:20:03
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
|         }
|         else {
>             this._configs.set(nameOrConfig.name ?? "default", nameOrConfig);
|         }
|     }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/index.js 1:0-34 9:24-30
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Move/MoveAttract.js      friendly-errors 11:20:03

Module parse failed: Unexpected token (33:36)                                                       friendly-errors 11:20:03
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
|             this.enable = data.enable;
|         }
>         const rotateX = data.rotate?.x ?? data.rotateX;
|         if (rotateX !== undefined) {
|             this.rotate.x = rotateX;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 62:0-61 62:0-61
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Interactivity/Events/Events.js     friendly-errors 11:20:03

Module parse failed: Unexpected token (35:40)                                                       friendly-errors 11:20:03
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
|             return;
|         }
>         this.onClick.load(data.onClick ?? data.onclick);
|         const onDiv = data.onDiv ?? data.ondiv;
|         if (onDiv !== undefined) {
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 45:0-62 45:0-62
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/ValueWithRandom.js                 friendly-errors 11:20:03

Module parse failed: Unexpected token (40:42)                                                       friendly-errors 11:20:03
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
|             return;
|         }
>         const animation = data.animation ?? data.anim;
|         if (animation !== undefined) {
|             this.animation.load(animation);
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js 1:0-56 2:43-58
 @ ./node_modules/tsparticles-engine/esm/exports.js
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/ParticlesOptions.js      friendly-errors 11:20:03

Module parse failed: Unexpected token (42:72)                                                       friendly-errors 11:20:03
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
|                 const item = data.groups[group];
|                 if (item !== undefined) {
>                     this.groups[group] = deepExtend(this.groups[group] ?? {}, item);
|                 }
|             }
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 59:0-61 59:0-61
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/Utils.js                                     friendly-errors 11:20:03

Module parse failed: Unexpected token (51:45)                                                       friendly-errors 11:20:03
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 async function loadFont(font, weight) {
|     try {
>         await document.fonts.load(`${weight ?? "400"} 36px '${font ?? "Verdana"}'`);
|     }
|     catch {
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/index.js 5:0-38 11:5-10
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/RgbColorManager.js                           friendly-errors 11:20:03

Module parse failed: Unexpected token (8:67)                                                        friendly-errors 11:20:03
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
|     }
|     handleColor(color) {
>         const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
|         if (rgbColor.r !== undefined) {
|             return rgbColor;
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/index.js 3:0-58 6:28-43
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/Particles/Move/Move.js             friendly-errors 11:20:03

Module parse failed: Unexpected token (90:40)                                                       friendly-errors 11:20:03
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
|         }
|         this.gravity.load(data.gravity);
>         const outModes = data.outModes ?? data.outMode ?? data.out_mode;
|         if (outModes !== undefined) {
|             if (typeof outModes === "object") {
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 63:0-54 63:0-54
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Options/Classes/ManualParticle.js                  friendly-errors 11:20:03

Module parse failed: Unexpected token (9:36)                                                        friendly-errors 11:20:03
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
|         if (data.position) {
|             this.position = {
>                 x: data.position.x ?? 50,
|                 y: data.position.y ?? 50,
|                 mode: data.position.mode ?? "percent",
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/exports.js 51:0-49 51:0-49
 @ ./node_modules/tsparticles-engine/esm/index.js
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                    friendly-errors 11:20:03

 ERROR  in ./node_modules/tsparticles-engine/esm/Utils/HslColorManager.js                           friendly-errors 11:20:03

Module parse failed: Unexpected token (9:67)                                                        friendly-errors 11:20:03
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
|     }
|     handleColor(color) {
>         const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
|         if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
|             return hslToRgb(hslColor);
                                                                                                    friendly-errors 11:20:03
 @ ./node_modules/tsparticles-engine/esm/index.js 2:0-58 6:69-84
 @ ./node_modules/vue2-particles/dist/vue2-particles.js
 @ ./plugins/vue2-particles.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
matteobruni commented 1 year ago

Related issue: https://github.com/nuxt/nuxt/issues/9221#issuecomment-830012118

You need to add tsparticles-engine and other tsparticles imported libraries in your nuxt.config.js build section in the transpile property, like this:

https://github.com/tsparticles/vue2/blob/2bcda535a0450886159e681b4f2dd4dc4318c1b1/apps/nuxt2/nuxt.config.js#L47-L49

vDk3 commented 1 year ago

Thanks for your response, after adding build transpile it now say "File was processed with these loaders" but still get few errors (i also tried to add tsparticles-plugin-emitters, tsparticles-move-base to transpile but still no luck)

ERROR in ./node_modules/tsparticles-plugin-emitters/cjs/EmitterInstance.js 109:22
Module parse failed: Unexpected token (109:22)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     this._startParticlesAdded = false;
|     let particlesOptions = (0, tsparticles_engine_1.deepExtend)({}, this.options.particles);
>     particlesOptions ??= {};
|     particlesOptions.move ??= {};
|     particlesOptions.move.direction ??= this.options.direction;
 @ ./node_modules/tsparticles-plugin-emitters/cjs/Emitters.js 9:26-54
 @ ./node_modules/tsparticles-plugin-emitters/cjs/index.js
 @ ./node_modules/tsparticles/cjs/index.js
 @ ./node_modules/babel-loader/lib??ref--2-0!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue
 @ ./.nuxt/router.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/server.js

ERROR in ./node_modules/tsparticles-engine/cjs/Core/Utils/FrameManager.js 25:31
Module parse failed: Unexpected token (25:31)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|         return;
|       }
>       container.lastFrameTime ??= timestamp;
|       const delta = initDelta(timestamp - container.lastFrameTime, container.fpsLimit, container.smooth);
|       container.addLifeTime(delta.value);
 @ ./node_modules/tsparticles-engine/cjs/Core/Container.js 23:23-54
 @ ./node_modules/tsparticles-engine/cjs/Core/Loader.js
 @ ./node_modules/tsparticles-engine/cjs/engine.js
 @ ./node_modules/tsparticles-engine/cjs/index.js
 @ ./node_modules/tsparticles-plugin-emitters/cjs/index.js
 @ ./node_modules/tsparticles/cjs/index.js
 @ ./node_modules/babel-loader/lib??ref--2-0!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue
 @ ./.nuxt/router.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/server.js

ERROR in ./node_modules/tsparticles-move-base/cjs/BaseMover.js 64:46
Module parse failed: Unexpected token (64:46)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|       pxRatio = container.retina.pixelRatio,
|       slowFactor = (0, Utils_1.getProximitySpeedFactor)(particle),
>       baseSpeed = (particle.retina.moveSpeed ??= (0, tsparticles_engine_1.getRangeValue)(moveOptions.speed) * pxRatio) * container.retina.reduceFactor,
|       moveDrift = particle.retina.moveDrift ??= (0, tsparticles_engine_1.getRangeValue)(particle.options.move.drift) * pxRatio,
|       maxSize = (0, tsparticles_engine_1.getRangeMax)(particleOptions.size.value) * pxRatio,
 @ ./node_modules/tsparticles-move-base/cjs/index.js 7:20-42
 @ ./node_modules/tsparticles-slim/cjs/index.js
 @ ./node_modules/tsparticles/cjs/index.js
 @ ./node_modules/babel-loader/lib??ref--2-0!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue?vue&type=script&lang=js&
 @ ./pages/index.vue
 @ ./.nuxt/router.js
 @ ./.nuxt/index.js
 @ ./.nuxt/server.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/server.js
matteobruni commented 1 year ago

Try adding these packages too:

https://github.com/tsparticles/vue2/blob/e2bbc05e3a79494a64f61ef3668036e6f3c3153b/apps/nuxt2/package.json#L29-L31

vDk3 commented 1 year ago

That didn't help, i just checked sample app and noticed that you added

  // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
  ssr: false,

  // Target: https://go.nuxtjs.dev/config-target
  target: "static",

However, I am using ssr and target is server (these are also the default values in nuxt) and then I get these errors that I have posted above.

matteobruni commented 1 year ago

Have you created the Nuxt plugin file?

You need to add it to your Nuxt config like this:

https://github.com/tsparticles/vue2/blob/e2bbc05e3a79494a64f61ef3668036e6f3c3153b/apps/nuxt2/nuxt.config.js#L27-L32

and it MUST be "client", it can't work server side.

You can see the sample plugin here:

https://github.com/tsparticles/vue2/blob/e2bbc05e3a79494a64f61ef3668036e6f3c3153b/apps/nuxt2/plugins/vue2-particles.ts#L1-L4

In my app I didn't use SSR since I don't need it for a test application, but since the plugin must be installed as a client one it shouldn't matter.

vDk3 commented 1 year ago

Yes i did that, just change ssr to true and target to server and try to build your test app, it throw errors.

import { loadFull } from "tsparticles"

this import causes these build errors since its always imported in server side too.

matteobruni commented 1 year ago

https://v2.nuxt.com/docs/features/nuxt-components#the-client-only-component

Is this helpful?

vDk3 commented 1 year ago

Yeah it works this way:

async particlesInit(engine) {
  if (process.client) {
    const { loadFull } = await import("tsparticles")
    await loadFull(engine)
  }
},