Add ESModule support

This commit is contained in:
Fabian Stamm 2020-08-26 11:55:57 +02:00
parent f34800d725
commit b92caf6468
9 changed files with 251 additions and 236 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@ node_modules/
logs/
yarn.lock
out/
.history/
esm/

410
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{
"name": "@hibas123/logging",
"version": "2.4.5",
"version": "2.5.4",
"description": "",
"main": "out/index.js",
"types": "out/index.d.ts",
"module": "esm/index.js",
"scripts": {
"prepublish": "tsc",
"build": "tsc",
"prepublish": "npm run build",
"build": "tsc && tsc -p tsconfig.esm.json",
"dev": "nodemon -e ts --exec ts-node src/test.ts"
},
"repository": {
@ -18,16 +19,17 @@
"files": [
"src/",
"out/",
"esm/",
"tsconfig.json",
"readme.md"
],
"devDependencies": {
"concurrently": "^5.1.0",
"nodemon": "^2.0.3",
"ts-node": "^8.8.2",
"typescript": "^3.8.3"
"concurrently": "^5.3.0",
"nodemon": "^2.0.4",
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
},
"dependencies": {
"@hibas123/utils": "^2.2.4"
"@hibas123/utils": "^2.2.10"
}
}

View File

@ -1,6 +1,6 @@
import { Observable, ObservableInterface } from "@hibas123/utils";
import { ConsoleAdapter } from "./consolewriter";
import inspect from "./inspect";
import { ConsoleAdapter } from "./consolewriter.js";
import inspect from "./inspect.js";
import {
Adapter,
LoggingTypes,
@ -12,7 +12,7 @@ import {
Colors,
FormattedText,
FormattedLine,
} from "./types";
} from "./types.js";
const browser = typeof window !== "undefined";

View File

@ -1,14 +1,16 @@
import { ObservableInterface } from "@hibas123/utils";
import { Colors } from "./index";
import { Colors } from "./index.js";
import {
Adapter,
Message,
FormattedLine,
TerminalFormats,
FormatTypes,
} from "./types";
} from "./types.js";
const browser = typeof window !== "undefined";
declare const Deno: any;
const browser = typeof window !== "undefined" && typeof Deno === "undefined";
export class ConsoleAdapter implements Adapter {
constructor(private colors: boolean = true) {}

View File

@ -1,11 +1,11 @@
import { LoggingBase } from "./base";
export { ConsoleAdapter } from "./consolewriter";
import { LoggingBase } from "./base.js";
export { ConsoleAdapter } from "./consolewriter.js";
export {
LoggingBase,
LoggingBaseOptions,
removeColors,
withColor,
} from "./base";
} from "./base.js";
export {
Adapter,
LoggingTypes,
@ -18,7 +18,7 @@ export {
Format,
FormatTypes,
TerminalFormats,
} from "./types";
} from "./types.js";
export { ObservableInterface } from "@hibas123/utils";

View File

@ -1,4 +1,10 @@
import { Logging, LoggingBase, LoggingTypes, Colors, withColor } from ".";
import {
Logging,
LoggingBase,
LoggingTypes,
Colors,
withColor,
} from "./index.js";
Logging.log("test");
Logging.log("i", "am", { a: "an" }, 1000);

11
tsconfig.esm.json Normal file
View File

@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"target": "ES2017",
"moduleResolution": "node",
"outDir": "esm"
},
"exclude": ["node_modules"],
"include": ["src"]
}

View File

@ -1,19 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"target": "esnext",
"noImplicitAny": false,
"sourceMap": true,
"outDir": "out",
"declaration": true,
"typeRoots": [
"node_modules/@types"
]
"typeRoots": ["node_modules/@types"]
},
"exclude": [
"node_modules"
],
"include": [
"src"
]
}
"exclude": ["node_modules"],
"include": ["src"]
}