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 a756998 commit 11b0a10
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 34 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 @@ -67,7 +67,7 @@
"@stylistic/eslint-plugin": "^2.6.1",
"@types/express": "^4.17.21",
"@types/node": "^22.1.0",
"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
2 changes: 1 addition & 1 deletion src/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {ok} from 'node:assert';

import {PACKAGES_URL} from './constants';
import {PACKAGES_URL} from './constants.ts';

void describe('constants', () => {
void describe('PACKAGES_URL', () => {
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from './meta';
export * from './types';
export * from './constants';
export * from './dispatcher';
export * from './stream';
export * from './package';
export * from './packages';
export * from './manager';
export * from './meta.ts';
export * from './types.ts';
export * from './constants.ts';
export * from './dispatcher.ts';
export * from './stream.ts';
export * from './package.ts';
export * from './packages.ts';
export * from './manager.ts';
2 changes: 1 addition & 1 deletion src/manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Server} from 'node:http';

import express from 'express';

import {IPackageDownloadProgress, Manager} from './manager';
import {IPackageDownloadProgress, Manager} from './manager.ts';

const withTemp = (i => async (func: (path: string) => Promise<unknown>) => {
const path = `./spec/tmp/manager/${i++}`;
Expand Down
14 changes: 7 additions & 7 deletions src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
TEMP_EXT,
PATH_ENV,
TEMP_DIR
} from './constants';
import {Dispatcher} from './dispatcher';
import {EmptyStream, SliceStream, WriterStream} from './stream';
import {Package} from './package';
import {Packages} from './packages';
import {IFetch} from './types';
import {NAME, VERSION} from './meta';
} from './constants.ts';
import {Dispatcher} from './dispatcher.ts';
import {EmptyStream, SliceStream, WriterStream} from './stream.ts';
import {Package} from './package.ts';
import {Packages} from './packages.ts';
import {IFetch} from './types.ts';
import {NAME, VERSION} from './meta.ts';

/**
* Retry once on error.
Expand Down
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/packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {describe, it} from 'node:test';
import {deepStrictEqual, ok, strictEqual, throws} from 'node:assert';
import {access, mkdir, rm, writeFile} from 'node:fs/promises';

import {Packages} from './packages';
import {Packages} from './packages.ts';

const withTemp = (i => async (func: (file: string, dir: string) => unknown) => {
const dir = `./spec/tmp/packages/${i++}`;
Expand Down
4 changes: 2 additions & 2 deletions src/packages.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {access, mkdir, readFile, rename, rm, writeFile} from 'node:fs/promises';
import {dirname} from 'node:path';

import {IPackagesListPackage, Package} from './package';
import {TEMP_EXT} from './constants';
import {IPackagesListPackage, Package} from './package.ts';
import {TEMP_EXT} from './constants.ts';

export interface IPackageUpdated {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {pipeline} from 'node:stream/promises';
import {join as pathJoin} from 'node:path';
import {rm, mkdir, lstat} from 'node:fs/promises';

import {EmptyStream, SliceStream, WriterStream} from './stream';
import {EmptyStream, SliceStream, WriterStream} from './stream.ts';

const withTemp = (i => async (func: (dir: string) => unknown) => {
const dir = `./spec/tmp/stream/${i++}`;
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", "dom"],
"newLine": "lf",

Expand Down

0 comments on commit 11b0a10

Please sign in to comment.