diff --git a/src/@types/package.json.d.ts b/src/@types/package.json.d.ts new file mode 100644 index 0000000000..7cf07c1abc --- /dev/null +++ b/src/@types/package.json.d.ts @@ -0,0 +1,3 @@ +declare module '*/package.json' { + const version: string; +} diff --git a/src/config/load.ts b/src/config/load.ts index 4e9a72edd7..ba8b4af3ce 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -7,7 +7,7 @@ import { URL } from 'url'; import * as yaml from 'js-yaml'; import { Source, Mixin } from './types'; import isUrl = require('is-url'); -const pkg = require('../../package.json'); +import * as pkg from '../../package.json'; /** * Path of configuration directory diff --git a/src/index.ts b/src/index.ts index b61283b4e9..13510c9b49 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,7 @@ import notesStats from './daemons/notes-stats'; import loadConfig from './config/load'; import { Config } from './config/types'; import { lessThan } from './prelude/array'; +import * as pkg from '../package.json'; const clusterLog = debug('misskey:cluster'); const ev = new Xev(); @@ -31,8 +32,6 @@ if (process.env.NODE_ENV != 'production' && process.env.DEBUG == null) { debug.enable('misskey'); } -const pkg = require('../package.json'); - //#region Command line argument definitions program .version(pkg.version) diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 3b2a49dbb0..6aed1b2298 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -4,8 +4,8 @@ import config from '../../../config'; import Emoji from '../../../models/emoji'; import define from '../define'; import fetchMeta from '../../../misc/fetch-meta'; +import * as pkg from '../../../../package.json'; -const pkg = require('../../../../package.json'); const client = require('../../../../built/client/meta.json'); export const meta = { diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 69f3b8859f..afb05923cd 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -20,7 +20,7 @@ import Note, { pack as packNote } from '../../models/note'; import getNoteSummary from '../../misc/get-note-summary'; import fetchMeta from '../../misc/fetch-meta'; import Emoji from '../../models/emoji'; -const pkg = require('../../../package.json'); +import * as pkg from '../../../package.json'; const client = `${__dirname}/../../client/`; diff --git a/tsconfig.json b/tsconfig.json index ff4eaf917a..0cfd63c691 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,8 @@ "noLib": false, "strict": true, "strictNullChecks": false, - "experimentalDecorators": true + "experimentalDecorators": true, + "resolveJsonModule": true }, "compileOnSave": false, "include": [