Skip to content

Commit

Permalink
Import ts with extension
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Aug 6, 2024
1 parent 224fdce commit b508ba6
Show file tree
Hide file tree
Showing 27 changed files with 65 additions and 68 deletions.
8 changes: 2 additions & 6 deletions babel.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ export default api => {
);
plugins.push(
[
'esm-resolver',
'module-replace',
{
source: {
extensions: [
[['.js', '.mjs', '.jsx', '.mjsx', '.ts', '.tsx'], ext]
]
}
replace: [[/^(\.\.?\/.+)\.(m|c)?tsx?$/i, `$1${ext}`]]
}
],
[
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@types/node": "^22.1.0",
"@types/unbzip2-stream": "^1.4.3",
"@types/yauzl": "^2.10.3",
"babel-plugin-esm-resolver": "^3.0.0",
"babel-plugin-module-replace": "^1.0.1",
"babel-plugin-search-and-replace": "^1.1.1",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/archive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import {join as pathJoin} from 'node:path';
import {Readable, Writable} from 'node:stream';
import {pipeline} from 'node:stream/promises';

import {Archive, Entry, IEntryInfo} from './archive';
import {PathType} from './types';
import {Archive, Entry, IEntryInfo} from './archive.ts';
import {PathType} from './types.ts';
import {
fsLchmodSupported,
fsLstat,
fsLutimesSupported,
modePermissionBits,
pathResourceFork,
streamToBuffer
} from './util';
} from './util.ts';

export const specTmpPath = (
(i: number) => (s: string) =>
Expand Down
2 changes: 1 addition & 1 deletion src/archive.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {describe} from 'node:test';

import {ArchiveTest, testArchive} from './archive.spec';
import {ArchiveTest, testArchive} from './archive.spec.ts';

void describe('archive', () => {
void describe('Archive', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {promisify} from 'node:util';

const pipe = promisify(pipeline);

import {PathType} from './types';
import {PathType} from './types.ts';
import {
fsChmod,
fsLchmod,
Expand All @@ -20,7 +20,7 @@ import {
pathNormalize,
pathResourceFork,
streamToBuffer
} from './util';
} from './util.ts';

export interface IArchiveAfterReadSetAttributesEntry {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/archive/dir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
platformIsWin,
safeToExtract,
testArchive
} from '../archive.spec';
import {PathType} from '../types';
} from '../archive.spec.ts';
import {PathType} from '../types.ts';

import {ArchiveDir} from './dir';
import {ArchiveDir} from './dir.ts';

void describe('archive/dir', () => {
void describe('ArchiveDir', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/archive/dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {Stats, createReadStream} from 'node:fs';
import {join as pathJoin} from 'node:path';

import {Archive, Entry, IEntryInfo} from '../archive';
import {PathType} from '../types';
import {Archive, Entry, IEntryInfo} from '../archive.ts';
import {PathType} from '../types.ts';
import {
fsLstat,
fsLstatExists,
Expand All @@ -13,7 +13,7 @@ import {
pathNormalize,
pathResourceFork,
statToPathType
} from '../util';
} from '../util.ts';

const walkOpts = {
ignoreUnreadableDirectories: true
Expand Down
4 changes: 2 additions & 2 deletions src/archive/hdi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {describe, it} from 'node:test';
import {deepStrictEqual} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {platformIsMac, specFixturesPath, testArchive} from '../archive.spec';
import {platformIsMac, specFixturesPath, testArchive} from '../archive.spec.ts';

import {ArchiveHdi} from './hdi';
import {ArchiveHdi} from './hdi.ts';

// eslint-disable-next-line no-process-env
const NO_HDI = /^(1|true|yes)$/i.test(process.env['SHOCKPKG_NO_HDI'] || '');
Expand Down
6 changes: 3 additions & 3 deletions src/archive/hdi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import {basename, join as pathJoin} from 'node:path';

import {Mounter} from '@shockpkg/hdi-mac';

import {Archive, Entry, IEntryInfo} from '../archive';
import {PathType} from '../types';
import {Archive, Entry, IEntryInfo} from '../archive.ts';
import {PathType} from '../types.ts';
import {
fsLstatExists,
fsReadlinkRaw,
fsWalk,
pathNormalize,
pathResourceFork,
statToPathType
} from '../util';
} from '../util.ts';

const walkOpts = {
ignoreUnreadableDirectories: true
Expand Down
10 changes: 5 additions & 5 deletions src/archive/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './dir';
export * from './hdi';
export * from './tar';
export * from './tar/';
export * from './zip';
export * from './dir.ts';
export * from './hdi.ts';
export * from './tar.ts';
export * from './tar/index.ts';
export * from './zip.ts';
4 changes: 2 additions & 2 deletions src/archive/tar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {describe, it} from 'node:test';
import {deepStrictEqual} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {specFixturesPath, testArchive} from '../archive.spec';
import {specFixturesPath, testArchive} from '../archive.spec.ts';

import {ArchiveTar} from './tar';
import {ArchiveTar} from './tar.ts';

void describe('archive/tar', () => {
void describe('ArchiveTar', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {createReadStream} from 'node:fs';
import {Readable} from 'node:stream';

import {Archive, Entry, IEntryInfo} from '../archive';
import {PathType} from '../types';
import {Archive, Entry, IEntryInfo} from '../archive.ts';
import {PathType} from '../types.ts';

// Based on it-tar TarEntryHeader.
interface IHeader {
Expand Down
4 changes: 2 additions & 2 deletions src/archive/tar/bz2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {describe, it} from 'node:test';
import {deepStrictEqual} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {specFixturesPath, testArchive} from '../../archive.spec';
import {specFixturesPath, testArchive} from '../../archive.spec.ts';

import {ArchiveTarBz2} from './bz2';
import {ArchiveTarBz2} from './bz2.ts';

void describe('archive/tar/bz2', () => {
void describe('ArchiveTarBz2', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/archive/tar/bz2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unbzip2Stream from 'unbzip2-stream';

import {ArchiveTar} from '../tar';
import {ArchiveTar} from '../tar.ts';

/**
* ArchiveTarBz2 object.
Expand Down
4 changes: 2 additions & 2 deletions src/archive/tar/gz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {describe, it} from 'node:test';
import {deepStrictEqual} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {specFixturesPath, testArchive} from '../../archive.spec';
import {specFixturesPath, testArchive} from '../../archive.spec.ts';

import {ArchiveTarGz} from './gz';
import {ArchiveTarGz} from './gz.ts';

void describe('archive/tar/gz', () => {
void describe('ArchiveTarGz', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/archive/tar/gz.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createGunzip} from 'node:zlib';

import {ArchiveTar} from '../tar';
import {ArchiveTar} from '../tar.ts';

/**
* ArchiveTarGz object.
Expand Down
4 changes: 2 additions & 2 deletions src/archive/tar/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './bz2';
export * from './gz';
export * from './bz2.ts';
export * from './gz.ts';
4 changes: 2 additions & 2 deletions src/archive/zip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {describe, it} from 'node:test';
import {deepStrictEqual} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {specFixturesPath, testArchive} from '../archive.spec';
import {specFixturesPath, testArchive} from '../archive.spec.ts';

import {ArchiveZip} from './zip';
import {ArchiveZip} from './zip.ts';

void describe('archive/zip', () => {
void describe('ArchiveZip', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/archive/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {Readable} from 'node:stream';

import yauzl from 'yauzl';

import {Archive, Entry, IEntryInfo} from '../archive';
import {PathType} from '../types';
import {modeToPathType, streamToBuffer} from '../util';
import {Archive, Entry, IEntryInfo} from '../archive.ts';
import {PathType} from '../types.ts';
import {modeToPathType, streamToBuffer} from '../util.ts';

/**
* Read entry.
Expand Down
2 changes: 1 addition & 1 deletion src/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {ok, strictEqual} from 'node:assert';

import {createArchiveByFileExtension} from './create';
import {createArchiveByFileExtension} from './create.ts';

void describe('create', () => {
void describe('createArchiveByFileExtension', () => {
Expand Down
14 changes: 7 additions & 7 deletions src/create.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {stat} from 'node:fs/promises';

import {Archive} from './archive';
import {ArchiveDir} from './archive/dir';
import {ArchiveHdi} from './archive/hdi';
import {ArchiveTar} from './archive/tar';
import {ArchiveTarBz2} from './archive/tar/bz2';
import {ArchiveTarGz} from './archive/tar/gz';
import {ArchiveZip} from './archive/zip';
import {Archive} from './archive.ts';
import {ArchiveDir} from './archive/dir.ts';
import {ArchiveHdi} from './archive/hdi.ts';
import {ArchiveTar} from './archive/tar.ts';
import {ArchiveTarBz2} from './archive/tar/bz2.ts';
import {ArchiveTarGz} from './archive/tar/gz.ts';
import {ArchiveZip} from './archive/zip.ts';

export interface ICreateArchiveOptions {
/**
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './meta';
export * from './types';
export * from './util';
export * from './archive';
export * from './archive/';
export * from './create';
export * from './meta.ts';
export * from './types.ts';
export * from './util.ts';
export * from './archive.ts';
export * from './archive/index.ts';
export * from './create.ts';
2 changes: 1 addition & 1 deletion src/meta.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {match} from 'node:assert';

import {NAME, VERSION} from './meta';
import {NAME, VERSION} from './meta.ts';

void describe('meta', () => {
void it('NAME', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {describe, it} from 'node:test';
import {strictEqual} from 'node:assert';
import {mkdir, rm} from 'node:fs/promises';

import {fsLstatExists, pathNormalize, fsSymlink} from './util';
import {fsLstatExists, pathNormalize, fsSymlink} from './util.ts';

async function withSymlinksDir(f: (dir: string) => unknown) {
const dir = 'spec/tmp/symlinks';
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {join as pathJoin} from 'node:path';
import {Readable, Writable} from 'node:stream';
import {pipeline} from 'node:stream/promises';

import {PathType} from './types';
import {PathType} from './types.ts';

export interface IFsWalkOptions {
/**
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "commonjs",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"lib": ["ESNext"],
"newLine": "lf",

Expand Down

0 comments on commit b508ba6

Please sign in to comment.