Closed Tassfighter closed 5 years ago
Can you share any of the application code? I am wondering what functionality you may be using that may need to be polyfilled. According to the docs for library:
Important! This preset does not include @babel/polyfill for size reasons. If you need polyfills in your library code, consider importing @babel/polyfill, core-js, or other alternative.
I am using neutrino together with lerna in a monorepo. My library is just a little boilerplate to create web servers with hapi.
import fs from 'fs';
import Hapi from 'hapi';
import pino from 'hapi-pino';
import Inert from 'inert';
import Vision from 'vision';
import HapiSwagger from 'hapi-swagger';
import Pack from '../../package';
import systemRoutes from './routes'; // tiny hello world route
const prettyPrint = true; // process.env.NODE_ENV !== 'production';
const logger = require('pino')({ prettyPrint });
// TODO: enable TLS by removing the following line
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
const {
HOST, PORT, TLS_KEY, TLS_CERT, CORS,
} = process.env;
function buildContext() {
const context = {
host: HOST || '0.0.0.0',
port: PORT || 6781,
routes: {
cors: String(CORS) !== 'false',
},
};
if (TLS_KEY && TLS_CERT) {
const tls = {
key: fs.readFileSync(TLS_KEY),
cert: fs.readFileSync(TLS_CERT),
};
return { ...context, ...tls };
}
return context;
}
class Server {
constructor({ context, routes, info }) {
this.info = info;
this.context = { ...buildContext(), ...(context || {}) };
this.server = Hapi.server(this.context);
logger.info(systemRoutes, routes);
this.routes = systemRoutes;
if (routes && routes.length > 0) {
this.routes = [...systemRoutes, ...routes];
}
logger.info(this.routes);
this.server.route(this.routes);
}
async start() {
try {
await this.server.register([
Inert,
Vision,
{
plugin: HapiSwagger,
options: {
info: this.info || {
title: 'API Documentation',
version: Pack.version,
},
},
},
{
plugin: pino,
options: {
prettyPrint,
// Redact Authorization headers, see https://getpino.io/#/docs/redaction
redact: ['req.headers.authorization'],
},
},
]);
await this.server.start();
} catch (err) {
logger.fatal(err);
process.exit(1);
}
}
}
export default Server;
This is how I use the library.
import Node from 'full-stack-node';
const routes = [];
const context = {
port: process.env.PORT || 8200,
};
const server = new Node.Server({ context, routes });
server.start();
Seems like this is the same error: 1417
So the issue is in neutrino's library preset and react-component preset. Some how they cannot handle async/await.
@eliperelman Thanks! Finally I got it...
import "core-js/stable";
import "regenerator-runtime/runtime";
from babel-polyfill
regeneratorRuntime.mark(function _callee() { ^
ReferenceError: regeneratorRuntime is not defined at /mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:211:7 at /mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:242:6 at Module../src/server/index.js (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:246:2) at webpack_require (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:30:30) at Module../src/index.js (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:108:65) at webpack_require (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:30:30) at Object.0 (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:279:18) at __webpack_require__ (/mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:30:30) at /mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:94:18 at /mnt/work/gitlab/platform/mediq/packages/full-stack/node/build/index.js:97:10
Please try to answer the following questions: