ptech-preset 1.3.3 → 1.3.4
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/index.js +17 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/index.ts
|
|
9
2
|
import path3 from "path";
|
|
10
3
|
import fs3 from "fs";
|
|
@@ -134,6 +127,10 @@ async function collectAutoRemotes(opts = {}) {
|
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
// src/index.ts
|
|
130
|
+
import { createRequire } from "module";
|
|
131
|
+
import { fileURLToPath } from "url";
|
|
132
|
+
var esmRequire = createRequire(import.meta.url);
|
|
133
|
+
var HERE = typeof __dirname !== "undefined" ? __dirname : path3.dirname(fileURLToPath(import.meta.url));
|
|
137
134
|
var DEFAULT_SHARED = {
|
|
138
135
|
react: { singleton: true, eager: true, requiredVersion: false },
|
|
139
136
|
"react-dom": { singleton: true, eager: true, requiredVersion: false },
|
|
@@ -227,11 +224,11 @@ async function devFetchRemoteTypesOnce(params) {
|
|
|
227
224
|
);
|
|
228
225
|
}
|
|
229
226
|
function tryRequireTs(root) {
|
|
230
|
-
const
|
|
231
|
-
for (const p of
|
|
227
|
+
const searchPaths = [root, HERE, process.cwd()];
|
|
228
|
+
for (const p of searchPaths) {
|
|
232
229
|
try {
|
|
233
|
-
const tsPath =
|
|
234
|
-
return
|
|
230
|
+
const tsPath = esmRequire.resolve("typescript", { paths: [p] });
|
|
231
|
+
return esmRequire(tsPath);
|
|
235
232
|
} catch {
|
|
236
233
|
}
|
|
237
234
|
}
|
|
@@ -248,21 +245,21 @@ function readBaseTsConfigJSONC(baseAbs, root) {
|
|
|
248
245
|
}
|
|
249
246
|
if (r.config) return r.config;
|
|
250
247
|
} catch (e) {
|
|
251
|
-
console.warn("[plugin-mf-auto] TS readConfigFile threw, fallback
|
|
248
|
+
console.warn("[plugin-mf-auto] TS readConfigFile threw, fallback:", e);
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
try {
|
|
255
|
-
const { parse } =
|
|
252
|
+
const { parse } = esmRequire("jsonc-parser");
|
|
256
253
|
const raw = fs3.readFileSync(baseAbs, "utf8");
|
|
257
254
|
return parse(raw);
|
|
258
255
|
} catch {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const raw = fs3.readFileSync(baseAbs, "utf8").replace(/^\uFEFF/, "").replace(/(^|[\s{[,])\/\/.*$/gm, "$1").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,(?=\s*[\]}])/g, "");
|
|
259
|
+
return JSON.parse(raw);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
console.warn("[plugin-mf-auto] Cannot parse tsconfig (fallback) -> using minimal:", e);
|
|
262
|
+
return {};
|
|
266
263
|
}
|
|
267
264
|
}
|
|
268
265
|
function ensureDtsObject(dts) {
|