-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typeorm Decorators cause Module parse failed: Unexpected character '�' #776
Comments
Can you share the contents of |
@styfle index.ts import 'reflect-metadata';
import path from 'path';
import http from 'http';
import express from 'express';
import session from 'express-session';
import connectSqlite3 from 'connect-sqlite3';
import { ApolloServer } from 'apollo-server-express';
import { buildSchema } from 'type-graphql';
import compression from 'compression';
import dotv from 'dotenv';
import cors from 'cors';
import Log from './logger/winstonLogger';
import { PubSub } from 'apollo-server-express';
import { CameraResolver } from './resolvers/CameraResolver';
import ValidateLicenseKey from './license';
import { createTypeormConn } from './createTypeormCon';
import { getCoreTempinfo } from './logger/temperature';
import { getNetworkinfo } from './logger/network';
import { getCpuInfo } from './logger/cpu';
const pubsub = new PubSub();
dotv.config();
const SQLiteStore = connectSqlite3(session);
const server = async () => {
createTypeormConn().then(() => {
new ValidateLicenseKey().timer();
});
const app = express();
app.use(cors());
app.use(
session({
store: new SQLiteStore({
db: 'database.db',
dir: 'usr/local/database',
concurrentDB: true,
}),
name: 'uavid',
secret: process.env.ACCESS_TOKEN_SECRET || '',
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
maxAge: 1000 * 60 * 60 * 24 * 100,
},
})
);
if (process.env.NODE_ENV === 'production') {
console.log('Running Production Server');
app.use(compression());
app.use(express.static(path.join(__dirname, '../../frontend/build')));
// Route all requests to index
app.get('/*', function (_, res) {
res.sendFile(path.join(__dirname, '../../frontend/build/index.html'), function (err) {
if (err) {
res.status(500).send(err);
}
});
});
}
const apolloServer = new ApolloServer({
schema: await buildSchema({
resolvers: [CameraResolver],
validate: false,
}),
subscriptions: {
path: '/subscriptions',
},
context: ({ req, res }) => ({ req, res, pubsub }),
playground: {
settings: {
'request.credentials': 'include',
},
},
});
apolloServer.applyMiddleware({ app, cors: false });
const httpServer = http.createServer(app);
apolloServer.installSubscriptionHandlers(httpServer);
const port = process.env.SERVER_PORT || 4000;
httpServer.listen(port, () => {
Log.server(`started at http://localhost:${port}/graphql`);
});
};
server(); tsconfig.json {
"compilerOptions": {
"target": "es6",
"allowJs": true,
"module": "commonjs",
"lib": [
"dom",
"es6",
"es2017",
"esnext.asynciterable"
],
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": "."
},
"include": [
"src/**/*.tsx",
"src/**/*.ts",
"src/**/*.js",
]
} |
Hi, Same issue with mikro-orm and type-graphql annotations |
Having similar issues with decorators. The change seems to be between class Foo {
@test('value') readonly att: string = '';
} The decorator With class Foo {
constructor() {
this.att = '';
}
} but with class Foo {
att = '';
} The way the decorators are generated didn't change in the output. The effect in this case is that the Versions:
Running |
I have identified why things were not working for me. In my tsconfig.json, I use This project uses tsconfig-paths to resolve tsconfig, but that project has an issue which means it could never correctly resolve my tsconfig. It would just silently not load the parent. I have logged an issue about that here: dividab/tsconfig-paths#182 Something seems to have changed with Eventually, I could reference the base config like so |
Im trying to build a node typescript app, but it fails with the bellow output.
Seems like it fails in typeorm decorator.
running ncc as:
ncc build -w src/index.ts -o ./build
The text was updated successfully, but these errors were encountered: