Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
terehov committed Nov 16, 2022
1 parent a084790 commit c666b4b
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 25 deletions.
60 changes: 48 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,51 @@ Donations help me allocate more time for my open source work.

## Install

> **`tslog` is a native ES module.**
```bash
npm install tslog
```

**Enable TypeScript source map support:**
In order to run a native ES module in Node.js, you have to do two things:

This feature enables `tslog` to reference a correct line number in your TypeScript source code.
1) Set `"type": "module` in `package.json`.
2) Start with `--experimental-specifier-resolution=node`

```json5
// tsconfig.json
Example `package.json`
```json
{
// ...
compilerOptions: {
// ...
sourceMap: true,
// we recommend using a current ES version
target: "es2020",
"name": "bot",
"version": "1.0.0",
"main": "dist/app.js",
"type": "module", // <-- here
"scripts": {
"build": "tsc -p .",
"start": "node --enable-source-maps --experimental-specifier-resolution=node index.js" // <-- and here
},
"dependencies": {
"tslog": "^4"
},
"devDependencies": {
"typescript": "^4.8.4"
},
"engines": {
"node": ">=16"
}
}
```

And run with:
With this `package.json` you can simply build and run it:
```bash
npm run build
npm start
```

**Otherwise:**

Node.js with JavaScript:
```bash
node --enable-source-maps
node --enable-source-maps --experimental-specifier-resolution=node
```

Node.js with TypeScript and `ts-node` (with ESM support):
Expand Down Expand Up @@ -103,6 +122,23 @@ Browser:
</html>
```

**Enable TypeScript source map support:**

This feature enables `tslog` to reference a correct line number in your TypeScript source code.

```json5
// tsconfig.json
{
// ...
compilerOptions: {
// ...
"inlineSourceMap": true, // <!-- here
// we recommend using a current ES version
target: "es2020",
},
}
```

## Simple example

```typescript
Expand Down
60 changes: 48 additions & 12 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,51 @@ Donations help me allocate more time for my open source work.

## Install

> **`tslog` is a native ES module.**
```bash
npm install tslog
```

**Enable TypeScript source map support:**
In order to run a native ES module in Node.js, you have to do two things:

This feature enables `tslog` to reference a correct line number in your TypeScript source code.
1) Set `"type": "module` in `package.json`.
2) Start with `--experimental-specifier-resolution=node`

```json5
// tsconfig.json
Example `package.json`
```json
{
// ...
compilerOptions: {
// ...
sourceMap: true,
// we recommend using a current ES version
target: "es2020",
"name": "bot",
"version": "1.0.0",
"main": "dist/app.js",
"type": "module", // <-- here
"scripts": {
"build": "tsc -p .",
"start": "node --enable-source-maps --experimental-specifier-resolution=node index.js" // <-- and here
},
"dependencies": {
"tslog": "^4"
},
"devDependencies": {
"typescript": "^4.8.4"
},
"engines": {
"node": ">=16"
}
}
```

And run with:
With this `package.json` you can simply build and run it:
```bash
npm run build
npm start
```

**Otherwise:**

Node.js with JavaScript:
```bash
node --enable-source-maps
node --enable-source-maps --experimental-specifier-resolution=node
```

Node.js with TypeScript and `ts-node` (with ESM support):
Expand Down Expand Up @@ -103,6 +122,23 @@ Browser:
</html>
```

**Enable TypeScript source map support:**

This feature enables `tslog` to reference a correct line number in your TypeScript source code.

```json5
// tsconfig.json
{
// ...
compilerOptions: {
// ...
"inlineSourceMap": true, // <!-- here
// we recommend using a current ES version
target: "es2020",
},
}
```

## Simple example

```typescript
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"moduleResolution": "Node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"inlineSourceMap": true,
"strict": true,
"skipLibCheck": true,
"suppressImplicitAnyIndexErrors": true,
Expand Down

0 comments on commit c666b4b

Please sign in to comment.