@handlewithcare/react-prosemirror 2.8.0-tiptap.10 → 2.8.0-tiptap.12
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/dist/cjs/tiptap/TiptapEditorView.js +2 -1
- package/dist/cjs/tiptap/tiptapNodeView.js +26 -13
- package/dist/esm/tiptap/TiptapEditorView.js +2 -1
- package/dist/esm/tiptap/tiptapNodeView.js +27 -14
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/props.d.ts +26 -26
- package/dist/types/tiptap/TiptapEditorView.d.ts +2 -1
- package/package.json +1 -1
- package/dist/esm/@jest/pattern/src/__tests__/TestPathPatterns.test.js +0 -241
- package/dist/esm/@swc/cli/lib/swc/__tests__/compile.test.js +0 -19
- package/dist/esm/@swc/cli/lib/swc/__tests__/options.test.js +0 -315
- package/dist/esm/@swc/cli/lib/swc/__tests__/sources.test.js +0 -161
- package/dist/esm/@uiw/react-codemirror/src/__tests__/index.test.js +0 -111
- package/dist/esm/cheerio/src/__tests__/deprecated.spec.js +0 -249
- package/dist/esm/cheerio/src/__tests__/xml.spec.js +0 -55
- package/dist/esm/components/__tests__/ProseMirror.composition.test.js +0 -395
- package/dist/esm/components/__tests__/ProseMirror.domchange.test.js +0 -266
- package/dist/esm/components/__tests__/ProseMirror.draw-decoration.test.js +0 -968
- package/dist/esm/components/__tests__/ProseMirror.draw.test.js +0 -335
- package/dist/esm/components/__tests__/ProseMirror.mobile.test.js +0 -54
- package/dist/esm/components/__tests__/ProseMirror.node-view.test.js +0 -553
- package/dist/esm/components/__tests__/ProseMirror.selection.test.js +0 -440
- package/dist/esm/components/__tests__/ProseMirror.test.js +0 -324
- package/dist/esm/contexts/__tests__/DeferredLayoutEffects.test.js +0 -98
- package/dist/esm/hooks/__tests__/useEditorEffect.test.js +0 -134
- package/dist/esm/jsx-ast-utils/__tests__/helper.js +0 -83
- package/dist/esm/jsx-ast-utils/__tests__/src/elementType-test.js +0 -76
- package/dist/esm/jsx-ast-utils/__tests__/src/eventHandlers-test.js +0 -98
- package/dist/esm/jsx-ast-utils/__tests__/src/getProp-parser-test.js +0 -188
- package/dist/esm/jsx-ast-utils/__tests__/src/getProp-test.js +0 -119
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropLiteralValue-babelparser-test.js +0 -393
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropLiteralValue-flowparser-test.js +0 -379
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropValue-babelparser-test.js +0 -925
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropValue-flowparser-test.js +0 -700
- package/dist/esm/jsx-ast-utils/__tests__/src/hasProp-test.js +0 -350
- package/dist/esm/jsx-ast-utils/__tests__/src/index-test.js +0 -24
- package/dist/esm/jsx-ast-utils/__tests__/src/propName-test.js +0 -37
- package/dist/esm/plugins/__tests__/reactKeys.test.js +0 -77
- package/dist/esm/tsconfig-paths/lib/__tests__/config-loader.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/config-loader.test.js +0 -97
- package/dist/esm/tsconfig-paths/lib/__tests__/data/match-path-data.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/data/match-path-data.js +0 -319
- package/dist/esm/tsconfig-paths/lib/__tests__/filesystem.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/filesystem.test.js +0 -62
- package/dist/esm/tsconfig-paths/lib/__tests__/mapping-entry.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/mapping-entry.test.js +0 -80
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-async.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-async.test.js +0 -22
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-sync.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-sync.test.js +0 -20
- package/dist/esm/tsconfig-paths/lib/__tests__/try-path.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/try-path.test.js +0 -219
- package/dist/esm/tsconfig-paths/lib/__tests__/tsconfig-loader.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js +0 -323
- package/dist/esm/tsconfig-paths/src/__tests__/config-loader.test.js +0 -89
- package/dist/esm/tsconfig-paths/src/__tests__/data/match-path-data.js +0 -314
- package/dist/esm/tsconfig-paths/src/__tests__/filesystem.test.js +0 -58
- package/dist/esm/tsconfig-paths/src/__tests__/mapping-entry.test.js +0 -76
- package/dist/esm/tsconfig-paths/src/__tests__/match-path-async.test.js +0 -12
- package/dist/esm/tsconfig-paths/src/__tests__/match-path-sync.test.js +0 -10
- package/dist/esm/tsconfig-paths/src/__tests__/try-path.test.js +0 -214
- package/dist/esm/tsconfig-paths/src/__tests__/tsconfig-loader.test.js +0 -296
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
var try_path_1 = require("../try-path");
|
|
6
|
-
var path_1 = require("path");
|
|
7
|
-
describe("mapping-entry", function() {
|
|
8
|
-
var abosolutePathMappings = [
|
|
9
|
-
{
|
|
10
|
-
pattern: "longest/pre/fix/*",
|
|
11
|
-
paths: [
|
|
12
|
-
(0, path_1.join)("/absolute", "base", "url", "foo2", "bar")
|
|
13
|
-
]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
pattern: "pre/fix/*",
|
|
17
|
-
paths: [
|
|
18
|
-
(0, path_1.join)("/absolute", "base", "url", "foo3")
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
pattern: "*",
|
|
23
|
-
paths: [
|
|
24
|
-
(0, path_1.join)("/absolute", "base", "url", "foo1")
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
var abosolutePathMappingsStarstWithSlash = [
|
|
29
|
-
{
|
|
30
|
-
pattern: "/opt/*",
|
|
31
|
-
paths: [
|
|
32
|
-
(0, path_1.join)("/absolute", "src", "aws-layer")
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
pattern: "*",
|
|
37
|
-
paths: [
|
|
38
|
-
(0, path_1.join)("/absolute", "src")
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
it("should return no paths for relative requested module", function() {
|
|
43
|
-
var result = (0, try_path_1.getPathsToTry)([
|
|
44
|
-
".ts",
|
|
45
|
-
"tsx"
|
|
46
|
-
], abosolutePathMappings, "./requested-module");
|
|
47
|
-
// assert.deepEqual(result, undefined);
|
|
48
|
-
expect(result).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
it("should return no paths if no pattern match the requested module", function() {
|
|
51
|
-
var result = (0, try_path_1.getPathsToTry)([
|
|
52
|
-
".ts",
|
|
53
|
-
"tsx"
|
|
54
|
-
], [
|
|
55
|
-
{
|
|
56
|
-
pattern: "longest/pre/fix/*",
|
|
57
|
-
paths: [
|
|
58
|
-
(0, path_1.join)("/absolute", "base", "url", "foo2", "bar")
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
pattern: "pre/fix/*",
|
|
63
|
-
paths: [
|
|
64
|
-
(0, path_1.join)("/absolute", "base", "url", "foo3")
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
], "requested-module");
|
|
68
|
-
expect(result).toBeUndefined();
|
|
69
|
-
});
|
|
70
|
-
it("should get all paths that matches requested module", function() {
|
|
71
|
-
var result = (0, try_path_1.getPathsToTry)([
|
|
72
|
-
".ts",
|
|
73
|
-
".tsx"
|
|
74
|
-
], abosolutePathMappings, "longest/pre/fix/requested-module");
|
|
75
|
-
// assert.deepEqual(result, [
|
|
76
|
-
// // "longest/pre/fix/*"
|
|
77
|
-
// { type: "file", path: join("/absolute", "base", "url", "foo2", "bar") },
|
|
78
|
-
// {
|
|
79
|
-
// type: "extension",
|
|
80
|
-
// path: join("/absolute", "base", "url", "foo2", "bar.ts"),
|
|
81
|
-
// },
|
|
82
|
-
// {
|
|
83
|
-
// type: "extension",
|
|
84
|
-
// path: join("/absolute", "base", "url", "foo2", "bar.tsx"),
|
|
85
|
-
// },
|
|
86
|
-
// {
|
|
87
|
-
// type: "package",
|
|
88
|
-
// path: join("/absolute", "base", "url", "foo2", "bar", "package.json"),
|
|
89
|
-
// },
|
|
90
|
-
// {
|
|
91
|
-
// type: "index",
|
|
92
|
-
// path: join("/absolute", "base", "url", "foo2", "bar", "index.ts"),
|
|
93
|
-
// },
|
|
94
|
-
// {
|
|
95
|
-
// type: "index",
|
|
96
|
-
// path: join("/absolute", "base", "url", "foo2", "bar", "index.tsx"),
|
|
97
|
-
// },
|
|
98
|
-
// // "*"
|
|
99
|
-
// { type: "file", path: join("/absolute", "base", "url", "foo1") },
|
|
100
|
-
// { type: "extension", path: join("/absolute", "base", "url", "foo1.ts") },
|
|
101
|
-
// { type: "extension", path: join("/absolute", "base", "url", "foo1.tsx") },
|
|
102
|
-
// {
|
|
103
|
-
// type: "package",
|
|
104
|
-
// path: join("/absolute", "base", "url", "foo1", "package.json"),
|
|
105
|
-
// },
|
|
106
|
-
// {
|
|
107
|
-
// type: "index",
|
|
108
|
-
// path: join("/absolute", "base", "url", "foo1", "index.ts"),
|
|
109
|
-
// },
|
|
110
|
-
// {
|
|
111
|
-
// type: "index",
|
|
112
|
-
// path: join("/absolute", "base", "url", "foo1", "index.tsx"),
|
|
113
|
-
// },
|
|
114
|
-
// ]);
|
|
115
|
-
expect(result).toEqual([
|
|
116
|
-
// "longest/pre/fix/*"
|
|
117
|
-
{
|
|
118
|
-
type: "file",
|
|
119
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar")
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
type: "extension",
|
|
123
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar.ts")
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
type: "extension",
|
|
127
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar.tsx")
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
type: "package",
|
|
131
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar", "package.json")
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
type: "index",
|
|
135
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar", "index.ts")
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
type: "index",
|
|
139
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo2", "bar", "index.tsx")
|
|
140
|
-
},
|
|
141
|
-
// "*"
|
|
142
|
-
{
|
|
143
|
-
type: "file",
|
|
144
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1")
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
type: "extension",
|
|
148
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1.ts")
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
type: "extension",
|
|
152
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1.tsx")
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
type: "package",
|
|
156
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1", "package.json")
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
type: "index",
|
|
160
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1", "index.ts")
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
type: "index",
|
|
164
|
-
path: (0, path_1.join)("/absolute", "base", "url", "foo1", "index.tsx")
|
|
165
|
-
}
|
|
166
|
-
]);
|
|
167
|
-
});
|
|
168
|
-
it("should resolve paths starting with a slash", function() {
|
|
169
|
-
var result = (0, try_path_1.getPathsToTry)([
|
|
170
|
-
".ts"
|
|
171
|
-
], abosolutePathMappingsStarstWithSlash, "/opt/utils");
|
|
172
|
-
expect(result).toEqual([
|
|
173
|
-
// "opt/*"
|
|
174
|
-
{
|
|
175
|
-
path: (0, path_1.join)("/absolute", "src", "aws-layer"),
|
|
176
|
-
type: "file"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
path: (0, path_1.join)("/absolute", "src", "aws-layer.ts"),
|
|
180
|
-
type: "extension"
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
path: (0, path_1.join)("/absolute", "src", "aws-layer", "package.json"),
|
|
184
|
-
type: "package"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
path: (0, path_1.join)("/absolute", "src", "aws-layer", "index.ts"),
|
|
188
|
-
type: "index"
|
|
189
|
-
},
|
|
190
|
-
// "*"
|
|
191
|
-
{
|
|
192
|
-
path: (0, path_1.join)("/absolute", "src"),
|
|
193
|
-
type: "file"
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
path: (0, path_1.join)("/absolute", "src.ts"),
|
|
197
|
-
type: "extension"
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
path: (0, path_1.join)("/absolute", "src", "package.json"),
|
|
201
|
-
type: "package"
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
path: (0, path_1.join)("/absolute", "src", "index.ts"),
|
|
205
|
-
type: "index"
|
|
206
|
-
}
|
|
207
|
-
]);
|
|
208
|
-
});
|
|
209
|
-
}); // describe("match-star", () => {
|
|
210
|
-
// it("should match star in last position", () => {
|
|
211
|
-
// const result = matchStar("lib/*", "lib/mylib");
|
|
212
|
-
// assert.equal(result, "mylib");
|
|
213
|
-
// });
|
|
214
|
-
// it("should match star in first position", () => {
|
|
215
|
-
// const result = matchStar("*/lib", "mylib/lib");
|
|
216
|
-
// assert.equal(result, "mylib");
|
|
217
|
-
// });
|
|
218
|
-
// });
|
|
219
|
-
//# sourceMappingURL=try-path.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
var tsconfig_loader_1 = require("../tsconfig-loader");
|
|
6
|
-
var path_1 = require("path");
|
|
7
|
-
describe("tsconfig-loader", function() {
|
|
8
|
-
it("should find tsconfig in cwd", function() {
|
|
9
|
-
var result = (0, tsconfig_loader_1.tsConfigLoader)({
|
|
10
|
-
cwd: "/foo/bar",
|
|
11
|
-
getEnv: function(_) {
|
|
12
|
-
return undefined;
|
|
13
|
-
},
|
|
14
|
-
loadSync: function(cwd) {
|
|
15
|
-
return {
|
|
16
|
-
tsConfigPath: "".concat(cwd, "/tsconfig.json"),
|
|
17
|
-
baseUrl: "./",
|
|
18
|
-
paths: {}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
// assert.equal(result.tsConfigPath, "/foo/bar/tsconfig.json");
|
|
23
|
-
expect(result.tsConfigPath).toBe("/foo/bar/tsconfig.json");
|
|
24
|
-
});
|
|
25
|
-
it("should return loaderResult.tsConfigPath as undefined when not found", function() {
|
|
26
|
-
var result = (0, tsconfig_loader_1.tsConfigLoader)({
|
|
27
|
-
cwd: "/foo/bar",
|
|
28
|
-
getEnv: function(_) {
|
|
29
|
-
return undefined;
|
|
30
|
-
},
|
|
31
|
-
loadSync: function(_) {
|
|
32
|
-
return {
|
|
33
|
-
tsConfigPath: undefined,
|
|
34
|
-
baseUrl: "./",
|
|
35
|
-
paths: {}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// assert.isUndefined(result.tsConfigPath);
|
|
40
|
-
expect(result.tsConfigPath).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
it("should use TS_NODE_PROJECT env if exists", function() {
|
|
43
|
-
var result = (0, tsconfig_loader_1.tsConfigLoader)({
|
|
44
|
-
cwd: "/foo/bar",
|
|
45
|
-
getEnv: function(key) {
|
|
46
|
-
return key === "TS_NODE_PROJECT" ? "/foo/baz" : undefined;
|
|
47
|
-
},
|
|
48
|
-
loadSync: function(cwd, fileName) {
|
|
49
|
-
if (cwd === "/foo/bar" && fileName === "/foo/baz") {
|
|
50
|
-
return {
|
|
51
|
-
tsConfigPath: "/foo/baz/tsconfig.json",
|
|
52
|
-
baseUrl: "./",
|
|
53
|
-
paths: {}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
tsConfigPath: undefined,
|
|
58
|
-
baseUrl: "./",
|
|
59
|
-
paths: {}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
// assert.equal(result.tsConfigPath, "/foo/baz/tsconfig.json");
|
|
64
|
-
expect(result.tsConfigPath).toBe("/foo/baz/tsconfig.json");
|
|
65
|
-
});
|
|
66
|
-
it("should use TS_NODE_BASEURL env if exists", function() {
|
|
67
|
-
var result = (0, tsconfig_loader_1.tsConfigLoader)({
|
|
68
|
-
cwd: "/foo/bar",
|
|
69
|
-
getEnv: function(key) {
|
|
70
|
-
return key === "TS_NODE_BASEURL" ? "SOME_BASEURL" : undefined;
|
|
71
|
-
},
|
|
72
|
-
loadSync: function(_0, _1, baseUrl) {
|
|
73
|
-
return {
|
|
74
|
-
tsConfigPath: undefined,
|
|
75
|
-
baseUrl: baseUrl,
|
|
76
|
-
paths: {}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
// assert.equal(result.baseUrl, "SOME_BASEURL");
|
|
81
|
-
expect(result.baseUrl).toBe("SOME_BASEURL");
|
|
82
|
-
});
|
|
83
|
-
it("should not use TS_NODE_BASEURL env if it does not exist", function() {
|
|
84
|
-
var result = (0, tsconfig_loader_1.tsConfigLoader)({
|
|
85
|
-
cwd: "/foo/bar",
|
|
86
|
-
getEnv: function(_) {
|
|
87
|
-
return undefined;
|
|
88
|
-
},
|
|
89
|
-
loadSync: function(_0, _1, baseUrl) {
|
|
90
|
-
return {
|
|
91
|
-
tsConfigPath: undefined,
|
|
92
|
-
baseUrl: baseUrl,
|
|
93
|
-
paths: {}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
// assert.equal(result.baseUrl, undefined);
|
|
98
|
-
expect(result.baseUrl).toBeUndefined();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe("walkForTsConfig", function() {
|
|
102
|
-
it("should find tsconfig in starting directory", function() {
|
|
103
|
-
var pathToTsconfig = (0, path_1.join)("/root", "dir1", "tsconfig.json");
|
|
104
|
-
var res = (0, tsconfig_loader_1.walkForTsConfig)((0, path_1.join)("/root", "dir1"), function(path) {
|
|
105
|
-
return path === pathToTsconfig;
|
|
106
|
-
});
|
|
107
|
-
// assert.equal(res, pathToTsconfig);
|
|
108
|
-
expect(res).toBe(pathToTsconfig);
|
|
109
|
-
});
|
|
110
|
-
it("should find tsconfig in parent directory", function() {
|
|
111
|
-
var pathToTsconfig = (0, path_1.join)("/root", "tsconfig.json");
|
|
112
|
-
var res = (0, tsconfig_loader_1.walkForTsConfig)((0, path_1.join)("/root", "dir1"), function(path) {
|
|
113
|
-
return path === pathToTsconfig;
|
|
114
|
-
});
|
|
115
|
-
// assert.equal(res, pathToTsconfig);
|
|
116
|
-
expect(res).toBe(pathToTsconfig);
|
|
117
|
-
});
|
|
118
|
-
it("should return undefined when reaching the top", function() {
|
|
119
|
-
var res = (0, tsconfig_loader_1.walkForTsConfig)((0, path_1.join)("/root", "dir1", "kalle"), function() {
|
|
120
|
-
return false;
|
|
121
|
-
});
|
|
122
|
-
// assert.equal(res, undefined);
|
|
123
|
-
expect(res).toBeUndefined();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
describe("loadConfig", function() {
|
|
127
|
-
it("It should load a config", function() {
|
|
128
|
-
var config = {
|
|
129
|
-
compilerOptions: {
|
|
130
|
-
baseUrl: "hej"
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function(path) {
|
|
134
|
-
return path === "/root/dir1/tsconfig.json";
|
|
135
|
-
}, function(_) {
|
|
136
|
-
return JSON.stringify(config);
|
|
137
|
-
});
|
|
138
|
-
// assert.deepEqual(res, config);
|
|
139
|
-
expect(res).toStrictEqual(config);
|
|
140
|
-
});
|
|
141
|
-
it("It should load a config with comments", function() {
|
|
142
|
-
var config = {
|
|
143
|
-
compilerOptions: {
|
|
144
|
-
baseUrl: "hej"
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function(path) {
|
|
148
|
-
return path === "/root/dir1/tsconfig.json";
|
|
149
|
-
}, function(_) {
|
|
150
|
-
return "{\n // my comment\n \"compilerOptions\": { \n \"baseUrl\": \"hej\"\n }\n }";
|
|
151
|
-
});
|
|
152
|
-
// assert.deepEqual(res, config);
|
|
153
|
-
expect(res).toStrictEqual(config);
|
|
154
|
-
});
|
|
155
|
-
it("It should load a config with trailing commas", function() {
|
|
156
|
-
var config = {
|
|
157
|
-
compilerOptions: {
|
|
158
|
-
baseUrl: "hej"
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)("/root/dir1/tsconfig.json", function(path) {
|
|
162
|
-
return path === "/root/dir1/tsconfig.json";
|
|
163
|
-
}, function(_) {
|
|
164
|
-
return "{\n \"compilerOptions\": { \n \"baseUrl\": \"hej\",\n },\n }";
|
|
165
|
-
});
|
|
166
|
-
// assert.deepEqual(res, config);
|
|
167
|
-
expect(res).toStrictEqual(config);
|
|
168
|
-
});
|
|
169
|
-
it("It should load a config with extends and overwrite all options", function() {
|
|
170
|
-
var firstConfig = {
|
|
171
|
-
extends: "../base-config.json",
|
|
172
|
-
compilerOptions: {
|
|
173
|
-
baseUrl: "kalle",
|
|
174
|
-
paths: {
|
|
175
|
-
foo: [
|
|
176
|
-
"bar2"
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var firstConfigPath = (0, path_1.join)("/root", "dir1", "tsconfig.json");
|
|
182
|
-
var baseConfig = {
|
|
183
|
-
compilerOptions: {
|
|
184
|
-
baseUrl: "olle",
|
|
185
|
-
paths: {
|
|
186
|
-
foo: [
|
|
187
|
-
"bar1"
|
|
188
|
-
]
|
|
189
|
-
},
|
|
190
|
-
strict: true
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var baseConfigPath = (0, path_1.join)("/root", "base-config.json");
|
|
194
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)((0, path_1.join)("/root", "dir1", "tsconfig.json"), function(path) {
|
|
195
|
-
return path === firstConfigPath || path === baseConfigPath;
|
|
196
|
-
}, function(path) {
|
|
197
|
-
if (path === firstConfigPath) {
|
|
198
|
-
return JSON.stringify(firstConfig);
|
|
199
|
-
}
|
|
200
|
-
if (path === baseConfigPath) {
|
|
201
|
-
return JSON.stringify(baseConfig);
|
|
202
|
-
}
|
|
203
|
-
return "";
|
|
204
|
-
});
|
|
205
|
-
// assert.deepEqual(res, {
|
|
206
|
-
// extends: "../base-config.json",
|
|
207
|
-
// compilerOptions: {
|
|
208
|
-
// baseUrl: "kalle",
|
|
209
|
-
// paths: { foo: ["bar2"] },
|
|
210
|
-
// strict: true,
|
|
211
|
-
// },
|
|
212
|
-
// });
|
|
213
|
-
expect(res).toEqual({
|
|
214
|
-
extends: "../base-config.json",
|
|
215
|
-
compilerOptions: {
|
|
216
|
-
baseUrl: "kalle",
|
|
217
|
-
paths: {
|
|
218
|
-
foo: [
|
|
219
|
-
"bar2"
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
strict: true
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
it("It should load a config with extends from node_modules and overwrite all options", function() {
|
|
227
|
-
var firstConfig = {
|
|
228
|
-
extends: "my-package/base-config.json",
|
|
229
|
-
compilerOptions: {
|
|
230
|
-
baseUrl: "kalle",
|
|
231
|
-
paths: {
|
|
232
|
-
foo: [
|
|
233
|
-
"bar2"
|
|
234
|
-
]
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
var firstConfigPath = (0, path_1.join)("/root", "dir1", "tsconfig.json");
|
|
239
|
-
var baseConfig = {
|
|
240
|
-
compilerOptions: {
|
|
241
|
-
baseUrl: "olle",
|
|
242
|
-
paths: {
|
|
243
|
-
foo: [
|
|
244
|
-
"bar1"
|
|
245
|
-
]
|
|
246
|
-
},
|
|
247
|
-
strict: true
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
var baseConfigPath = (0, path_1.join)("/root", "dir1", "node_modules", "my-package", "base-config.json");
|
|
251
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)((0, path_1.join)("/root", "dir1", "tsconfig.json"), function(path) {
|
|
252
|
-
return path === firstConfigPath || path === baseConfigPath;
|
|
253
|
-
}, function(path) {
|
|
254
|
-
if (path === firstConfigPath) {
|
|
255
|
-
return JSON.stringify(firstConfig);
|
|
256
|
-
}
|
|
257
|
-
if (path === baseConfigPath) {
|
|
258
|
-
return JSON.stringify(baseConfig);
|
|
259
|
-
}
|
|
260
|
-
return "";
|
|
261
|
-
});
|
|
262
|
-
// assert.deepEqual(res, {
|
|
263
|
-
// extends: "my-package/base-config.json",
|
|
264
|
-
// compilerOptions: {
|
|
265
|
-
// baseUrl: "kalle",
|
|
266
|
-
// paths: { foo: ["bar2"] },
|
|
267
|
-
// strict: true,
|
|
268
|
-
// },
|
|
269
|
-
// });
|
|
270
|
-
expect(res).toEqual({
|
|
271
|
-
extends: "my-package/base-config.json",
|
|
272
|
-
compilerOptions: {
|
|
273
|
-
baseUrl: "kalle",
|
|
274
|
-
paths: {
|
|
275
|
-
foo: [
|
|
276
|
-
"bar2"
|
|
277
|
-
]
|
|
278
|
-
},
|
|
279
|
-
strict: true
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
it("Should use baseUrl relative to location of extended tsconfig", function() {
|
|
284
|
-
var firstConfig = {
|
|
285
|
-
compilerOptions: {
|
|
286
|
-
baseUrl: "."
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
var firstConfigPath = (0, path_1.join)("/root", "first-config.json");
|
|
290
|
-
var secondConfig = {
|
|
291
|
-
extends: "../first-config.json"
|
|
292
|
-
};
|
|
293
|
-
var secondConfigPath = (0, path_1.join)("/root", "dir1", "second-config.json");
|
|
294
|
-
var thirdConfig = {
|
|
295
|
-
extends: "../second-config.json"
|
|
296
|
-
};
|
|
297
|
-
var thirdConfigPath = (0, path_1.join)("/root", "dir1", "dir2", "third-config.json");
|
|
298
|
-
var res = (0, tsconfig_loader_1.loadTsconfig)((0, path_1.join)("/root", "dir1", "dir2", "third-config.json"), function(path) {
|
|
299
|
-
return path === firstConfigPath || path === secondConfigPath || path === thirdConfigPath;
|
|
300
|
-
}, function(path) {
|
|
301
|
-
if (path === firstConfigPath) {
|
|
302
|
-
return JSON.stringify(firstConfig);
|
|
303
|
-
}
|
|
304
|
-
if (path === secondConfigPath) {
|
|
305
|
-
return JSON.stringify(secondConfig);
|
|
306
|
-
}
|
|
307
|
-
if (path === thirdConfigPath) {
|
|
308
|
-
return JSON.stringify(thirdConfig);
|
|
309
|
-
}
|
|
310
|
-
return "";
|
|
311
|
-
});
|
|
312
|
-
// assert.deepEqual(res, {
|
|
313
|
-
// extends: "../second-config.json",
|
|
314
|
-
// compilerOptions: { baseUrl: join("..", "..") },
|
|
315
|
-
// });
|
|
316
|
-
expect(res).toEqual({
|
|
317
|
-
extends: "../second-config.json",
|
|
318
|
-
compilerOptions: {
|
|
319
|
-
baseUrl: (0, path_1.join)("..", "..")
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}); //# sourceMappingURL=tsconfig-loader.test.js.map
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { configLoader, loadConfig } from "../config-loader";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
describe("config-loader", ()=>{
|
|
4
|
-
it("should use explicitParams when set", ()=>{
|
|
5
|
-
const result = configLoader({
|
|
6
|
-
explicitParams: {
|
|
7
|
-
baseUrl: "/foo/bar",
|
|
8
|
-
paths: {
|
|
9
|
-
asd: [
|
|
10
|
-
"asd"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
cwd: "/baz"
|
|
15
|
-
});
|
|
16
|
-
const successResult = result;
|
|
17
|
-
// assert.equal(successResult.resultType, "success");
|
|
18
|
-
// assert.equal(successResult.absoluteBaseUrl, "/foo/bar");
|
|
19
|
-
// assert.equal(successResult.paths["asd"][0], "asd");
|
|
20
|
-
expect(successResult.resultType).toBe("success");
|
|
21
|
-
expect(successResult.absoluteBaseUrl).toBe("/foo/bar");
|
|
22
|
-
expect(successResult.paths["asd"][0]).toBe("asd");
|
|
23
|
-
});
|
|
24
|
-
it("should use explicitParams when set and add cwd when path is relative", ()=>{
|
|
25
|
-
const result = configLoader({
|
|
26
|
-
explicitParams: {
|
|
27
|
-
baseUrl: "bar/",
|
|
28
|
-
paths: {
|
|
29
|
-
asd: [
|
|
30
|
-
"asd"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
cwd: "/baz"
|
|
35
|
-
});
|
|
36
|
-
const successResult = result;
|
|
37
|
-
// assert.equal(successResult.resultType, "success");
|
|
38
|
-
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "bar/"));
|
|
39
|
-
expect(successResult.resultType).toBe("success");
|
|
40
|
-
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "bar/"));
|
|
41
|
-
});
|
|
42
|
-
it("should fallback to tsConfigLoader when explicitParams is not set", ()=>{
|
|
43
|
-
const result = configLoader({
|
|
44
|
-
explicitParams: undefined,
|
|
45
|
-
cwd: "/baz",
|
|
46
|
-
// tslint:disable-next-line:no-any
|
|
47
|
-
tsConfigLoader: (_)=>({
|
|
48
|
-
tsConfigPath: "/baz/tsconfig.json",
|
|
49
|
-
baseUrl: "./src",
|
|
50
|
-
paths: {}
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
const successResult = result;
|
|
54
|
-
// assert.equal(successResult.resultType, "success");
|
|
55
|
-
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "src"));
|
|
56
|
-
expect(successResult.resultType).toBe("success");
|
|
57
|
-
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "src"));
|
|
58
|
-
});
|
|
59
|
-
it("should show an error message when baseUrl is missing", ()=>{
|
|
60
|
-
const result = configLoader({
|
|
61
|
-
explicitParams: undefined,
|
|
62
|
-
cwd: "/baz",
|
|
63
|
-
// tslint:disable-next-line:no-any
|
|
64
|
-
tsConfigLoader: (_)=>({
|
|
65
|
-
tsConfigPath: "/baz/tsconfig.json",
|
|
66
|
-
baseUrl: undefined,
|
|
67
|
-
paths: {}
|
|
68
|
-
})
|
|
69
|
-
});
|
|
70
|
-
const failResult = result;
|
|
71
|
-
// assert.equal(failResult.resultType, "failed");
|
|
72
|
-
// assert.isTrue(failResult.message.indexOf("baseUrl") > -1);
|
|
73
|
-
expect(failResult.resultType).toBe("failed");
|
|
74
|
-
expect(failResult.message.indexOf("baseUrl") > -1).toBeTruthy();
|
|
75
|
-
});
|
|
76
|
-
it("should presume cwd to be a tsconfig file when loadConfig is called with absolute path to tsconfig.json", ()=>{
|
|
77
|
-
// using tsconfig-named.json to ensure that future changes to fix
|
|
78
|
-
// https://github.com/dividab/tsconfig-paths/issues/31
|
|
79
|
-
// do not pass this test case just because of a directory walk looking
|
|
80
|
-
// for tsconfig.json
|
|
81
|
-
const configFile = join(__dirname, "tsconfig-named.json");
|
|
82
|
-
const result = loadConfig(configFile);
|
|
83
|
-
const successResult = result;
|
|
84
|
-
// assert.equal(successResult.resultType, "success");
|
|
85
|
-
// assert.equal(successResult.configFileAbsolutePath, configFile);
|
|
86
|
-
expect(successResult.resultType).toBe("success");
|
|
87
|
-
expect(successResult.configFileAbsolutePath).toBe(configFile);
|
|
88
|
-
});
|
|
89
|
-
});
|