diff --git a/.gitignore b/.gitignore index ce7e2e2eb5..644f0a2e30 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ node_modules # Build output dist lib +dist-* # Coverage directory coverage diff --git a/packages/logger/package.json b/packages/logger/package.json index 84478e69b9..5a2f5b8666 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -18,7 +18,10 @@ "test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --watch --group=unit", - "build": "tsc", + "build": "npm run build:cjs && npm run build:esm && npm run build:types", + "build:cjs": "tsc -p tsconfig.json", + "build:esm": "tsc -p tsconfig.es.json", + "build:types": "tsc -p tsconfig.types.json", "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", @@ -28,8 +31,10 @@ }, "homepage": "https://github.com/awslabs/aws-lambda-powertools-typescript/tree/master/packages/logging#readme", "license": "MIT", - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "type": "module", + "main": "./lib/cjs/index.js", + "module": "./lib/es/index.js", + "types": "./lib/types/index.d.ts", "typedocMain": "src/index.ts", "devDependencies": { "@types/lodash.clonedeep": "^4.5.7", @@ -60,5 +65,12 @@ "logging", "serverless", "nodejs" - ] + ], + "exports": { + ".": { + "types": "./lib/types/index.d.js", + "import": "./lib/es/index.js", + "require": "./lib/cjs/index.js" + } + } } diff --git a/packages/logger/tsconfig-dev.json b/packages/logger/tsconfig-dev.json index 7c6046c8bc..7b6e7f7f1a 100644 --- a/packages/logger/tsconfig-dev.json +++ b/packages/logger/tsconfig-dev.json @@ -1,30 +1,5 @@ { - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2019", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2019" ], - "types": [ - "jest", - "node" - ] + "extends": "./tsconfig", + "compilerOptions": {}, + "include": ["src/**/*", "examples/**/*", "**/tests/**/*"] } \ No newline at end of file diff --git a/packages/logger/tsconfig.es.json b/packages/logger/tsconfig.es.json index 7c6046c8bc..07c329fd01 100644 --- a/packages/logger/tsconfig.es.json +++ b/packages/logger/tsconfig.es.json @@ -1,30 +1,8 @@ { - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2019", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2019" ], - "types": [ - "jest", - "node" - ] + "extends": "./tsconfig", + "compilerOptions": { + "target": "es5", + "module": "esnext", + "outDir": "lib/es" + } } \ No newline at end of file diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index 3d7d8b8b05..5d5fe6008c 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -1,19 +1,19 @@ { "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2019", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "experimentalDecorators": true, + "noImplicitAny": true, + "target": "ES2019", + "module": "commonjs", + "declaration": false, + "outDir": "lib/cjs", + "strict": true, + "inlineSourceMap": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "pretty": true, + "baseUrl": "src/", + "rootDirs": ["src/"], + "esModuleInterop": true }, "include": [ "src/**/*" ], "exclude": [ "./node_modules"], diff --git a/packages/logger/tsconfig.types.json b/packages/logger/tsconfig.types.json new file mode 100644 index 0000000000..59a3f72e55 --- /dev/null +++ b/packages/logger/tsconfig.types.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "removeComments": false, + "declaration": true, + "declarationDir": "lib/types", + "emitDeclarationOnly": true + }, + "exclude": ["test/**/*", "dist-types/**/*"] +} \ No newline at end of file