From 90d3a0f16a7ddbbf7c9441a6f93ff8527c21bfbc Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 4 Mar 2019 09:57:29 -0800 Subject: [PATCH] Allow logger package to be publishable (#37) --- packages/logger/.npmignore | 4 ++++ packages/logger/README.md | 6 +++++- packages/logger/package.json | 14 +++++++++++--- packages/logger/tsconfig.build.json | 8 ++++++++ packages/logger/webpack.config.js | 16 ++++++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 packages/logger/.npmignore create mode 100644 packages/logger/tsconfig.build.json create mode 100644 packages/logger/webpack.config.js diff --git a/packages/logger/.npmignore b/packages/logger/.npmignore new file mode 100644 index 00000000..d248c0bf --- /dev/null +++ b/packages/logger/.npmignore @@ -0,0 +1,4 @@ +src +tsconfig.build.json +webpack.config.js +yarn.lock \ No newline at end of file diff --git a/packages/logger/README.md b/packages/logger/README.md index 83d89757..c449d6cb 100644 --- a/packages/logger/README.md +++ b/packages/logger/README.md @@ -1,6 +1,10 @@ # Logger -Beautiful client logging inspired by https://github.com/uber-go/zap. +Beautiful logging inspired by https://github.com/uber-go/zap. + +- Built for node and the browser +- Zero dependencies +- Uses groups in the browser to reduce clutter ## Example Usage diff --git a/packages/logger/package.json b/packages/logger/package.json index 0a4f7411..ad3640eb 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -1,5 +1,13 @@ { - "name": "@coder/logger", - "description": "Beautiful client logging inspired by https://github.com/uber-go/zap.", - "main": "src/index.ts" + "name": "@coder/logger", + "description": "Beautiful logging inspired by https://github.com/uber-go/zap.", + "scripts": { + "build": "tsc -p tsconfig.build.json && cp ./out/packages/logger/src/* ./out && rm -rf out/packages && ../../node_modules/.bin/webpack --config ./webpack.config.js", + "postinstall": "if [ ! -d out ];then npm run build; fi" + }, + "version": "1.0.3", + "main": "out/main.js", + "types": "out/index.d.ts", + "author": "Coder", + "license": "MIT" } diff --git a/packages/logger/tsconfig.build.json b/packages/logger/tsconfig.build.json new file mode 100644 index 00000000..04a1c4cb --- /dev/null +++ b/packages/logger/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "declarationDir": "out", + "declaration": true, + "emitDeclarationOnly": true + } +} \ No newline at end of file diff --git a/packages/logger/webpack.config.js b/packages/logger/webpack.config.js new file mode 100644 index 00000000..3e84a213 --- /dev/null +++ b/packages/logger/webpack.config.js @@ -0,0 +1,16 @@ +const path = require("path"); +const merge = require("webpack-merge"); + +module.exports = merge(require(path.join(__dirname, "../../scripts", "webpack.general.config.js"))(), { + devtool: "none", + mode: "production", + target: "node", + output: { + path: path.join(__dirname, "out"), + filename: "main.js", + libraryTarget: "commonjs", + }, + entry: [ + "./packages/logger/src/index.ts" + ], +});