Skip to content

Commit

Permalink
fix: support ts node16 resolution in cjs (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Feb 8, 2023
1 parent 83a72bd commit fa09d03
Show file tree
Hide file tree
Showing 33 changed files with 160 additions and 81 deletions.
7 changes: 6 additions & 1 deletion demo/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"start": "node server.js"
},
"dependencies": {
"express": "^4.18.2"
"csv": "^6.2.6",
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"express": "^4.18.2",
"stream-transform": "^3.2.1"
}
}
5 changes: 5 additions & 0 deletions demo/cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"license": "MIT",
"type": "commonjs",
"private": true,
"dependencies": {
"csv": "^6.2.6",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3"
},
"devDependencies": {
"@types/node": "^18.8.4",
"coffeescript": "^2.7.0",
Expand Down
4 changes: 4 additions & 0 deletions demo/issues-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"main": "index.js",
"license": "MIT",
"private": true,
"dependencies": {
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3"
},
"devDependencies": {
"coffeescript": "^2.7.0",
"mocha": "^10.1.0",
Expand Down
3 changes: 3 additions & 0 deletions demo/issues-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"test": "mocha 'test/**/*.coffee'"
},
"dependencies": {
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"desm": "^1.3.0"
}
}
28 changes: 28 additions & 0 deletions demo/ts-cjs-node16/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import assert from 'assert'
import { generate, Generator } from 'csv-generate';
import { parse, Parser } from 'csv-parse';
import { transform, Transformer } from 'stream-transform';
import { stringify, Stringifier } from 'csv-stringify';

let chunks: string[] = [];

// Create the parser
const generator: Generator = generate({length: 2, seed: true});
const parser: Parser = parse();
const transformer: Transformer = transform((record) => record);
const stringifier: Stringifier = stringify();
generator.pipe(parser).pipe(transformer).pipe(stringifier)
.on('data', function(data) {
chunks.push(data.toString())
})
.on('end', () => {
assert.strictEqual(
chunks.join(''),
[
'OMH,ONKCHhJmjadoA,D,GeACHiN,nnmiN,CGfDKB,NIl,JnnmjadnmiNL',
'KB,dmiM,fENL,Jn,opEMIkdmiOMFckep,MIj,bgIjadnn,fENLEOMIkbhLDK',
'',
].join('\n')
)
})
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"name": "csv-demo-ts-moduleresolution-node16-cjs",
"version": "0.2.1",
"dependencies": {
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"stream-transform": "^3.2.1"
},
"main": "index.js",
"license": "MIT",
"private": true,
"devDependencies": {
"typescript": "^4.9.5"
},
"scripts": {
"typecheck": "tsc --noEmit"
"test": "tsc --noEmit"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"license": "MIT",
"type": "module",
"private": true,
"dependencies": {
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"stream-transform": "^3.2.1"
},
"devDependencies": {
"@types/node": "^18.11.9",
"coffeescript": "^2.7.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 0 additions & 32 deletions demo/ts-moduleresolution-node16-cjs/lib/stringify.ts

This file was deleted.

18 changes: 11 additions & 7 deletions demo/webpack-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
"version": "0.1.3",
"description": "",
"private": true,
"scripts": {
"build": "npx webpack --config webpack.config.js",
"start": "http-server ./dist -p 8080",
"test": "npm run build >/dev/null"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"http-server": "^14.1.1",
"stream-transform": "^3.2.1"
},
"devDependencies": {
"buffer-browserify": "^0.2.5",
"node-polyfill-webpack-plugin": "^2.0.1",
Expand All @@ -20,7 +22,9 @@
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"http-server": "^14.1.1"
"scripts": {
"build": "npx webpack --config webpack.config.js",
"start": "http-server ./dist -p 8080",
"test": "npm run build >/dev/null"
}
}
7 changes: 6 additions & 1 deletion demo/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"csv": "^6.2.6",
"csv-generate": "^4.2.1",
"csv-parse": "^5.3.4",
"csv-stringify": "^6.2.3",
"http-server": "^14.1.1",
"stream-browserify": "^3.0.0"
"stream-browserify": "^3.0.0",
"stream-transform": "^3.2.1"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 27 additions & 12 deletions packages/csv-generate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,41 @@
},
"exports": {
".": {
"import": "./lib/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./lib/index.d.ts"
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./sync": {
"import": "./lib/sync.js",
"require": "./dist/cjs/sync.cjs",
"types": "./lib/sync.d.ts"
"import": {
"types": "./lib/sync.d.ts",
"default": "./lib/sync.js"
},
"require": {
"types": "./dist/cjs/sync.d.cts",
"default": "./dist/cjs/sync.cjs"
}
},
"./stream": {
"import": "./lib/stream.js",
"require": "./dist/cjs/stream.cjs",
"types": "./lib/stream.d.ts"
"import": {
"types": "./lib/stream.d.ts",
"default": "./lib/stream.js"
},
"require": {
"types": "./dist/cjs/stream.d.cts",
"default": "./dist/cjs/stream.cjs"
}
},
"./browser/esm": {
"types": "./lib/index.d.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"./browser/esm/sync": {
"types": "./lib/sync.d.ts",
"types": "./dist/esm/sync.d.ts",
"default": "./dist/esm/sync.js"
}
},
Expand Down Expand Up @@ -78,7 +93,7 @@
"scripts": {
"build": "npm run build:rollup && npm run build:ts",
"build:rollup": "npx rollup -c",
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/stream.d.ts dist/cjs/stream.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
"lint:lib": "eslint --fix lib/*.js",
"lint:samples": "eslint --fix samples/*.js",
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 19 additions & 9 deletions packages/csv-parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,31 @@
],
"exports": {
".": {
"import": "./lib/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./lib/index.d.ts"
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./sync": {
"import": "./lib/sync.js",
"require": "./dist/cjs/sync.cjs",
"types": "./lib/sync.d.ts"
"import": {
"types": "./lib/sync.d.ts",
"default": "./lib/sync.js"
},
"require": {
"types": "./dist/cjs/sync.d.cts",
"default": "./dist/cjs/sync.cjs"
}
},
"./browser/esm": {
"types": "./lib/index.d.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"./browser/esm/sync": {
"types": "./lib/sync.d.ts",
"types": "./dist/esm/sync.d.ts",
"default": "./dist/esm/sync.js"
}
},
Expand Down Expand Up @@ -96,7 +106,7 @@
"scripts": {
"build": "npm run build:rollup && npm run build:ts",
"build:rollup": "npx rollup -c",
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
"lint:lib": "eslint --fix lib/*.js",
"lint:samples": "eslint --fix samples/*.js",
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 19 additions & 9 deletions packages/csv-stringify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,31 @@
},
"exports": {
".": {
"import": "./lib/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./lib/index.d.ts"
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./sync": {
"import": "./lib/sync.js",
"require": "./dist/cjs/sync.cjs",
"types": "./lib/sync.d.ts"
"import": {
"types": "./lib/sync.d.ts",
"default": "./lib/sync.js"
},
"require": {
"types": "./dist/cjs/sync.d.cts",
"default": "./dist/cjs/sync.cjs"
}
},
"./browser/esm": {
"types": "./lib/index.d.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"./browser/esm/sync": {
"types": "./lib/sync.d.ts",
"types": "./dist/esm/sync.d.ts",
"default": "./dist/esm/sync.js"
}
},
Expand Down Expand Up @@ -73,7 +83,7 @@
"scripts": {
"build": "npm run build:rollup && npm run build:ts",
"build:rollup": "npx rollup -c",
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
"lint:lib": "eslint --fix lib/*.js",
"lint:samples": "eslint --fix samples/*.js",
Expand Down
28 changes: 19 additions & 9 deletions packages/stream-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,31 @@
},
"exports": {
".": {
"import": "./lib/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./lib/index.d.ts"
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
},
"./sync": {
"import": "./lib/sync.js",
"require": "./dist/cjs/sync.cjs",
"types": "./lib/sync.d.ts"
"import": {
"types": "./lib/sync.d.ts",
"default": "./lib/sync.js"
},
"require": {
"types": "./dist/cjs/sync.d.cts",
"default": "./dist/cjs/sync.cjs"
}
},
"./browser/esm": {
"types": "./lib/index.d.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"./browser/esm/sync": {
"types": "./lib/sync.d.ts",
"types": "./dist/esm/sync.d.ts",
"default": "./dist/esm/sync.js"
}
},
Expand Down Expand Up @@ -73,7 +83,7 @@
"scripts": {
"build": "npm run build:rollup && npm run build:ts",
"build:rollup": "npx rollup -c",
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
"build:ts": "cp lib/index.d.ts dist/cjs/index.d.cts && cp lib/sync.d.ts dist/cjs/sync.d.cts && cp lib/*.ts dist/esm",
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
"lint:lib": "eslint --fix lib/*.js",
"lint:samples": "eslint --fix samples/*.js",
Expand Down

0 comments on commit fa09d03

Please sign in to comment.