Skip to content

Commit

Permalink
fix esm build
Browse files Browse the repository at this point in the history
  • Loading branch information
bguerout committed Jan 5, 2025
1 parent f19c8b2 commit 7175a9d
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 68 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
"error", {
"allowModules": ["slow-stream"]
}
],
"node/no-missing-import": [
"error", {
"tryExtensions": [".js", ".ts"]
}
]
}
}
5 changes: 4 additions & 1 deletion .tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cd "${PROJECT_DIR}"

echo "Compiling oleoduc (esm version)..."
npm run tsc -- -p tsconfig.json
cat >"${DIST_DIR}/mjs/package.json" <<!EOF
cat >"${DIST_DIR}/esm/package.json" <<!EOF
{
"type": "module"
}
Expand All @@ -26,6 +26,9 @@ cat >"${DIST_DIR}/cjs/package.json" <<!EOF
}
!EOF

echo "Compiling oleoduc (types)..."
npm run tsc -- -p tsconfig.types.json

echo "Building oleoduc for test..."
npm run tsc -- -p tsconfig.test.json
echo "Patching package.json to be able to run tests against previous versions of nodejs..."
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
}
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/accumulateData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Transform, TransformOptions} from "stream";
import {Transform, TransformOptions} from "node:stream";

export type AccumulateDataOptions<TAcc> = TransformOptions & {accumulator?: TAcc};
export type AccumulateDataCallback<TInput, TOutput, TAcc> = (
Expand Down
14 changes: 7 additions & 7 deletions src/compose.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {parseArgs} from "./utils/parseArgs";
import {wrapStreams} from "./utils/wrapStreams";
import {isReadableStream} from "./utils/isReadableStream";
import {decorateWithAsyncIterator} from "./utils/decorateWithAsyncIterator";
import {pipeStreamsTogether} from "./utils/pipeStreamsTogether";
import {AnyStream, PipeableStreams} from "./types";
import {Readable, TransformOptions} from "stream";
import {Readable, TransformOptions} from "node:stream";
import {parseArgs} from "./utils/parseArgs.ts";
import {wrapStreams} from "./utils/wrapStreams.ts";
import {isReadableStream} from "./utils/isReadableStream.ts";
import {decorateWithAsyncIterator} from "./utils/decorateWithAsyncIterator.ts";
import {pipeStreamsTogether} from "./utils/pipeStreamsTogether.ts";
import {AnyStream, PipeableStreams} from "./types.ts";

export type ComposeOptions = TransformOptions;

Expand Down
4 changes: 2 additions & 2 deletions src/concatStreams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {PassThrough, TransformOptions} from "stream";
import {parseArgs} from "./utils/parseArgs";
import {PassThrough, TransformOptions} from "node:stream";
import {parseArgs} from "./utils/parseArgs.ts";

type NextStreamCallback = () => Promise<NodeJS.ReadableStream | null> | NodeJS.ReadableStream | null;

Expand Down
2 changes: 1 addition & 1 deletion src/filterData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {TransformDataCallback, transformData, TransformDataOptions} from "./transformData";
import {Transform} from "node:stream";
import {TransformDataCallback, transformData, TransformDataOptions} from "./transformData.ts";

export function filterData<TInput>(
filter: TransformDataCallback<TInput, boolean | null>,
Expand Down
2 changes: 1 addition & 1 deletion src/flattenArray.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Transform, TransformCallback, TransformOptions} from "stream";
import {Transform, TransformCallback, TransformOptions} from "node:stream";

/**
* Inspired by https://stackoverflow.com/a/43811543/122975
Expand Down
2 changes: 1 addition & 1 deletion src/groupData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {accumulateData, AccumulateDataOptions} from "./accumulateData";
import {accumulateData, AccumulateDataOptions} from "./accumulateData.ts";

export type GroupDataOptions<TInput> = {size?: number} & AccumulateDataOptions<Array<TInput>>;

Expand Down
30 changes: 15 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {accumulateData} from "./accumulateData";
import {compose} from "./compose";
import {concatStreams} from "./concatStreams";
import {filterData} from "./filterData";
import {flattenArray} from "./flattenArray";
import {groupData} from "./groupData";
import {mergeStreams} from "./mergeStreams";
import {oleoduc} from "./oleoduc";
import {readLineByLine} from "./readLineByLine";
import {transformData} from "./transformData";
import {transformIntoCSV} from "./transformIntoCSV";
import {transformIntoJSON} from "./transformIntoJSON";
import {transformStream} from "./transformStream";
import {writeData} from "./writeData";
import {writeToStdout} from "./writeToStdout";
import {accumulateData} from "./accumulateData.ts";
import {compose} from "./compose.ts";
import {concatStreams} from "./concatStreams.ts";
import {filterData} from "./filterData.ts";
import {flattenArray} from "./flattenArray.ts";
import {groupData} from "./groupData.ts";
import {mergeStreams} from "./mergeStreams.ts";
import {oleoduc} from "./oleoduc.ts";
import {readLineByLine} from "./readLineByLine.ts";
import {transformData} from "./transformData.ts";
import {transformIntoCSV} from "./transformIntoCSV.ts";
import {transformIntoJSON} from "./transformIntoJSON.ts";
import {transformStream} from "./transformStream.ts";
import {writeData} from "./writeData.ts";
import {writeToStdout} from "./writeToStdout.ts";

export {
accumulateData,
Expand Down
7 changes: 3 additions & 4 deletions src/mergeStreams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {PassThrough, Transform} from "stream";
import {decorateWithAsyncIterator} from "./utils/decorateWithAsyncIterator";
import {parseArgs} from "./utils/parseArgs";
import {StreamOptions} from "node:stream";
import {PassThrough, Transform, StreamOptions} from "node:stream";
import {decorateWithAsyncIterator} from "./utils/decorateWithAsyncIterator.ts";
import {parseArgs} from "./utils/parseArgs.ts";

export function mergeStreams(
...args:
Expand Down
10 changes: 5 additions & 5 deletions src/oleoduc.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {parseArgs} from "./utils/parseArgs";
import {AnyStream, PipeableStreams} from "./types";
import {wrapStreams} from "./utils/wrapStreams";
import {pipeStreamsTogether} from "./utils/pipeStreamsTogether";
import {TransformOptions} from "stream";
import {TransformOptions} from "node:stream";
import {parseArgs} from "./utils/parseArgs.ts";
import {AnyStream, PipeableStreams} from "./types.ts";
import {wrapStreams} from "./utils/wrapStreams.ts";
import {pipeStreamsTogether} from "./utils/pipeStreamsTogether.ts";

export type OleoducOptions = TransformOptions;

Expand Down
6 changes: 3 additions & 3 deletions src/readLineByLine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {accumulateData} from "./accumulateData";
import {flattenArray} from "./flattenArray";
import {compose} from "./compose";
import {accumulateData} from "./accumulateData.ts";
import {flattenArray} from "./flattenArray.ts";
import {compose} from "./compose.ts";

export function readLineByLine() {
return compose(
Expand Down
3 changes: 1 addition & 2 deletions src/transformData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import transform from "parallel-transform";
import {Transform, TransformOptions} from "node:stream";
import {TransformCallback} from "stream";
import {Transform, TransformOptions, TransformCallback} from "node:stream";

export type TransformDataCallback<TInput, TOutput> = (data: TInput) => Promise<TOutput> | TOutput;
export type TransformDataOptions<TInput> = {
Expand Down
2 changes: 1 addition & 1 deletion src/transformIntoCSV.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Transform, TransformOptions} from "stream";
import {Transform, TransformOptions} from "node:stream";

export type TransformIntoCSVOptions<TInput> = TransformOptions & {
columns?: Record<string, (data: TInput) => Promise<AllowedCSVType> | AllowedCSVType>;
Expand Down
2 changes: 1 addition & 1 deletion src/transformIntoJSON.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Transform, TransformOptions} from "stream";
import {Transform, TransformOptions} from "node:stream";

export type TransformIntoJSONOptions = TransformOptions & {
arrayPropertyName?: string;
Expand Down
3 changes: 1 addition & 2 deletions src/transformStream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Transform, TransformCallback} from "stream";
import {TransformOptions} from "node:stream";
import {Transform, TransformOptions, TransformCallback} from "node:stream";

export type TransformStreamCallback<TInput, TOutput extends NodeJS.ReadableStream> = (
data: TInput,
Expand Down
3 changes: 1 addition & 2 deletions src/writeData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Writable} from "stream";
import {WritableOptions, Writable} from "node:stream";
import cyclist, {Cyclist} from "cyclist";
import {WritableOptions} from "node:stream";

export type WriteDataOptions = {parallel?: number};
export type WriteDataCallback<TInput> = (data: TInput) => void | unknown;
Expand Down
2 changes: 1 addition & 1 deletion src/writeToStdout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Writable} from "stream";
import {Writable} from "node:stream";

type WriteToStdoutCallback = (error: Error | null | undefined) => void;

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"outDir": "./dist/cjs",
"target": "es2015",
"typeRoots": ["./node_modules/@types", "./src/@types"]
}
}
16 changes: 6 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
{
"include": ["src"],
"exclude": ["node_modules", "dist"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"lib": ["esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist/mjs",
"module": "ESNext",
"target": "esnext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"allowSyntheticDefaultImports": true,
"outDir": "./dist/esm",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"types": ["node", "mocha"],
},
}
9 changes: 9 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true
}
}

0 comments on commit 7175a9d

Please sign in to comment.