wuchale 0.23.0 → 0.23.2
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/config.js +4 -1
- package/dist/handler/files.js +1 -1
- package/dist/hub.js +15 -12
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -12,6 +12,9 @@ export const defaultConfig = {
|
|
|
12
12
|
function deepFill(target, defaults) {
|
|
13
13
|
for (const [key, def] of Object.entries(defaults)) {
|
|
14
14
|
const value = target[key];
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
15
18
|
if (!def || Array.isArray(def) || typeof def !== 'object') {
|
|
16
19
|
if (value === undefined) {
|
|
17
20
|
target[key] = def;
|
|
@@ -19,7 +22,7 @@ function deepFill(target, defaults) {
|
|
|
19
22
|
continue;
|
|
20
23
|
}
|
|
21
24
|
// def is an object. force prepare an object on the destination
|
|
22
|
-
if (!value ||
|
|
25
|
+
if (!value || typeof value !== 'object') {
|
|
23
26
|
target[key] = {};
|
|
24
27
|
}
|
|
25
28
|
deepFill(target[key], def);
|
package/dist/handler/files.js
CHANGED
|
@@ -112,7 +112,7 @@ export class Files {
|
|
|
112
112
|
getImportPath(filename, importer) {
|
|
113
113
|
const relTo = importer ? resolve(this.#opts.root, importer) : filename;
|
|
114
114
|
filename = normalizeSep(relative(dirname(relTo), filename));
|
|
115
|
-
if (!filename.startsWith('.')) {
|
|
115
|
+
if (!filename.startsWith('../') && !filename.startsWith('./')) {
|
|
116
116
|
filename = `./${filename}`;
|
|
117
117
|
}
|
|
118
118
|
return filename;
|
package/dist/hub.js
CHANGED
|
@@ -59,6 +59,7 @@ export class Hub {
|
|
|
59
59
|
#formatTransformErr = e => e;
|
|
60
60
|
#hmrVersion = -1;
|
|
61
61
|
#lastSourceTriggeredCatalogWrite = 0;
|
|
62
|
+
#lastAdapterForFile = new Map();
|
|
62
63
|
constructor(opts) {
|
|
63
64
|
this.#opts = opts;
|
|
64
65
|
this.#handlers = opts.handlers;
|
|
@@ -197,24 +198,26 @@ export class Hub {
|
|
|
197
198
|
}
|
|
198
199
|
const filename = normalizeSep(relative(this.#opts.root, filePath));
|
|
199
200
|
let output = null;
|
|
200
|
-
let lastAdapterKey = null;
|
|
201
201
|
for (const adapter of this.#handlers.values()) {
|
|
202
|
-
if (adapter.fileMatches(filename)) {
|
|
203
|
-
|
|
204
|
-
throw new Error(`${logPrefix} ${filename} matches both adapters ${lastAdapterKey} and ${adapter.key}`);
|
|
205
|
-
}
|
|
206
|
-
try {
|
|
207
|
-
output = await adapter.transform(code, filename, this.#hmrVersion, forServer);
|
|
208
|
-
}
|
|
209
|
-
catch (e) {
|
|
210
|
-
throw this.#formatTransformErr(e, adapter.key, filename);
|
|
211
|
-
}
|
|
212
|
-
lastAdapterKey = adapter.key;
|
|
202
|
+
if (!adapter.fileMatches(filename)) {
|
|
203
|
+
continue;
|
|
213
204
|
}
|
|
205
|
+
try {
|
|
206
|
+
output = await adapter.transform(code, filename, this.#hmrVersion, forServer);
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
throw this.#formatTransformErr(e, adapter.key, filename);
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
214
212
|
}
|
|
215
213
|
return output ?? [{}, false];
|
|
216
214
|
};
|
|
217
215
|
#visitFileHandl = async (filename, handler) => {
|
|
216
|
+
const lastAdapterKey = this.#lastAdapterForFile.get(filename);
|
|
217
|
+
if (lastAdapterKey && lastAdapterKey !== handler.key) {
|
|
218
|
+
this.#opts.log.warn(`${filename} matches both adapters '${lastAdapterKey}' and '${handler.key}'`);
|
|
219
|
+
}
|
|
220
|
+
this.#lastAdapterForFile.set(filename, handler.key);
|
|
218
221
|
this.#opts.log.info(`${logPrefixHandler(handler.key)} Extract from ${color.cyan(filename)}`);
|
|
219
222
|
const contents = await this.#opts.fs.read(resolve(this.#opts.root, filename));
|
|
220
223
|
const [, updated] = await handler.transform(contents, filename);
|