Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update TS types files for better TS support #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 190 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@logdna/browser",
"version": "1.1.0",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"license": "MIT",
"types": "./dist/types/index.d.ts",
"scripts": {
"build": "rollup -c rollup.config.ts",
"clean": "rm -rf dist",
"build": "npm run clean && rollup -c rollup.config.ts",
"start": "rollup -c rollup.config.ts -w",
"test": "jest",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -41,7 +42,7 @@
},
"homepage": "https://github.com/logdna/logdna-browser#readme",
"devDependencies": {
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.4",
Expand All @@ -56,7 +57,9 @@
"prettier": "^1.14.3",
"pretty-quick": "^3.1.0",
"rollup": "^2.33.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"semantic-release": "^17.4.2",
"semantic-release-config-logdna": "^1.1.1",
"serve": "^11.3.2",
Expand Down Expand Up @@ -84,4 +87,4 @@
],
"extends": "semantic-release-config-logdna"
}
}
}
35 changes: 28 additions & 7 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
import replace from '@rollup/plugin-replace';
import copy from 'rollup-plugin-copy';

export default {
input: `src/index.ts`,
output: {
dir: 'dist',
const OUTPUT_DATA = [
{
input: 'src/index.ts',
file: 'dist/index.esm.js',
format: 'es',
},
{
input: 'src/index-umd.ts',
file: 'dist/index.js',
format: 'umd',
},
];

const config = OUTPUT_DATA.map(({ file, format, input }) => ({
input,
output: {
file,
format,
sourcemap: true,
name: 'logdna',
},
Expand All @@ -19,7 +33,9 @@ export default {
},
plugins: [
json(),
typescript(),
typescript({
useTsconfigDeclarationDir: true,
}),
commonjs(),
resolve(),
replace({
Expand All @@ -32,5 +48,10 @@ export default {
comments: false,
},
}),
copy({
targets: [{ src: 'src/logdna.d.ts', dest: 'dist/types' }],
}),
],
};
}));

export default config;
4 changes: 4 additions & 0 deletions src/index-umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//For umd build only
import LogDNABrowserLogger from './index';

export default LogDNABrowserLogger;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
StaticContext,
ILogDNABrowserLogger,
Plugin,
} from './index.d';
} from './logdna.d';
import utils from './utils';
import {
DEFAULT_INGESTION_URL,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoggerOptionsT, LogDNALogLine } from './index.d';
import { LoggerOptionsT, LogDNALogLine } from './logdna.d';
import {
LOG_LINE_FLUSH_TIMEOUT,
FLUSH_BYTE_LIMIT,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, ILogDNABrowserLogger } from '../index.d';
import { Plugin, ILogDNABrowserLogger } from '../logdna.d';

type LogType = 'log' | 'debug' | 'error' | 'warn' | 'info' | 'assert';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/global-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, ILogDNABrowserLogger } from '../index.d';
import { Plugin, ILogDNABrowserLogger } from '../logdna.d';

export type Options = {
enableErrorHandler?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/performance-measure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, ILogDNABrowserLogger, LogType } from '../index.d';
import { Plugin, ILogDNABrowserLogger, LogType } from '../logdna.d';
export type Options = {
prefix?: String;
logLevel?: LogType;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import safeStringify from 'fast-safe-stringify';
import { ContextT, LogDNABrowserOptionsT } from './index.d';
import { ContextT, LogDNABrowserOptionsT } from './logdna.d';
import { HOSTNAME_CHECK } from './constants';
import { version } from '../package.json';

Expand Down