Skip to content

Commit 246e046

Browse files
authored
fix: migrate to Node16 module resolution to fix ES module imports (#29)
- Switch from bundler to node16 moduleResolution - Add .js extensions to all relative imports in source files - Update samples and documentation to reflect changes - Fix ESLint configuration for test files - Update copilot-instructions.md with Node16 requirements Fixes ERR_MODULE_NOT_FOUND errors when consuming package
1 parent ba13377 commit 246e046

26 files changed

+71
-56
lines changed

.github/copilot-instructions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This is a TypeScript project using modern best practices with ES modules, pnpm p
77
## Technology Stack
88

99
- **TypeScript**: Strict mode enabled with modern ES2022+ features
10+
- Uses Node16 module resolution for proper ES module support
11+
- All relative imports require `.js` extensions
1012
- **Package Manager**: pnpm (required)
1113
- **Build Tool**: TypeScript Compiler (tsc)
1214
- **Testing**: Vitest with coverage support
@@ -31,6 +33,9 @@ This is a TypeScript project using modern best practices with ES modules, pnpm p
3133
### TypeScript
3234

3335
- Always use ES modules (`import`/`export`)
36+
- **All relative imports MUST include `.js` extensions** (e.g., `'./types.js'`, not `'./types'`)
37+
- This is required for Node16 module resolution
38+
- TypeScript will correctly map `.js` to `.ts` files during compilation
3439
- Enable strict type checking
3540
- Prefer type inference but add explicit return types for exported functions
3641
- Use `type` imports when importing only types

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ dist
138138
vite.config.js.timestamp-*
139139
vite.config.ts.timestamp-*
140140
samples/temp/
141+
.DS_Store

__tests__/writers/csv/CsvWriter.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ describe('CsvWriter', () => {
4040
};
4141

4242
// Act & Assert
43-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4443
expect(() => new CsvWriter(options as any)).toThrow('Invalid writer type for CsvWriter');
4544
});
4645

__tests__/writers/json/JsonWriter.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
21
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
32
import * as fs from 'node:fs';
43
import * as path from 'node:path';
@@ -41,7 +40,6 @@ describe('JsonWriter', () => {
4140
};
4241

4342
// Act & Assert
44-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4543
expect(() => new JsonWriter(options as any)).toThrow('Invalid writer type for JsonWriter');
4644
});
4745

eslint.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ export default [
6969
'@typescript-eslint/no-explicit-any': 'off',
7070
},
7171
},
72+
{
73+
files: ['__tests__/**/*.ts'],
74+
rules: {
75+
'@typescript-eslint/no-unsafe-assignment': 'off',
76+
'@typescript-eslint/no-unsafe-member-access': 'off',
77+
'@typescript-eslint/no-unsafe-call': 'off',
78+
'@typescript-eslint/no-unsafe-argument': 'off',
79+
'@typescript-eslint/no-unsafe-return': 'off',
80+
'@typescript-eslint/no-unsafe-construction': 'off',
81+
},
82+
},
7283
{
7384
files: ['samples/**/*.ts'],
7485
rules: {
@@ -78,6 +89,7 @@ export default [
7889
'@typescript-eslint/no-unsafe-member-access': 'off',
7990
'@typescript-eslint/no-unsafe-call': 'off',
8091
'@typescript-eslint/no-unsafe-argument': 'off',
92+
'@typescript-eslint/no-unsafe-return': 'off',
8193
},
8294
},
8395
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scottluskcis/outport",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "Tool for exporting data to a format that can be used for reporting such as CSV, JSON, etc.",
55
"type": "module",
66
"main": "./dist/index.js",

samples/01-basic-csv-export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Run: npx tsx samples/01-basic-csv-export.ts
88
*/
99

10-
import { outport } from '../src/index';
10+
import { outport } from '../src/index.js';
1111
import * as path from 'path';
1212
import * as fs from 'fs';
1313
import { fileURLToPath } from 'url';

samples/02-basic-json-export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Run: npx tsx samples/02-basic-json-export.ts
88
*/
99

10-
import { outport } from '../src/index';
10+
import { outport } from '../src/index.js';
1111
import * as path from 'path';
1212
import * as fs from 'fs';
1313
import { fileURLToPath } from 'url';

samples/03-csv-custom-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Run: npx tsx samples/03-csv-custom-config.ts
1111
*/
1212

13-
import { outport } from '../src/index';
13+
import { outport } from '../src/index.js';
1414
import * as path from 'path';
1515
import * as fs from 'fs';
1616
import { fileURLToPath } from 'url';

samples/04-progress-tracking.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Run: npx tsx samples/04-progress-tracking.ts
88
*/
99

10-
import { outport } from '../src/index';
10+
import { outport } from '../src/index.js';
1111
import * as path from 'path';
1212
import * as fs from 'fs';
1313
import { fileURLToPath } from 'url';

0 commit comments

Comments
 (0)