bugfix: fix tsc error of dist lib (#24)

diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index f210af9..9d48727 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -24,7 +24,7 @@
       - master
 
 jobs:
-  Build:
+  TestPlugins:
     runs-on: ubuntu-18.04
     timeout-minutes: 30
     strategy:
@@ -54,3 +54,16 @@
           npm i
           npm run lint
           npm run test
+
+  TestLib:
+    runs-on: ubuntu-18.04
+    timeout-minutes: 30
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: true
+
+      - name: Test Dist Lib
+        run: |
+          docker build . -f tests/build/Dockerfile -t skywalking-nodejs:${{ github.sha }}
+          docker run --rm skywalking-nodejs:${{ github.sha }}
diff --git a/package.json b/package.json
index 4409c2b..f6c9d31 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
   "scripts": {
     "prepare": "npm run generate-source",
     "generate-source": "scripts/protoc.sh",
-    "build": "tsc --build src",
+    "build": "npm run clean && npm run prepare && tsc --build src && OUT_DIR=lib/proto/ scripts/protoc.sh",
     "lint": "tslint -p src/tsconfig.json src/**/*.ts",
     "test": "DEBUG=testcontainers* jest",
     "format": "prettier --write \"src/**/*.ts\"",
diff --git a/scripts/protoc.sh b/scripts/protoc.sh
index 8e7679d..992d6c6 100755
--- a/scripts/protoc.sh
+++ b/scripts/protoc.sh
@@ -16,24 +16,25 @@
 # limitations under the License.
 #
 
-ROOT_DIR="$(dirname "$0")"/..
+ROOT_DIR=$(cd "$(dirname "$0")"/..; pwd)
+OUT_DIR="$ROOT_DIR"/${OUT_DIR:-src/proto/}
 
-(rm -rf src/proto || true) && (mkdir -p src/proto || true) && (rm -rf src/proto || true) && (mkdir -p src/proto || true)
+mkdir -p $OUT_DIR || true
 
 cd "${ROOT_DIR}"/protocol || exit
 
-PROTOC_GEN_TS_PATH="../${ROOT_DIR}/node_modules/.bin/protoc-gen-ts"
-PROTOC_PLUGIN="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc_plugin"
-PROTOC="../${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc"
+PROTOC_GEN_TS_PATH="${ROOT_DIR}/node_modules/.bin/protoc-gen-ts"
+PROTOC_PLUGIN="${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc_plugin"
+PROTOC="${ROOT_DIR}/node_modules/.bin/grpc_tools_node_protoc"
 
 ${PROTOC} \
-    --js_out=import_style=commonjs,binary:../src/proto/ \
-    --grpc_out=../src/proto/ \
+    --js_out=import_style=commonjs,binary:$OUT_DIR \
+    --grpc_out=$OUT_DIR \
     --plugin=protoc-gen-grpc="${PROTOC_PLUGIN}" \
       **/*.proto
 
 ${PROTOC} \
     --plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \
-    --ts_out=../src/proto/ \
+    --ts_out=$OUT_DIR \
       **/*.proto
 
diff --git a/src/trace/context/CarrierItem.ts b/src/trace/context/CarrierItem.ts
index 99b2fa2..b26ae5a 100644
--- a/src/trace/context/CarrierItem.ts
+++ b/src/trace/context/CarrierItem.ts
@@ -17,8 +17,9 @@
  *
  */
 
-export class CarrierItem {
-  value!: string;
+export abstract class CarrierItem {
+  abstract get value(): string;
+  abstract set value(val: string);
 
-  constructor(public key: string) {}
+  protected constructor(public key: string) {}
 }
diff --git a/tests/build/Dockerfile b/tests/build/Dockerfile
new file mode 100644
index 0000000..7c0722f
--- /dev/null
+++ b/tests/build/Dockerfile
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM node:12
+
+WORKDIR /app
+
+ADD . /app
+
+RUN npm install request && npm install && npm run build
+
+ADD tests/build/main.ts /test/main.ts
+ADD tests/build/package.json /test/package.json
+
+WORKDIR /test
+
+RUN npm install && npm install /app && npm run build
diff --git a/tests/build/main.ts b/tests/build/main.ts
new file mode 100644
index 0000000..af97cc8
--- /dev/null
+++ b/tests/build/main.ts
@@ -0,0 +1,25 @@
+/*!
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import agent from 'skywalking-backend-js';
+
+agent.start({
+  serviceName: 'server',
+  maxBufferSize: 1000,
+});
diff --git a/tests/build/package.json b/tests/build/package.json
new file mode 100644
index 0000000..e11b67f
--- /dev/null
+++ b/tests/build/package.json
@@ -0,0 +1,16 @@
+{
+  "name": "test",
+  "version": "1.0.0",
+  "scripts": {
+    "build": "tsc main.ts"
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "tslib": "^2.1.0"
+  },
+  "devDependencies": {
+    "@types/node": "^14.14.21",
+    "typescript": "^4.1.3"
+  }
+}
diff --git a/tests/build/tsconfig.json b/tests/build/tsconfig.json
new file mode 100644
index 0000000..0a402e8
--- /dev/null
+++ b/tests/build/tsconfig.json
@@ -0,0 +1,14 @@
+{
+  "compilerOptions": {
+    "module": "commonjs",
+    "rootDir": ".",
+    "baseUrl": ".",
+    "outDir": ".",
+    "resolveJsonModule": true,
+    "composite": true,
+    "esModuleInterop": true
+  },
+  "files": [
+    "package.json"
+  ]
+}