adonisjs / adonis-websocket-client

Websocket client for AdonisJs framework.
52 stars 48 forks source link

Adonuxt integration not working regeneratorRuntime is not defined #34

Closed jericopulvera closed 6 years ago

jericopulvera commented 6 years ago

Hi I'm trying to use this together with adonuxt-boilerplate

nuxt.js

  plugins: [
    { src: "~plugins/ws.js", ssr: false },
  ]
 }

~/plugins/ws.js

import Ws from "@adonisjs/websocket-client";
const ws = Ws("ws://localhost:3333");

export default (ctx, inject) => {
  console.log(ctx);
  console.log(ws);
  // ctx.$ws = ws;
  // inject("ws", ws);
};

Error is ReferenceError regeneratorRuntime is not defined

Error preview server-bundler.js

exports.NuxtError = exports.createApp = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var createApp = function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(ssrContext) {
    var _this = this;

    var router, store, app, next, route, path, inject;
    return regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
jericopulvera commented 6 years ago

@IvanAquino it does not work for me. The error now appears at the console.

I made it work though by using babel-polyfill

npm i --save babel-polyfill

import "babel-polyfill"; import Ws from '@adonisjs/websocket-client'