Skip to content

Commit

Permalink
improving sync load in _require_
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmachuca committed Nov 10, 2024
1 parent 5e23cbe commit c7cbb92
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 51 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.112-beta
2.5.113-beta
21 changes: 10 additions & 11 deletions build/findPackageNodePath.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findPackageNodePath = void 0;
const _import_1 = require("./_import_");
const CONFIG_1 = require("./CONFIG");
const Export_1 = require("./Export");
const Logger_1 = require("./Logger");
const platform_1 = require("./platform");
const node_fs_1 = __importDefault(require("node:fs"));
const findPackageNodePath = function (packagename) {
let sdkPath = null;
if (!platform_1.isBrowser) {
try {
let fs;
(async () => {
fs = await (0, _import_1._import_)("node:fs");
})().then(() => {
let sdkPaths = [
`${CONFIG_1.CONFIG.get("projectPath")}${CONFIG_1.CONFIG.get("relativeImportPath")}`,
`${CONFIG_1.CONFIG.get("basePath")}${CONFIG_1.CONFIG.get("relativeImportPath")}`,
Expand All @@ -28,7 +28,7 @@ const findPackageNodePath = function (packagename) {
""
].concat(module.paths);
sdkPaths = sdkPaths.filter(p => {
return (node_fs_1.default).existsSync(p + "/" + packagename);
return (fs).existsSync(p + "/" + packagename);
});
if (sdkPaths.length > 0) {
sdkPath = sdkPaths[0];
Expand All @@ -38,11 +38,10 @@ const findPackageNodePath = function (packagename) {
sdkPath = "";
Logger_1.logger.info(`${packagename} is not in a standard path.`);
}
}
catch (e) {
// do nothing
console.log(e);
}
})
.catch((e) => {
throw new Error(e);
});
}
return sdkPath;
};
Expand Down
5 changes: 3 additions & 2 deletions build/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const _require_ = (name) => {
return (exports.isDeno) ? ((0, exports.deno_require)(name)) : (((name) => {
let r;
try {
(0, _import_1._import_)(name)
.then((m) => {
(async () => {
r = await (0, _import_1._import_)(name);
})().then((m) => {
r = (m && m.default) || m;
})
.catch((e) => {
Expand Down
25 changes: 15 additions & 10 deletions public/browser/QCObjects.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions public/browser/QCObjects.js.map

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions public/cjs/QCObjects.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ var init_platform = __esm({
return isDeno ? deno_require(name) : ((name2) => {
let r;
try {
_import_(name2).then((m) => {
(async () => {
r = await _import_(name2);
})().then((m) => {
r = m && m.default || m;
}).catch((e) => {
logger.warn(`An error ocurred: ${e}`);
Expand Down Expand Up @@ -2274,9 +2276,9 @@ var init_componentLoader = __esm({
} else {
logger.debug("Loading the component as a local file in server...");
const _directLoad = /* @__PURE__ */ __name(function() {
const fs2 = _require_("fs");
const fs = _require_("fs");
logger.debug("SENDING THE NORMAL REQUEST ");
fs2.readFile(component2.url, _componentLoaded);
fs.readFile(component2.url, _componentLoaded);
}, "_directLoad");
if (component2.cached) {
logger.debug("USING CACHE FOR COMPONENT: " + component2.name);
Expand Down Expand Up @@ -4325,19 +4327,22 @@ var init_Tag = __esm({
});

// src/findPackageNodePath.ts
var import_node_fs, findPackageNodePath;
var findPackageNodePath;
var init_findPackageNodePath = __esm({
"src/findPackageNodePath.ts"() {
"use strict";
init_import();
init_CONFIG();
init_Export();
init_Logger();
init_platform();
import_node_fs = __toESM(require("node:fs"));
findPackageNodePath = /* @__PURE__ */ __name(function(packagename) {
let sdkPath = null;
if (!isBrowser) {
try {
let fs;
(async () => {
fs = await _import_("node:fs");
})().then(() => {
let sdkPaths = [
`${CONFIG.get("projectPath")}${CONFIG.get("relativeImportPath")}`,
`${CONFIG.get("basePath")}${CONFIG.get("relativeImportPath")}`,
Expand All @@ -4353,7 +4358,7 @@ var init_findPackageNodePath = __esm({
""
].concat(module.paths);
sdkPaths = sdkPaths.filter((p) => {
return import_node_fs.default.existsSync(p + "/" + packagename);
return fs.existsSync(p + "/" + packagename);
});
if (sdkPaths.length > 0) {
sdkPath = sdkPaths[0];
Expand All @@ -4362,9 +4367,9 @@ var init_findPackageNodePath = __esm({
sdkPath = "";
logger.info(`${packagename} is not in a standard path.`);
}
} catch (e) {
console.log(e);
}
}).catch((e) => {
throw new Error(e);
});
}
return sdkPath;
}, "findPackageNodePath");
Expand Down
6 changes: 3 additions & 3 deletions public/cjs/QCObjects.cjs.map

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions public/esm/QCObjects.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ var init_platform = __esm({
return isDeno ? deno_require(name) : ((name2) => {
let r;
try {
_import_(name2).then((m) => {
(async () => {
r = await _import_(name2);
})().then((m) => {
r = m && m.default || m;
}).catch((e) => {
logger.warn(`An error ocurred: ${e}`);
Expand Down Expand Up @@ -2274,9 +2276,9 @@ var init_componentLoader = __esm({
} else {
logger.debug("Loading the component as a local file in server...");
const _directLoad = /* @__PURE__ */ __name(function() {
const fs2 = _require_("fs");
const fs = _require_("fs");
logger.debug("SENDING THE NORMAL REQUEST ");
fs2.readFile(component2.url, _componentLoaded);
fs.readFile(component2.url, _componentLoaded);
}, "_directLoad");
if (component2.cached) {
logger.debug("USING CACHE FOR COMPONENT: " + component2.name);
Expand Down Expand Up @@ -4325,19 +4327,22 @@ var init_Tag = __esm({
});

// src/findPackageNodePath.ts
import fs from "node:fs";
var findPackageNodePath;
var init_findPackageNodePath = __esm({
"src/findPackageNodePath.ts"() {
"use strict";
init_import();
init_CONFIG();
init_Export();
init_Logger();
init_platform();
findPackageNodePath = /* @__PURE__ */ __name(function(packagename) {
let sdkPath = null;
if (!isBrowser) {
try {
let fs;
(async () => {
fs = await _import_("node:fs");
})().then(() => {
let sdkPaths = [
`${CONFIG.get("projectPath")}${CONFIG.get("relativeImportPath")}`,
`${CONFIG.get("basePath")}${CONFIG.get("relativeImportPath")}`,
Expand All @@ -4362,9 +4367,9 @@ var init_findPackageNodePath = __esm({
sdkPath = "";
logger.info(`${packagename} is not in a standard path.`);
}
} catch (e) {
console.log(e);
}
}).catch((e) => {
throw new Error(e);
});
}
return sdkPath;
}, "findPackageNodePath");
Expand Down
6 changes: 3 additions & 3 deletions public/esm/QCObjects.mjs.map

Large diffs are not rendered by default.

0 comments on commit c7cbb92

Please sign in to comment.