From ba13f063ed084f86649bd8f3979dde1869de9528 Mon Sep 17 00:00:00 2001 From: Coleman Rollins Date: Mon, 25 Nov 2024 10:31:35 -0800 Subject: [PATCH] [cr] adjust build commands/exports for packaging --- README.md | 4 ++++ package.json | 3 ++- src/index.js | 9 +++++++++ src/index.ts | 5 ----- tsconfig.json | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 src/index.js delete mode 100644 src/index.ts diff --git a/README.md b/README.md index 28d3c0d..b39d104 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ The library in this directory is an effort to reduce the potential toil involved ## Examples +```ts +import { promql, Expression } from 'tsqtsq'; +``` + `sum` ```ts diff --git a/package.json b/package.json index 1c047b1..f63d05a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "description": "A reusable and composable query library for Prometheus", "keywords": ["prometheus", "promql", "typescript", "query", "javascript"], "author": "Grafana Labs", + "types": "dist/index.d.ts", "repository": { "type": "git", "url": "https://github.com/grafana/tsqtsq" @@ -20,6 +21,6 @@ "scripts": { "test": "jest", "test:watch": "jest --watch", - "build": "esbuild src/index.ts --bundle --outfile=dist/index.js " + "build": "esbuild src/index.js --bundle --platform=node --outfile=dist/index.js " } } diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0a23645 --- /dev/null +++ b/src/index.js @@ -0,0 +1,9 @@ +import { promql } from './promql'; +import { Expression } from './expression'; +import { MatchingOperator } from './types'; + +module.exports = { + promql, + Expression, + MatchingOperator, +}; diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 57f3763..0000000 --- a/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { promql } from './promql'; - -export default promql; - -export * from './types'; diff --git a/tsconfig.json b/tsconfig.json index 8bb6097..0867199 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -49,7 +49,7 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */