Я пытаюсь сначала скомпилировать свое приложение с помощью TypeScript, а затем с помощью Webpack.Мне это нужно, потому что мой сервер должен быть одним файлом js.
Мой проблемный проект можно скачать здесь:
https://s3 -ap-southeast-2.amazonaws.com/test-bucket-alsh/untitled+folder.zip
index.ts
console.log(process)
console.log(process.env)
webpack.config.js
module.exports = {
entry: path.join(__dirname, '/index.ts'),
mode,
node: {
console: true,
global: true,
process: true,
__filename: true,
__dirname: true,
Buffer: true,
setImmediate: true
},
output: {
filename: 'index.js',
path: __dirname
},
module: {
rules: [
{
test: /\.ts$/,
use: ['ts-loader']
}
]
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"baseUrl": "./",
"outDir": "./dist/",
"sourceMap": true,
"esModuleInterop": true,
"lib": [
"es2016"
],
"types": [
"node"
]
},
"exclude": [
"node_modules"
]
}
npx webpack && node index.js
Результаты в
{ nextTick: [Function],
title: 'browser',
browser: true,
env: {},
argv: [],
version: '',
versions: {},
on: [Function: noop],
addListener: [Function: noop],
once: [Function: noop],
off: [Function: noop],
removeListener: [Function: noop],
removeAllListeners: [Function: noop],
emit: [Function: noop],
prependListener: [Function: noop],
prependOnceListener: [Function: noop],
listeners: [Function],
binding: [Function],
cwd: [Function],
chdir: [Function],
umask: [Function] }
{}