Skip to content

Commit fa09d03

Browse files
committed
fix: support ts node16 resolution in cjs (#354)
1 parent 83a72bd commit fa09d03

File tree

33 files changed

+160
-81
lines changed

33 files changed

+160
-81
lines changed

demo/browser/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"start": "node server.js"
2121
},
2222
"dependencies": {
23-
"express": "^4.18.2"
23+
"csv": "^6.2.6",
24+
"csv-generate": "^4.2.1",
25+
"csv-parse": "^5.3.4",
26+
"csv-stringify": "^6.2.3",
27+
"express": "^4.18.2",
28+
"stream-transform": "^3.2.1"
2429
}
2530
}

demo/cjs/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"license": "MIT",
66
"type": "commonjs",
77
"private": true,
8+
"dependencies": {
9+
"csv": "^6.2.6",
10+
"csv-parse": "^5.3.4",
11+
"csv-stringify": "^6.2.3"
12+
},
813
"devDependencies": {
914
"@types/node": "^18.8.4",
1015
"coffeescript": "^2.7.0",

demo/issues-cjs/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"main": "index.js",
55
"license": "MIT",
66
"private": true,
7+
"dependencies": {
8+
"csv-parse": "^5.3.4",
9+
"csv-stringify": "^6.2.3"
10+
},
711
"devDependencies": {
812
"coffeescript": "^2.7.0",
913
"mocha": "^10.1.0",

demo/issues-esm/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"test": "mocha 'test/**/*.coffee'"
2727
},
2828
"dependencies": {
29+
"csv-generate": "^4.2.1",
30+
"csv-parse": "^5.3.4",
31+
"csv-stringify": "^6.2.3",
2932
"desm": "^1.3.0"
3033
}
3134
}

demo/ts-cjs-node16/lib/index.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
import assert from 'assert'
3+
import { generate, Generator } from 'csv-generate';
4+
import { parse, Parser } from 'csv-parse';
5+
import { transform, Transformer } from 'stream-transform';
6+
import { stringify, Stringifier } from 'csv-stringify';
7+
8+
let chunks: string[] = [];
9+
10+
// Create the parser
11+
const generator: Generator = generate({length: 2, seed: true});
12+
const parser: Parser = parse();
13+
const transformer: Transformer = transform((record) => record);
14+
const stringifier: Stringifier = stringify();
15+
generator.pipe(parser).pipe(transformer).pipe(stringifier)
16+
.on('data', function(data) {
17+
chunks.push(data.toString())
18+
})
19+
.on('end', () => {
20+
assert.strictEqual(
21+
chunks.join(''),
22+
[
23+
'OMH,ONKCHhJmjadoA,D,GeACHiN,nnmiN,CGfDKB,NIl,JnnmjadnmiNL',
24+
'KB,dmiM,fENL,Jn,opEMIkdmiOMFckep,MIj,bgIjadnn,fENLEOMIkbhLDK',
25+
'',
26+
].join('\n')
27+
)
28+
})
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
22
"name": "csv-demo-ts-moduleresolution-node16-cjs",
33
"version": "0.2.1",
4+
"dependencies": {
5+
"csv-generate": "^4.2.1",
6+
"csv-parse": "^5.3.4",
7+
"csv-stringify": "^6.2.3",
8+
"stream-transform": "^3.2.1"
9+
},
410
"main": "index.js",
511
"license": "MIT",
612
"private": true,
713
"devDependencies": {
814
"typescript": "^4.9.5"
915
},
1016
"scripts": {
11-
"typecheck": "tsc --noEmit"
17+
"test": "tsc --noEmit"
1218
}
1319
}
File renamed without changes.

demo/ts-module-node16/package.json renamed to demo/ts-esm-node16/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"license": "MIT",
66
"type": "module",
77
"private": true,
8+
"dependencies": {
9+
"csv-generate": "^4.2.1",
10+
"csv-parse": "^5.3.4",
11+
"csv-stringify": "^6.2.3",
12+
"stream-transform": "^3.2.1"
13+
},
814
"devDependencies": {
915
"@types/node": "^18.11.9",
1016
"coffeescript": "^2.7.0",

demo/ts-moduleresolution-node16-cjs/lib/stringify.ts

-32
This file was deleted.

demo/webpack-ts/package.json

+11-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"version": "0.1.3",
44
"description": "",
55
"private": true,
6-
"scripts": {
7-
"build": "npx webpack --config webpack.config.js",
8-
"start": "http-server ./dist -p 8080",
9-
"test": "npm run build >/dev/null"
10-
},
116
"keywords": [],
127
"author": "",
138
"license": "ISC",
9+
"dependencies": {
10+
"csv-generate": "^4.2.1",
11+
"csv-parse": "^5.3.4",
12+
"csv-stringify": "^6.2.3",
13+
"http-server": "^14.1.1",
14+
"stream-transform": "^3.2.1"
15+
},
1416
"devDependencies": {
1517
"buffer-browserify": "^0.2.5",
1618
"node-polyfill-webpack-plugin": "^2.0.1",
@@ -20,7 +22,9 @@
2022
"webpack": "^5.74.0",
2123
"webpack-cli": "^4.10.0"
2224
},
23-
"dependencies": {
24-
"http-server": "^14.1.1"
25+
"scripts": {
26+
"build": "npx webpack --config webpack.config.js",
27+
"start": "http-server ./dist -p 8080",
28+
"test": "npm run build >/dev/null"
2529
}
2630
}

demo/webpack/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
"webpack-cli": "^4.10.0"
1717
},
1818
"dependencies": {
19+
"csv": "^6.2.6",
20+
"csv-generate": "^4.2.1",
21+
"csv-parse": "^5.3.4",
22+
"csv-stringify": "^6.2.3",
1923
"http-server": "^14.1.1",
20-
"stream-browserify": "^3.0.0"
24+
"stream-browserify": "^3.0.0",
25+
"stream-transform": "^3.2.1"
2126
}
2227
}

packages/csv-generate/package.json

+27-12
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,41 @@
2929
},
3030
"exports": {
3131
".": {
32-
"import": "./lib/index.js",
33-
"require": "./dist/cjs/index.cjs",
34-
"types": "./lib/index.d.ts"
32+
"import": {
33+
"types": "./lib/index.d.ts",
34+
"default": "./lib/index.js"
35+
},
36+
"require": {
37+
"types": "./dist/cjs/index.d.cts",
38+
"default": "./dist/cjs/index.cjs"
39+
}
3540
},
3641
"./sync": {
37-
"import": "./lib/sync.js",
38-
"require": "./dist/cjs/sync.cjs",
39-
"types": "./lib/sync.d.ts"
42+
"import": {
43+
"types": "./lib/sync.d.ts",
44+
"default": "./lib/sync.js"
45+
},
46+
"require": {
47+
"types": "./dist/cjs/sync.d.cts",
48+
"default": "./dist/cjs/sync.cjs"
49+
}
4050
},
4151
"./stream": {
42-
"import": "./lib/stream.js",
43-
"require": "./dist/cjs/stream.cjs",
44-
"types": "./lib/stream.d.ts"
52+
"import": {
53+
"types": "./lib/stream.d.ts",
54+
"default": "./lib/stream.js"
55+
},
56+
"require": {
57+
"types": "./dist/cjs/stream.d.cts",
58+
"default": "./dist/cjs/stream.cjs"
59+
}
4560
},
4661
"./browser/esm": {
47-
"types": "./lib/index.d.ts",
62+
"types": "./dist/esm/index.d.ts",
4863
"default": "./dist/esm/index.js"
4964
},
5065
"./browser/esm/sync": {
51-
"types": "./lib/sync.d.ts",
66+
"types": "./dist/esm/sync.d.ts",
5267
"default": "./dist/esm/sync.js"
5368
}
5469
},
@@ -78,7 +93,7 @@
7893
"scripts": {
7994
"build": "npm run build:rollup && npm run build:ts",
8095
"build:rollup": "npx rollup -c",
81-
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
96+
"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",
8297
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
8398
"lint:lib": "eslint --fix lib/*.js",
8499
"lint:samples": "eslint --fix samples/*.js",

packages/csv-parse/package.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,31 @@
3131
],
3232
"exports": {
3333
".": {
34-
"import": "./lib/index.js",
35-
"require": "./dist/cjs/index.cjs",
36-
"types": "./lib/index.d.ts"
34+
"import": {
35+
"types": "./lib/index.d.ts",
36+
"default": "./lib/index.js"
37+
},
38+
"require": {
39+
"types": "./dist/cjs/index.d.cts",
40+
"default": "./dist/cjs/index.cjs"
41+
}
3742
},
3843
"./sync": {
39-
"import": "./lib/sync.js",
40-
"require": "./dist/cjs/sync.cjs",
41-
"types": "./lib/sync.d.ts"
44+
"import": {
45+
"types": "./lib/sync.d.ts",
46+
"default": "./lib/sync.js"
47+
},
48+
"require": {
49+
"types": "./dist/cjs/sync.d.cts",
50+
"default": "./dist/cjs/sync.cjs"
51+
}
4252
},
4353
"./browser/esm": {
44-
"types": "./lib/index.d.ts",
54+
"types": "./dist/esm/index.d.ts",
4555
"default": "./dist/esm/index.js"
4656
},
4757
"./browser/esm/sync": {
48-
"types": "./lib/sync.d.ts",
58+
"types": "./dist/esm/sync.d.ts",
4959
"default": "./dist/esm/sync.js"
5060
}
5161
},
@@ -96,7 +106,7 @@
96106
"scripts": {
97107
"build": "npm run build:rollup && npm run build:ts",
98108
"build:rollup": "npx rollup -c",
99-
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
109+
"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",
100110
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
101111
"lint:lib": "eslint --fix lib/*.js",
102112
"lint:samples": "eslint --fix samples/*.js",

packages/csv-stringify/package.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,31 @@
2929
},
3030
"exports": {
3131
".": {
32-
"import": "./lib/index.js",
33-
"require": "./dist/cjs/index.cjs",
34-
"types": "./lib/index.d.ts"
32+
"import": {
33+
"types": "./lib/index.d.ts",
34+
"default": "./lib/index.js"
35+
},
36+
"require": {
37+
"types": "./dist/cjs/index.d.cts",
38+
"default": "./dist/cjs/index.cjs"
39+
}
3540
},
3641
"./sync": {
37-
"import": "./lib/sync.js",
38-
"require": "./dist/cjs/sync.cjs",
39-
"types": "./lib/sync.d.ts"
42+
"import": {
43+
"types": "./lib/sync.d.ts",
44+
"default": "./lib/sync.js"
45+
},
46+
"require": {
47+
"types": "./dist/cjs/sync.d.cts",
48+
"default": "./dist/cjs/sync.cjs"
49+
}
4050
},
4151
"./browser/esm": {
42-
"types": "./lib/index.d.ts",
52+
"types": "./dist/esm/index.d.ts",
4353
"default": "./dist/esm/index.js"
4454
},
4555
"./browser/esm/sync": {
46-
"types": "./lib/sync.d.ts",
56+
"types": "./dist/esm/sync.d.ts",
4757
"default": "./dist/esm/sync.js"
4858
}
4959
},
@@ -73,7 +83,7 @@
7383
"scripts": {
7484
"build": "npm run build:rollup && npm run build:ts",
7585
"build:rollup": "npx rollup -c",
76-
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
86+
"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",
7787
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
7888
"lint:lib": "eslint --fix lib/*.js",
7989
"lint:samples": "eslint --fix samples/*.js",

packages/stream-transform/package.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,31 @@
2929
},
3030
"exports": {
3131
".": {
32-
"import": "./lib/index.js",
33-
"require": "./dist/cjs/index.cjs",
34-
"types": "./lib/index.d.ts"
32+
"import": {
33+
"types": "./lib/index.d.ts",
34+
"default": "./lib/index.js"
35+
},
36+
"require": {
37+
"types": "./dist/cjs/index.d.cts",
38+
"default": "./dist/cjs/index.cjs"
39+
}
3540
},
3641
"./sync": {
37-
"import": "./lib/sync.js",
38-
"require": "./dist/cjs/sync.cjs",
39-
"types": "./lib/sync.d.ts"
42+
"import": {
43+
"types": "./lib/sync.d.ts",
44+
"default": "./lib/sync.js"
45+
},
46+
"require": {
47+
"types": "./dist/cjs/sync.d.cts",
48+
"default": "./dist/cjs/sync.cjs"
49+
}
4050
},
4151
"./browser/esm": {
42-
"types": "./lib/index.d.ts",
52+
"types": "./dist/esm/index.d.ts",
4353
"default": "./dist/esm/index.js"
4454
},
4555
"./browser/esm/sync": {
46-
"types": "./lib/sync.d.ts",
56+
"types": "./dist/esm/sync.d.ts",
4757
"default": "./dist/esm/sync.js"
4858
}
4959
},
@@ -73,7 +83,7 @@
7383
"scripts": {
7484
"build": "npm run build:rollup && npm run build:ts",
7585
"build:rollup": "npx rollup -c",
76-
"build:ts": "cp lib/*.ts dist/cjs && cp lib/*.ts dist/esm",
86+
"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",
7787
"lint": "npm run lint:lib && npm run lint:samples && npm run lint:test",
7888
"lint:lib": "eslint --fix lib/*.js",
7989
"lint:samples": "eslint --fix samples/*.js",

0 commit comments

Comments
 (0)