webpack gateway, ingame 분리
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
|||||||
|
type ErrType<T> = { new(msg?: string): T }
|
||||||
|
type Nullable<T> = T | null | undefined
|
||||||
|
|
||||||
|
export class RuntimeError extends Error {
|
||||||
|
public name = 'RuntimeError';
|
||||||
|
constructor(public message: string = '') {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
toString(): string {
|
||||||
|
if (this.message) {
|
||||||
|
return this.name + ': ' + this.message;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NotNullExpected extends RuntimeError {
|
||||||
|
public name = 'NotNullExpected';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unwrap<T>(result: Nullable<T>): T {
|
||||||
|
if (result === null || result === undefined) {
|
||||||
|
throw new NotNullExpected();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unwrap_err<T, ErrT extends Error>(result: Nullable<T>, errType: ErrType<ErrT>, errMsg?: string): T {
|
||||||
|
if (result === null || result === undefined) {
|
||||||
|
throw new errType(errMsg);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
+34
-1
@@ -1,6 +1,8 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = [
|
||||||
|
{
|
||||||
|
name: 'ingame',
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".tsx"]
|
extensions: [".ts", ".tsx"]
|
||||||
},
|
},
|
||||||
@@ -28,4 +30,35 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'gateway',
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".tsx"]
|
||||||
|
},
|
||||||
|
entry: {
|
||||||
|
//test: './ts/test.ts',
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
path: path.resolve(__dirname, 'js'),
|
||||||
|
},
|
||||||
|
mode: 'none',
|
||||||
|
devtool: 'source-map',
|
||||||
|
module: {
|
||||||
|
rules: [{
|
||||||
|
test: /\.(ts|tsx)$/,
|
||||||
|
exclude: /(node_modules)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: [
|
||||||
|
'@babel/preset-env',
|
||||||
|
'@babel/preset-typescript'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user