Skip to content

Commit 781f2c1

Browse files
committed
feat: converting repo to esm
1 parent c4dc04a commit 781f2c1

18 files changed

+3413
-1399
lines changed

package-lock.json

Lines changed: 3342 additions & 1330 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"type": "git",
2222
"url": "https://github.com/MatrixAI/js-virtualtar.git"
2323
},
24+
"type" :"module",
2425
"main": "dist/index.js",
2526
"types": "dist/index.d.ts",
2627
"scripts": {
@@ -34,14 +35,14 @@
3435
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
3536
},
3637
"dependencies": {
37-
"@matrixai/errors": "^1.1.7"
38+
"@matrixai/errors": "^2.1.3"
3839
},
3940
"devDependencies": {
40-
"@fast-check/jest": "^1.1.0",
41+
"@fast-check/jest": "^2.1.0",
4142
"@matrixai/lint": "^0.2.11",
4243
"@swc/core": "^1.3.62",
4344
"@swc/jest": "^0.2.26",
44-
"@types/jest": "^28.1.3",
45+
"@types/jest": "^29.1.3",
4546
"@types/node": "^18.15.0",
4647
"@types/tar": "^6.1.13",
4748
"fast-check": "^3.0.1",
@@ -54,7 +55,7 @@
5455
"ts-jest": "^28.0.5",
5556
"ts-node": "^10.9.1",
5657
"tsconfig-paths": "^3.9.0",
57-
"typedoc": "^0.23.21",
58-
"typescript": "^4.9.3"
58+
"typedoc": "^0.24.8",
59+
"typescript": "^5.1.6"
5960
}
6061
}

src/Generator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { FileType, FileStat } from './types';
2-
import { GeneratorState } from './types';
3-
import * as constants from './constants';
4-
import * as errors from './errors';
5-
import * as utils from './utils';
1+
import type { FileType, FileStat } from './types.js';
2+
import { GeneratorState } from './types.js';
3+
import * as constants from './constants.js';
4+
import * as errors from './errors.js';
5+
import * as utils from './utils.js';
66

77
/**
88
* The Generator can be used to generate blocks for a tar archive. The generator

src/Parser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { TokenHeader, TokenData, TokenEnd } from './types';
2-
import { ParserState } from './types';
3-
import * as constants from './constants';
4-
import * as errors from './errors';
5-
import * as utils from './utils';
1+
import type { TokenHeader, TokenData, TokenEnd } from './types.js';
2+
import { ParserState } from './types.js';
3+
import * as constants from './constants.js';
4+
import * as errors from './errors.js';
5+
import * as utils from './utils.js';
66

77
/**
88
* The Parser is used to parse blocks from a tar archive. Each written chunk can

src/VirtualTarGenerator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { FileStat } from './types';
2-
import Generator from './Generator';
3-
import * as constants from './constants';
4-
import * as utils from './utils';
1+
import type { FileStat } from './types.js';
2+
import Generator from './Generator.js';
3+
import * as constants from './constants.js';
4+
import * as utils from './utils.js';
55

66
/**
77
* VirtualTar is a library used to create tar files using a virtual file system

src/VirtualTarParser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import type {
44
MetadataKeywords,
55
TokenData,
66
TokenHeader,
7-
} from './types';
8-
import Parser from './Parser';
9-
import * as constants from './constants';
10-
import * as errors from './errors';
11-
import * as utils from './utils';
7+
} from './types.js';
8+
import Parser from './Parser.js';
9+
import * as constants from './constants.js';
10+
import * as errors from './errors.js';
11+
import * as utils from './utils.js';
1212

1313
/**
1414
* VirtualTar is a library used to create tar files using a virtual file system

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export { default as Generator } from './Generator';
2-
export { default as Parser } from './Parser';
3-
export { default as VirtualTarGenerator } from './VirtualTarGenerator';
4-
export { default as VirtualTarParser } from './VirtualTarParser';
5-
export * as constants from './constants';
6-
export * as errors from './errors';
7-
export * as utils from './utils';
8-
export * as types from './types';
1+
export { default as Generator } from './Generator.js';
2+
export { default as Parser } from './Parser.js';
3+
export { default as VirtualTarGenerator } from './VirtualTarGenerator.js';
4+
export { default as VirtualTarParser } from './VirtualTarParser.js';
5+
export * as constants from './constants.js';
6+
export * as errors from './errors.js';
7+
export * as utils from './utils.js';
8+
export * as types from './types.js';

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { FileType, MetadataKeywords } from './types';
2-
import { EntryType } from './types';
3-
import * as errors from './errors';
4-
import * as constants from './constants';
1+
import type { FileType, MetadataKeywords } from './types.js';
2+
import { EntryType } from './types.js';
3+
import * as errors from './errors.js';
4+
import * as constants from './constants.js';
55

66
// Text decoder for text parsing utilities
77
const decoder = new TextDecoder('ascii');

tests/Generator.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import path from 'path';
44
import fc from 'fast-check';
55
import { test } from '@fast-check/jest';
66
import * as tar from 'tar';
7-
import Generator from '@/Generator';
8-
import { EntryType, GeneratorState } from '@/types';
9-
import * as tarConstants from '@/constants';
10-
import * as tarErrors from '@/errors';
11-
import * as tarUtils from '@/utils';
12-
import * as utils from './utils';
7+
import Generator from '@/Generator.js';
8+
import { EntryType, GeneratorState } from '@/types.js';
9+
import * as tarConstants from '@/constants.js';
10+
import * as tarErrors from '@/errors.js';
11+
import * as tarUtils from '@/utils.js';
12+
import * as utils from './utils/index.js';
1313

1414
describe('generating archive', () => {
1515
test.prop([utils.fileArb()])(

tests/Parser.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import type { VirtualFile, VirtualDirectory } from './types';
2-
import type { MetadataKeywords } from '@/types';
1+
import type { VirtualFile, VirtualDirectory } from './types.js';
2+
import type { MetadataKeywords } from '@/types.js';
33
import fs from 'fs';
44
import path from 'path';
55
import os from 'os';
66
import fc from 'fast-check';
77
import { test } from '@fast-check/jest';
88
import * as tar from 'tar';
9-
import Parser from '@/Parser';
10-
import { ParserState } from '@/types';
11-
import * as tarErrors from '@/errors';
12-
import * as tarUtils from '@/utils';
13-
import * as tarConstants from '@/constants';
14-
import * as utils from './utils';
9+
import Parser from '@/Parser.js';
10+
import { ParserState } from '@/types.js';
11+
import * as tarErrors from '@/errors.js';
12+
import * as tarUtils from '@/utils.js';
13+
import * as tarConstants from '@/constants.js';
14+
import * as utils from './utils/index.js';
1515

1616
describe('parsing archive blocks', () => {
1717
test.prop([utils.tarEntryArb()])(

tests/VirtualTarGenerator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from 'path';
33
import os from 'os';
44
import { test } from '@fast-check/jest';
55
import * as tar from 'tar';
6-
import { VirtualTarGenerator } from '@';
7-
import * as tarConstants from '@/constants';
6+
import { VirtualTarGenerator } from '../src/index.js';
7+
import * as tarConstants from '@/constants.js';
88

99
describe('generator', () => {
1010
let tempDir;

tests/VirtualTarParser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import os from 'os';
44
import { test } from '@fast-check/jest';
55
import * as tar from 'tar';
6-
import { VirtualTarParser } from '@';
6+
import { VirtualTarParser } from '@/index.js';
77

88
describe('parser', () => {
99
let tempDir;

tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as tar from '@';
1+
import * as tar from '@/index.js';
22

33
describe('index', () => {
44
test('should have correct high-level exports', () => {

tests/integration.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { FileStat, MetadataKeywords } from '@/types';
2-
import type { VirtualFile, VirtualDirectory } from './types';
1+
import type { FileStat, MetadataKeywords } from '@/types.js';
2+
import type { VirtualFile, VirtualDirectory } from './types.js';
33
import { test } from '@fast-check/jest';
4-
import { Generator, Parser, VirtualTarGenerator, VirtualTarParser } from '@';
5-
import * as tarUtils from '@/utils';
6-
import * as tarConstants from '@/constants';
7-
import * as utils from './utils';
4+
import { Generator, Parser, VirtualTarGenerator, VirtualTarParser } from '@/index.js';
5+
import * as tarUtils from '@/utils.js';
6+
import * as tarConstants from '@/constants.js';
7+
import * as utils from './utils/index.js';
88

99
describe('integration testing', () => {
1010
test.prop([utils.fileTreeArb()])(

tests/utils/fastcheck.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { VirtualFile, VirtualDirectory } from '../types';
2-
import type { FileStat } from '@/types';
1+
import type { VirtualFile, VirtualDirectory } from '../types.js';
2+
import type { FileStat } from '@/types.js';
33
import fc from 'fast-check';
4-
import * as tarConstants from '@/constants';
5-
import * as tarUtils from '@/utils';
4+
import * as tarConstants from '@/constants.js';
5+
import * as tarUtils from '@/utils.js';
66

77
/**
88
* Creates an arbitrary to produce valid (and common) unix file modes. Note that

tests/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './fastcheck';
2-
export * from './utils';
1+
export * from './fastcheck.js';
2+
export * from './utils.js';

tests/utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as tarUtils from '@/utils';
1+
import * as tarUtils from '@/utils.js';
22

33
const deepSort = (obj: unknown) => {
44
if (Array.isArray(obj)) {

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
"esModuleInterop": true,
1313
"allowSyntheticDefaultImports": true,
1414
"resolveJsonModule": true,
15-
"moduleResolution": "node",
16-
"module": "CommonJS",
15+
"moduleResolution": "NodeNext",
16+
"module": "ESNext",
1717
"target": "ES2022",
1818
"baseUrl": "./src",
1919
"paths": {
2020
"@": ["index"],
2121
"@/*": ["*"]
2222
},
23+
"skipLibCheck": true,
2324
"noEmit": true
2425
},
2526
"include": [

0 commit comments

Comments
 (0)