Skip to content

Commit

Permalink
lint-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Oct 22, 2021
1 parent 4b957a1 commit b5ff840
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,19 @@ export namespace NodeLoaderHooksAPI2 {
url: string,
context: { format: NodeLoaderHooksFormat | null | undefined },
defaultLoad: NodeLoaderHooksAPI2['load']
) => Promise<{ format: NodeLoaderHooksFormat; source: string | Buffer | undefined }>;
) => Promise<{
format: NodeLoaderHooksFormat;
source: string | Buffer | undefined;
}>;
}

export type NodeLoaderHooksFormat = 'builtin' | 'commonjs' | 'dynamic' | 'json' | 'module' | 'wasm';
export type NodeLoaderHooksFormat =
| 'builtin'
| 'commonjs'
| 'dynamic'
| 'json'
| 'module'
| 'wasm';

/** @internal */
export function registerAndCreateEsmHooks(opts?: RegisterOptions) {
Expand Down Expand Up @@ -152,7 +161,10 @@ export function createEsmHooks(tsNodeService: Service) {
url: string,
context: { format: NodeLoaderHooksFormat | null | undefined },
defaultLoad: typeof load
): Promise<{ format: NodeLoaderHooksFormat; source: string | Buffer | undefined }> {
): Promise<{
format: NodeLoaderHooksFormat;
source: string | Buffer | undefined;
}> {
// If we get a format hint from resolve() on the context then use it
// otherwise call the old getFormat() hook using node's old built-in defaultGetFormat() that ships with ts-node
const format =
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export type {
TranspileOptions,
Transpiler,
} from './transpilers/types';
export type {NodeLoaderHooksAPI1, NodeLoaderHooksAPI2, NodeLoaderHooksFormat} from './esm';
export type {
NodeLoaderHooksAPI1,
NodeLoaderHooksAPI2,
NodeLoaderHooksFormat,
} from './esm';

/**
* Does this version of node obey the package.json "type" field
Expand Down
2 changes: 1 addition & 1 deletion src/test/esm-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.suite('createEsmHooks', (test) => {
test.suite('hooks', (_test) => {
const test = _test.context(async (t) => {
const service = t.context.tsNodeUnderTest.create({
cwd: TEST_DIR
cwd: TEST_DIR,
});
t.teardown(() => {
resetNodeEnvironment();
Expand Down

0 comments on commit b5ff840

Please sign in to comment.