@apidevtools/json-schema-ref-parser 9.1.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/cjs/bundle.js +304 -0
- package/cjs/dereference.js +258 -0
- package/cjs/index.js +603 -0
- package/cjs/normalize-args.js +64 -0
- package/cjs/options.js +125 -0
- package/cjs/package.json +3 -0
- package/cjs/parse.js +338 -0
- package/cjs/parsers/binary.js +54 -0
- package/cjs/parsers/json.js +199 -0
- package/cjs/parsers/text.js +61 -0
- package/cjs/parsers/yaml.js +239 -0
- package/cjs/pointer.js +290 -0
- package/cjs/ref.js +333 -0
- package/cjs/refs.js +214 -0
- package/cjs/resolve-external.js +333 -0
- package/cjs/resolvers/file.js +106 -0
- package/cjs/resolvers/http.js +184 -0
- package/cjs/util/errors.js +401 -0
- package/cjs/util/plugins.js +159 -0
- package/cjs/util/projectDir.cjs +6 -0
- package/cjs/util/url.js +228 -0
- package/lib/bundle.js +4 -6
- package/lib/dereference.js +5 -7
- package/lib/index.js +28 -21
- package/lib/normalize-args.js +2 -4
- package/lib/options.js +7 -9
- package/lib/parse.js +5 -7
- package/lib/parsers/binary.js +1 -3
- package/lib/parsers/json.js +2 -4
- package/lib/parsers/text.js +2 -4
- package/lib/parsers/yaml.js +4 -6
- package/lib/pointer.js +4 -6
- package/lib/ref.js +4 -6
- package/lib/refs.js +4 -8
- package/lib/resolve-external.js +6 -8
- package/lib/resolvers/file.js +5 -6
- package/lib/resolvers/http.js +4 -6
- package/lib/util/errors.js +14 -16
- package/lib/util/plugins.js +8 -10
- package/lib/util/projectDir.cjs +6 -0
- package/lib/util/url.js +29 -33
- package/package.json +17 -17
package/lib/resolvers/file.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { ResolverError } = require("../util/errors");
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { ono } from "@jsdevtools/ono";
|
|
3
|
+
import * as url from "../util/url.js";
|
|
4
|
+
import { ResolverError } from "../util/errors.js";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default {
|
|
8
7
|
/**
|
|
9
8
|
* The order that this resolver will run, in relation to other resolvers.
|
|
10
9
|
*
|
package/lib/resolvers/http.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { ono } from "@jsdevtools/ono";
|
|
2
|
+
import * as url from "../util/url.js";
|
|
3
|
+
import { ResolverError } from "../util/errors.js";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const url = require("../util/url");
|
|
5
|
-
const { ResolverError } = require("../util/errors");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
5
|
+
export default {
|
|
8
6
|
/**
|
|
9
7
|
* The order that this resolver will run, in relation to other resolvers.
|
|
10
8
|
*
|
package/lib/util/errors.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ono } from "@jsdevtools/ono";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { stripHash, toFileSystemPath } from "./url.js";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const JSONParserError = exports.JSONParserError = class JSONParserError extends Error {
|
|
5
|
+
export const JSONParserError = class JSONParserError extends Error {
|
|
8
6
|
constructor (message, source) {
|
|
9
7
|
super();
|
|
10
8
|
|
|
@@ -23,7 +21,7 @@ const JSONParserError = exports.JSONParserError = class JSONParserError extends
|
|
|
23
21
|
|
|
24
22
|
setErrorName(JSONParserError);
|
|
25
23
|
|
|
26
|
-
const JSONParserErrorGroup =
|
|
24
|
+
export const JSONParserErrorGroup = class JSONParserErrorGroup extends Error {
|
|
27
25
|
constructor (parser) {
|
|
28
26
|
super();
|
|
29
27
|
|
|
@@ -52,7 +50,7 @@ const JSONParserErrorGroup = exports.JSONParserErrorGroup = class JSONParserErro
|
|
|
52
50
|
|
|
53
51
|
setErrorName(JSONParserErrorGroup);
|
|
54
52
|
|
|
55
|
-
const ParserError =
|
|
53
|
+
export const ParserError = class ParserError extends JSONParserError {
|
|
56
54
|
constructor (message, source) {
|
|
57
55
|
super(`Error parsing ${source}: ${message}`, source);
|
|
58
56
|
|
|
@@ -62,7 +60,7 @@ const ParserError = exports.ParserError = class ParserError extends JSONParserEr
|
|
|
62
60
|
|
|
63
61
|
setErrorName(ParserError);
|
|
64
62
|
|
|
65
|
-
const UnmatchedParserError =
|
|
63
|
+
export const UnmatchedParserError = class UnmatchedParserError extends JSONParserError {
|
|
66
64
|
constructor (source) {
|
|
67
65
|
super(`Could not find parser for "${source}"`, source);
|
|
68
66
|
|
|
@@ -72,7 +70,7 @@ const UnmatchedParserError = exports.UnmatchedParserError = class UnmatchedParse
|
|
|
72
70
|
|
|
73
71
|
setErrorName(UnmatchedParserError);
|
|
74
72
|
|
|
75
|
-
const ResolverError =
|
|
73
|
+
export const ResolverError = class ResolverError extends JSONParserError {
|
|
76
74
|
constructor (ex, source) {
|
|
77
75
|
super(ex.message || `Error reading file "${source}"`, source);
|
|
78
76
|
|
|
@@ -86,7 +84,7 @@ const ResolverError = exports.ResolverError = class ResolverError extends JSONPa
|
|
|
86
84
|
|
|
87
85
|
setErrorName(ResolverError);
|
|
88
86
|
|
|
89
|
-
const UnmatchedResolverError =
|
|
87
|
+
export const UnmatchedResolverError = class UnmatchedResolverError extends JSONParserError {
|
|
90
88
|
constructor (source) {
|
|
91
89
|
super(`Could not find resolver for "${source}"`, source);
|
|
92
90
|
|
|
@@ -96,7 +94,7 @@ const UnmatchedResolverError = exports.UnmatchedResolverError = class UnmatchedR
|
|
|
96
94
|
|
|
97
95
|
setErrorName(UnmatchedResolverError);
|
|
98
96
|
|
|
99
|
-
const MissingPointerError =
|
|
97
|
+
export const MissingPointerError = class MissingPointerError extends JSONParserError {
|
|
100
98
|
constructor (token, path) {
|
|
101
99
|
super(`Token "${token}" does not exist.`, stripHash(path));
|
|
102
100
|
|
|
@@ -106,7 +104,7 @@ const MissingPointerError = exports.MissingPointerError = class MissingPointerEr
|
|
|
106
104
|
|
|
107
105
|
setErrorName(MissingPointerError);
|
|
108
106
|
|
|
109
|
-
const InvalidPointerError =
|
|
107
|
+
export const InvalidPointerError = class InvalidPointerError extends JSONParserError {
|
|
110
108
|
constructor (pointer, path) {
|
|
111
109
|
super(`Invalid $ref pointer "${pointer}". Pointers must begin with "#/"`, stripHash(path));
|
|
112
110
|
|
|
@@ -123,14 +121,14 @@ function setErrorName (err) {
|
|
|
123
121
|
});
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
|
|
124
|
+
export function isHandledError (err) {
|
|
127
125
|
return err instanceof JSONParserError || err instanceof JSONParserErrorGroup;
|
|
128
|
-
}
|
|
126
|
+
}
|
|
129
127
|
|
|
130
|
-
|
|
128
|
+
export function normalizeError (err) {
|
|
131
129
|
if (err.path === null) {
|
|
132
130
|
err.path = [];
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
return err;
|
|
136
|
-
}
|
|
134
|
+
}
|
package/lib/util/plugins.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Returns the given plugins as an array, rather than an object map.
|
|
5
3
|
* All other methods in this module expect an array of plugins rather than an object map.
|
|
@@ -7,7 +5,7 @@
|
|
|
7
5
|
* @param {object} plugins - A map of plugin objects
|
|
8
6
|
* @return {object[]}
|
|
9
7
|
*/
|
|
10
|
-
|
|
8
|
+
export function all (plugins) {
|
|
11
9
|
return Object.keys(plugins)
|
|
12
10
|
.filter((key) => {
|
|
13
11
|
return typeof plugins[key] === "object";
|
|
@@ -16,7 +14,7 @@ exports.all = function (plugins) {
|
|
|
16
14
|
plugins[key].name = key;
|
|
17
15
|
return plugins[key];
|
|
18
16
|
});
|
|
19
|
-
}
|
|
17
|
+
}
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Filters the given plugins, returning only the ones return `true` for the given method.
|
|
@@ -26,12 +24,12 @@ exports.all = function (plugins) {
|
|
|
26
24
|
* @param {object} file - A file info object, which will be passed to each method
|
|
27
25
|
* @return {object[]}
|
|
28
26
|
*/
|
|
29
|
-
|
|
27
|
+
export function filter (plugins, method, file) {
|
|
30
28
|
return plugins
|
|
31
29
|
.filter((plugin) => {
|
|
32
30
|
return !!getResult(plugin, method, file);
|
|
33
31
|
});
|
|
34
|
-
}
|
|
32
|
+
}
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* Sorts the given plugins, in place, by their `order` property.
|
|
@@ -39,13 +37,13 @@ exports.filter = function (plugins, method, file) {
|
|
|
39
37
|
* @param {object[]} plugins - An array of plugin objects
|
|
40
38
|
* @returns {object[]}
|
|
41
39
|
*/
|
|
42
|
-
|
|
40
|
+
export function sort (plugins) {
|
|
43
41
|
for (let plugin of plugins) {
|
|
44
42
|
plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
return plugins.sort((a, b) => { return a.order - b.order; });
|
|
48
|
-
}
|
|
46
|
+
}
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* Runs the specified method of the given plugins, in order, until one of them returns a successful result.
|
|
@@ -60,7 +58,7 @@ exports.sort = function (plugins) {
|
|
|
60
58
|
* @param {object} file - A file info object, which will be passed to each method
|
|
61
59
|
* @returns {Promise}
|
|
62
60
|
*/
|
|
63
|
-
|
|
61
|
+
export function run (plugins, method, file, $refs) {
|
|
64
62
|
let plugin, lastError, index = 0;
|
|
65
63
|
|
|
66
64
|
return new Promise(((resolve, reject) => {
|
|
@@ -119,7 +117,7 @@ exports.run = function (plugins, method, file, $refs) {
|
|
|
119
117
|
runNextPlugin();
|
|
120
118
|
}
|
|
121
119
|
}));
|
|
122
|
-
}
|
|
120
|
+
}
|
|
123
121
|
|
|
124
122
|
/**
|
|
125
123
|
* Returns the value of the given property.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const nodePath = require("path");
|
|
2
|
+
|
|
3
|
+
// Webpack 4 (used by browser tests) can't transpile import.meta.url
|
|
4
|
+
// So export the project directory using __dirname from a .cjs module
|
|
5
|
+
const projectDir = nodePath.resolve(__dirname, "..", "..");
|
|
6
|
+
module.exports = projectDir
|
package/lib/util/url.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const nodePath = require("path");
|
|
4
|
-
const projectDir = nodePath.resolve(__dirname, "..", "..");
|
|
1
|
+
import projectDir from "./projectDir.cjs";
|
|
5
2
|
|
|
6
3
|
let isWindows = /^win/.test(globalThis.process ? globalThis.process.platform : undefined),
|
|
7
4
|
forwardSlashPattern = /\//g,
|
|
8
5
|
protocolPattern = /^(\w{2,}):\/\//i,
|
|
9
|
-
url = module.exports,
|
|
10
6
|
jsonPointerSlash = /~1/g,
|
|
11
7
|
jsonPointerTilde = /~0/g;
|
|
12
8
|
|
|
@@ -25,14 +21,14 @@ let urlDecodePatterns = [
|
|
|
25
21
|
/\%40/g, "@"
|
|
26
22
|
];
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
export const parse = (u) => new URL(u);
|
|
29
25
|
|
|
30
26
|
/**
|
|
31
27
|
* Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
|
|
32
28
|
*
|
|
33
29
|
* @return {string}
|
|
34
30
|
*/
|
|
35
|
-
|
|
31
|
+
export function resolve (from, to) {
|
|
36
32
|
let resolvedUrl = new URL(to, new URL(from, "resolve://"));
|
|
37
33
|
if (resolvedUrl.protocol === "resolve:") {
|
|
38
34
|
// `from` is a relative URL.
|
|
@@ -40,14 +36,14 @@ exports.resolve = function resolve (from, to) {
|
|
|
40
36
|
return pathname + search + hash;
|
|
41
37
|
}
|
|
42
38
|
return resolvedUrl.toString();
|
|
43
|
-
}
|
|
39
|
+
}
|
|
44
40
|
|
|
45
41
|
/**
|
|
46
42
|
* Returns the current working directory (in Node) or the current page URL (in browsers).
|
|
47
43
|
*
|
|
48
44
|
* @returns {string}
|
|
49
45
|
*/
|
|
50
|
-
|
|
46
|
+
export function cwd () {
|
|
51
47
|
if (typeof window !== "undefined") {
|
|
52
48
|
return location.href;
|
|
53
49
|
}
|
|
@@ -61,7 +57,7 @@ exports.cwd = function cwd () {
|
|
|
61
57
|
else {
|
|
62
58
|
return path + "/";
|
|
63
59
|
}
|
|
64
|
-
}
|
|
60
|
+
}
|
|
65
61
|
|
|
66
62
|
/**
|
|
67
63
|
* Returns the protocol of the given URL, or `undefined` if it has no protocol.
|
|
@@ -69,12 +65,12 @@ exports.cwd = function cwd () {
|
|
|
69
65
|
* @param {string} path
|
|
70
66
|
* @returns {?string}
|
|
71
67
|
*/
|
|
72
|
-
|
|
68
|
+
export function getProtocol (path) {
|
|
73
69
|
let match = protocolPattern.exec(path);
|
|
74
70
|
if (match) {
|
|
75
71
|
return match[1].toLowerCase();
|
|
76
72
|
}
|
|
77
|
-
}
|
|
73
|
+
}
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
76
|
* Returns the lowercased file extension of the given URL,
|
|
@@ -83,13 +79,13 @@ exports.getProtocol = function getProtocol (path) {
|
|
|
83
79
|
* @param {string} path
|
|
84
80
|
* @returns {string}
|
|
85
81
|
*/
|
|
86
|
-
|
|
82
|
+
export function getExtension (path) {
|
|
87
83
|
let lastDot = path.lastIndexOf(".");
|
|
88
84
|
if (lastDot >= 0) {
|
|
89
|
-
return
|
|
85
|
+
return stripQuery(path.substr(lastDot).toLowerCase());
|
|
90
86
|
}
|
|
91
87
|
return "";
|
|
92
|
-
}
|
|
88
|
+
}
|
|
93
89
|
|
|
94
90
|
/**
|
|
95
91
|
* Removes the query, if any, from the given path.
|
|
@@ -97,13 +93,13 @@ exports.getExtension = function getExtension (path) {
|
|
|
97
93
|
* @param {string} path
|
|
98
94
|
* @returns {string}
|
|
99
95
|
*/
|
|
100
|
-
|
|
96
|
+
export function stripQuery (path) {
|
|
101
97
|
let queryIndex = path.indexOf("?");
|
|
102
98
|
if (queryIndex >= 0) {
|
|
103
99
|
path = path.substr(0, queryIndex);
|
|
104
100
|
}
|
|
105
101
|
return path;
|
|
106
|
-
}
|
|
102
|
+
}
|
|
107
103
|
|
|
108
104
|
/**
|
|
109
105
|
* Returns the hash (URL fragment), of the given path.
|
|
@@ -112,13 +108,13 @@ exports.stripQuery = function stripQuery (path) {
|
|
|
112
108
|
* @param {string} path
|
|
113
109
|
* @returns {string}
|
|
114
110
|
*/
|
|
115
|
-
|
|
111
|
+
export function getHash (path) {
|
|
116
112
|
let hashIndex = path.indexOf("#");
|
|
117
113
|
if (hashIndex >= 0) {
|
|
118
114
|
return path.substr(hashIndex);
|
|
119
115
|
}
|
|
120
116
|
return "#";
|
|
121
|
-
}
|
|
117
|
+
}
|
|
122
118
|
|
|
123
119
|
/**
|
|
124
120
|
* Removes the hash (URL fragment), if any, from the given path.
|
|
@@ -126,13 +122,13 @@ exports.getHash = function getHash (path) {
|
|
|
126
122
|
* @param {string} path
|
|
127
123
|
* @returns {string}
|
|
128
124
|
*/
|
|
129
|
-
|
|
125
|
+
export function stripHash (path) {
|
|
130
126
|
let hashIndex = path.indexOf("#");
|
|
131
127
|
if (hashIndex >= 0) {
|
|
132
128
|
path = path.substr(0, hashIndex);
|
|
133
129
|
}
|
|
134
130
|
return path;
|
|
135
|
-
}
|
|
131
|
+
}
|
|
136
132
|
|
|
137
133
|
/**
|
|
138
134
|
* Determines whether the given path is an HTTP(S) URL.
|
|
@@ -140,8 +136,8 @@ exports.stripHash = function stripHash (path) {
|
|
|
140
136
|
* @param {string} path
|
|
141
137
|
* @returns {boolean}
|
|
142
138
|
*/
|
|
143
|
-
|
|
144
|
-
let protocol =
|
|
139
|
+
export function isHttp (path) {
|
|
140
|
+
let protocol = getProtocol(path);
|
|
145
141
|
if (protocol === "http" || protocol === "https") {
|
|
146
142
|
return true;
|
|
147
143
|
}
|
|
@@ -153,7 +149,7 @@ exports.isHttp = function isHttp (path) {
|
|
|
153
149
|
// It's some other protocol, such as "ftp://", "mongodb://", etc.
|
|
154
150
|
return false;
|
|
155
151
|
}
|
|
156
|
-
}
|
|
152
|
+
}
|
|
157
153
|
|
|
158
154
|
/**
|
|
159
155
|
* Determines whether the given path is a filesystem path.
|
|
@@ -162,16 +158,16 @@ exports.isHttp = function isHttp (path) {
|
|
|
162
158
|
* @param {string} path
|
|
163
159
|
* @returns {boolean}
|
|
164
160
|
*/
|
|
165
|
-
|
|
161
|
+
export function isFileSystemPath (path) {
|
|
166
162
|
if (process.browser) {
|
|
167
163
|
// We're running in a browser, so assume that all paths are URLs.
|
|
168
164
|
// This way, even relative paths will be treated as URLs rather than as filesystem paths
|
|
169
165
|
return false;
|
|
170
166
|
}
|
|
171
167
|
|
|
172
|
-
let protocol =
|
|
168
|
+
let protocol = getProtocol(path);
|
|
173
169
|
return protocol === undefined || protocol === "file";
|
|
174
|
-
}
|
|
170
|
+
}
|
|
175
171
|
|
|
176
172
|
/**
|
|
177
173
|
* Converts a filesystem path to a properly-encoded URL.
|
|
@@ -189,7 +185,7 @@ exports.isFileSystemPath = function isFileSystemPath (path) {
|
|
|
189
185
|
* @param {string} path
|
|
190
186
|
* @returns {string}
|
|
191
187
|
*/
|
|
192
|
-
|
|
188
|
+
export function fromFileSystemPath (path) {
|
|
193
189
|
// Step 1: On Windows, replace backslashes with forward slashes,
|
|
194
190
|
// rather than encoding them as "%5C"
|
|
195
191
|
if (isWindows) {
|
|
@@ -214,7 +210,7 @@ exports.fromFileSystemPath = function fromFileSystemPath (path) {
|
|
|
214
210
|
}
|
|
215
211
|
|
|
216
212
|
return path;
|
|
217
|
-
}
|
|
213
|
+
}
|
|
218
214
|
|
|
219
215
|
/**
|
|
220
216
|
* Converts a URL to a local filesystem path.
|
|
@@ -223,7 +219,7 @@ exports.fromFileSystemPath = function fromFileSystemPath (path) {
|
|
|
223
219
|
* @param {boolean} [keepFileProtocol] - If true, then "file://" will NOT be stripped
|
|
224
220
|
* @returns {string}
|
|
225
221
|
*/
|
|
226
|
-
|
|
222
|
+
export function toFileSystemPath (path, keepFileProtocol) {
|
|
227
223
|
// Step 1: `decodeURI` will decode characters such as Cyrillic characters, spaces, etc.
|
|
228
224
|
path = decodeURI(path);
|
|
229
225
|
|
|
@@ -271,7 +267,7 @@ exports.toFileSystemPath = function toFileSystemPath (path, keepFileProtocol) {
|
|
|
271
267
|
}
|
|
272
268
|
|
|
273
269
|
return path;
|
|
274
|
-
}
|
|
270
|
+
}
|
|
275
271
|
|
|
276
272
|
/**
|
|
277
273
|
* Converts a $ref pointer to a valid JSON Path.
|
|
@@ -279,7 +275,7 @@ exports.toFileSystemPath = function toFileSystemPath (path, keepFileProtocol) {
|
|
|
279
275
|
* @param {string} pointer
|
|
280
276
|
* @returns {Array<number | string>}
|
|
281
277
|
*/
|
|
282
|
-
|
|
278
|
+
export function safePointerToPath (pointer) {
|
|
283
279
|
if (pointer.length <= 1 || pointer[0] !== "#" || pointer[1] !== "/") {
|
|
284
280
|
return [];
|
|
285
281
|
}
|
|
@@ -292,4 +288,4 @@ exports.safePointerToPath = function safePointerToPath (pointer) {
|
|
|
292
288
|
.replace(jsonPointerSlash, "/")
|
|
293
289
|
.replace(jsonPointerTilde, "~");
|
|
294
290
|
});
|
|
295
|
-
}
|
|
291
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apidevtools/json-schema-ref-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"funding": "https://github.com/sponsors/philsturgeon",
|
|
40
40
|
"main": "lib/index.js",
|
|
41
41
|
"typings": "lib/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
"types": "./lib/index.d.ts",
|
|
44
|
+
"require": "./cjs/index.js",
|
|
45
|
+
"default": "./lib/index.js"
|
|
46
|
+
},
|
|
42
47
|
"browser": {
|
|
43
48
|
"fs": false
|
|
44
49
|
},
|
|
@@ -46,18 +51,20 @@
|
|
|
46
51
|
"node": ">= 17"
|
|
47
52
|
},
|
|
48
53
|
"files": [
|
|
49
|
-
"lib"
|
|
54
|
+
"lib",
|
|
55
|
+
"cjs"
|
|
50
56
|
],
|
|
57
|
+
"type": "module",
|
|
51
58
|
"scripts": {
|
|
52
|
-
"build": "
|
|
53
|
-
"clean": "shx rm -rf
|
|
59
|
+
"build": "swc ./lib/*.js -d ./cjs && swc ./lib/**/*.js -d ./cjs && copyfiles ./lib/**/*.cjs -u 1 ./cjs && node ./scripts/writeCJSPackageJSON.cjs",
|
|
60
|
+
"clean": "shx rm -rf coverage cjs",
|
|
54
61
|
"lint": "eslint lib test/fixtures test/specs",
|
|
55
62
|
"test": "npm run test:node && npm run test:typescript && npm run test:browser && npm run lint",
|
|
56
63
|
"test:node": "mocha",
|
|
57
|
-
"test:browser": "cross-env NODE_OPTIONS=--openssl-legacy-provider karma start --single-run",
|
|
64
|
+
"test:browser": "cross-env NODE_OPTIONS=--openssl-legacy-provider karma start karma.conf.cjs --single-run",
|
|
58
65
|
"test:typescript": "tsc --noEmit --strict --lib esnext,dom test/specs/typescript-definition.spec.ts",
|
|
59
66
|
"coverage": "npm run coverage:node && npm run coverage:browser",
|
|
60
|
-
"coverage:node": "
|
|
67
|
+
"coverage:node": "c8 node_modules/mocha/bin/mocha",
|
|
61
68
|
"coverage:browser": "npm run test:browser -- --coverage",
|
|
62
69
|
"upgrade": "npm-check -u && npm audit fix"
|
|
63
70
|
},
|
|
@@ -67,10 +74,14 @@
|
|
|
67
74
|
"@jsdevtools/eslint-config": "^1.0.7",
|
|
68
75
|
"@jsdevtools/host-environment": "^2.1.2",
|
|
69
76
|
"@jsdevtools/karma-config": "^3.1.7",
|
|
77
|
+
"@swc/cli": "^0.1.59",
|
|
78
|
+
"@swc/core": "^1.3.25",
|
|
70
79
|
"@types/node": "^14.14.21",
|
|
80
|
+
"c8": "^7.12.0",
|
|
71
81
|
"chai": "^4.2.0",
|
|
72
82
|
"chai-subset": "^1.6.0",
|
|
73
83
|
"chokidar": "^3.5.3",
|
|
84
|
+
"copyfiles": "^2.4.1",
|
|
74
85
|
"cross-env": "^7.0.3",
|
|
75
86
|
"eslint": "^7.18.0",
|
|
76
87
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -79,8 +90,6 @@
|
|
|
79
90
|
"mocha": "^8.2.1",
|
|
80
91
|
"node-abort-controller": "^3.0.1",
|
|
81
92
|
"npm-check": "^5.9.0",
|
|
82
|
-
"nyc": "^15.0.1",
|
|
83
|
-
"semantic-release-plugin-update-version-in-files": "^1.1.0",
|
|
84
93
|
"shx": "^0.3.2",
|
|
85
94
|
"typescript": "^4.0.5"
|
|
86
95
|
},
|
|
@@ -97,15 +106,6 @@
|
|
|
97
106
|
"plugins": [
|
|
98
107
|
"@semantic-release/commit-analyzer",
|
|
99
108
|
"@semantic-release/release-notes-generator",
|
|
100
|
-
[
|
|
101
|
-
"semantic-release-plugin-update-version-in-files",
|
|
102
|
-
{
|
|
103
|
-
"files": [
|
|
104
|
-
"dist/package.json"
|
|
105
|
-
],
|
|
106
|
-
"placeholder": "X.X.X"
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
109
|
"@semantic-release/npm",
|
|
110
110
|
"@semantic-release/github"
|
|
111
111
|
]
|