Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
refactor: remove duplicate tsconfig and sourcemap code (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Jun 9, 2022
1 parent b810e73 commit a35b8f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/loaders-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@
*/
import {
transform,
installSourceMapSupport,
transformDynamicImport,
} from '@esbuild-kit/core-utils';
import getTsconfig from 'get-tsconfig';
import {
tsconfigRaw,
sourcemaps,
tsExtensionsPattern,
getFormatFromExtension,
type ModuleFormat,
type MaybePromise,
} from './utils';
import { getPackageType } from './package-json';

const tsconfig = getTsconfig();
const tsconfigRaw = tsconfig?.config;

const sourcemaps = installSourceMapSupport();

type getFormat = (
url: string,
context: Record<string, unknown>,
Expand Down
9 changes: 2 additions & 7 deletions src/loaders.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import path from 'path';
import {
transform,
installSourceMapSupport,
transformDynamicImport,
resolveTsPath,
} from '@esbuild-kit/core-utils';
import getTsconfig from 'get-tsconfig';
import {
tsconfigRaw,
sourcemaps,
tsExtensionsPattern,
getFormatFromExtension,
type ModuleFormat,
type MaybePromise,
} from './utils';
import { getPackageType } from './package-json';

const sourcemaps = installSourceMapSupport();

const tsconfig = getTsconfig();
const tsconfigRaw = tsconfig?.config;

type Resolved = {
url: string;
format: ModuleFormat;
Expand Down
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import path from 'path';
import { installSourceMapSupport } from '@esbuild-kit/core-utils';
import getTsconfig from 'get-tsconfig';

const tsconfig = getTsconfig();
export const tsconfigRaw = tsconfig?.config;

export const sourcemaps = installSourceMapSupport();

export const tsExtensionsPattern = /\.([cm]?ts|[tj]sx)$/;

Expand Down

0 comments on commit a35b8f9

Please sign in to comment.