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.
Files changed (2) hide show
  1. package/dist/index.js +17 -20
  2. 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 paths = [root, __dirname, process.cwd()];
231
- for (const p of paths) {
227
+ const searchPaths = [root, HERE, process.cwd()];
228
+ for (const p of searchPaths) {
232
229
  try {
233
- const tsPath = __require.resolve("typescript", { paths: [p] });
234
- return __require(tsPath);
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 to JSONC:", e);
248
+ console.warn("[plugin-mf-auto] TS readConfigFile threw, fallback:", e);
252
249
  }
253
250
  }
254
251
  try {
255
- const { parse } = __require("jsonc-parser");
252
+ const { parse } = esmRequire("jsonc-parser");
256
253
  const raw = fs3.readFileSync(baseAbs, "utf8");
257
254
  return parse(raw);
258
255
  } catch {
259
- try {
260
- const raw = fs3.readFileSync(baseAbs, "utf8").replace(/^\uFEFF/, "").replace(/(^|[\s{[,])\/\/.*$/gm, "$1").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,(?=\s*[\]}])/g, "");
261
- return JSON.parse(raw);
262
- } catch (e) {
263
- console.warn("[plugin-mf-auto] Cannot parse tsconfig (fallback) -> using minimal:", e);
264
- return {};
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ptech-preset",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Auto Module.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",