Skip to content

Commit 6d4ebf6

Browse files
committed
fix imports, use esm
1 parent 6e28e72 commit 6d4ebf6

File tree

15 files changed

+134
-21
lines changed

15 files changed

+134
-21
lines changed

lib/bundle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import $Ref from "./ref.js";
22
import Pointer from "./pointer.js";
33
import * as url from "./util/url.js";
44
import type $Refs from "./refs.js";
5-
import type $RefParser from "./index";
6-
import type { ParserOptions } from "./index";
7-
import type { JSONSchema } from "./index";
8-
import type { BundleOptions } from "./options";
5+
import type $RefParser from "./index.js";
6+
import type { ParserOptions } from "./index.js";
7+
import type { JSONSchema } from "./index.js";
8+
import type { BundleOptions } from "./options.js";
99

1010
export interface InventoryEntry {
1111
$ref: any;

lib/dereference.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import Pointer from "./pointer.js";
33
import * as url from "./util/url.js";
44
import type $Refs from "./refs.js";
55
import type { DereferenceOptions, ParserOptions } from "./options.js";
6-
import type { JSONSchema } from "./types";
7-
import type $RefParser from "./index";
8-
import { TimeoutError } from "./util/errors";
6+
import { type $RefParser, type JSONSchema } from "./index.js";
7+
import { TimeoutError } from "./util/errors.js";
98

109
export default dereference;
1110

lib/normalize-args.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Options, ParserOptions } from "./options.js";
22
import { getNewOptions } from "./options.js";
3-
import type { JSONSchema, SchemaCallback } from "./types";
3+
import type { JSONSchema, SchemaCallback } from "./index.js";
44

55
// I really dislike this function and the way it's written. It's not clear what it's doing, and it's way too flexible
66
// In the future, I'd like to deprecate the api and accept only named parameters in index.ts

lib/pointer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ParserOptions } from "./options.js";
33
import $Ref from "./ref.js";
44
import * as url from "./util/url.js";
55
import { JSONParserError, InvalidPointerError, MissingPointerError, isHandledError } from "./util/errors.js";
6-
import type { JSONSchema } from "./types";
6+
import type { JSONSchema } from "./index.js";
77
import type { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
88

99
export const nullSymbol = Symbol("null");

lib/ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { InvalidPointerError, isHandledError, normalizeError } from "./util/erro
44
import { safePointerToPath, stripHash, getHash } from "./util/url.js";
55
import type $Refs from "./refs.js";
66
import type { ParserOptions } from "./options.js";
7-
import type { JSONSchema } from "./types";
7+
import type { JSONSchema } from "./index.js";
88
import type { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
99

1010
export type $RefError = JSONParserError | ResolverError | ParserError | MissingPointerError;

lib/refs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import $Ref from "./ref.js";
22
import * as url from "./util/url.js";
33
import type { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
44
import type { ParserOptions } from "./options.js";
5-
import convertPathToPosix from "./util/convert-path-to-posix";
6-
import type { JSONSchema } from "./types";
5+
import convertPathToPosix from "./util/convert-path-to-posix.js";
6+
import type { JSONSchema } from "./index.js";
77

88
interface $RefsMap<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
99
[url: string]: $Ref<S, O>;

lib/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
JSONSchema7Object,
88
} from "json-schema";
99
import type $Refs from "../refs.js";
10-
import type { ParserOptions } from "../options";
10+
import type { ParserOptions } from "../options.js";
1111

1212
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
1313
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;

lib/util/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getHash, stripHash, toFileSystemPath } from "./url.js";
22
import type $RefParser from "../index.js";
33
import type { ParserOptions } from "../index.js";
44
import type { JSONSchema } from "../index.js";
5-
import type $Ref from "../ref";
5+
import type $Ref from "../ref.js";
66

77
export type JSONParserErrorType =
88
| "EUNKNOWN"

lib/util/url.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import convertPathToPosix from "./convert-path-to-posix";
1+
import convertPathToPosix from "./convert-path-to-posix.js";
22
import path, { win32 } from "path";
33

44
const forwardSlashPattern = /\//g;
@@ -7,7 +7,7 @@ const jsonPointerSlash = /~1/g;
77
const jsonPointerTilde = /~0/g;
88

99
import { join } from "path";
10-
import { isWindows } from "./is-windows";
10+
import { isWindows } from "./is-windows.js";
1111

1212
// RegExp patterns to URL-encode special characters in local filesystem paths
1313
const urlEncodePatterns = [

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"name": "@apidevtools/json-schema-ref-parser",
33
"version": "0.0.0-dev",
44
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5+
"type": "module",
6+
"types": "dist/lib/index.d.ts",
7+
"module": "dist/lib/index.js",
58
"scripts": {
69
"prepublishOnly": "yarn build",
710
"lint": "eslint lib",
811
"build": "rimraf dist && tsc",
912
"typecheck": "tsc --noEmit",
1013
"prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
1114
"test": "vitest --coverage",
15+
"test:specific": "vitest defs-encoding",
1216
"test:node": "yarn test",
1317
"test:browser": "cross-env BROWSER=\"true\" yarn test",
1418
"test:update": "vitest -u",
@@ -53,14 +57,11 @@
5357
"url": "https://github.com/APIDevTools/json-schema-ref-parser.git"
5458
},
5559
"license": "MIT",
56-
"funding": "https://github.com/sponsors/philsturgeon",
57-
"types": "dist/lib/index.d.ts",
58-
"main": "dist/lib/index.js",
5960
"browser": {
6061
"fs": false
6162
},
6263
"engines": {
63-
"node": ">= 20"
64+
"node": ">=20"
6465
},
6566
"files": [
6667
"lib",

0 commit comments

Comments
 (0)