@faasjs/load 0.0.2-beta.318 → 0.0.2-beta.322
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 +36 -4
- package/dist/index.mjs +41 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -148,6 +148,24 @@ var NODE_PACKAGES = [
|
|
|
148
148
|
"worker_threads",
|
|
149
149
|
"zlib"
|
|
150
150
|
];
|
|
151
|
+
function resolveModuleBasePath(moduleName) {
|
|
152
|
+
const moduleMainFilePath = require.resolve(moduleName);
|
|
153
|
+
const moduleNameParts = moduleName.split("/");
|
|
154
|
+
let searchForPathSection;
|
|
155
|
+
if (moduleName.startsWith("@") && moduleNameParts.length > 1) {
|
|
156
|
+
const [org, mod] = moduleNameParts;
|
|
157
|
+
searchForPathSection = `node_modules${import_path2.sep}${org}${import_path2.sep}${mod}`;
|
|
158
|
+
} else {
|
|
159
|
+
const [mod] = moduleNameParts;
|
|
160
|
+
searchForPathSection = `node_modules${import_path2.sep}${mod}`;
|
|
161
|
+
}
|
|
162
|
+
const lastIndex = moduleMainFilePath.lastIndexOf(searchForPathSection);
|
|
163
|
+
if (lastIndex === -1) {
|
|
164
|
+
console.log(searchForPathSection, moduleMainFilePath);
|
|
165
|
+
throw new Error(`Couldn't resolve the base path of "${moduleName}". Searched inside the resolved main file path "${moduleMainFilePath}" using "${searchForPathSection}"`);
|
|
166
|
+
}
|
|
167
|
+
return moduleMainFilePath.slice(0, lastIndex + searchForPathSection.length);
|
|
168
|
+
}
|
|
151
169
|
function findModule(list, key, options = { excludes: [] }) {
|
|
152
170
|
if (list[key])
|
|
153
171
|
return;
|
|
@@ -155,12 +173,26 @@ function findModule(list, key, options = { excludes: [] }) {
|
|
|
155
173
|
return;
|
|
156
174
|
try {
|
|
157
175
|
list[key] = (0, import_path2.dirname)(require.resolve((0, import_path2.join)(key, "package.json")));
|
|
158
|
-
const pkg = JSON.parse((0, import_fs2.readFileSync)((0, import_path2.join)(list[key], "package.json")).toString());
|
|
159
|
-
const deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {}));
|
|
160
|
-
deps.map((d) => findModule(list, d, options));
|
|
161
176
|
} catch (error) {
|
|
162
|
-
console.warn(
|
|
177
|
+
console.warn(error);
|
|
178
|
+
try {
|
|
179
|
+
list[key] = resolveModuleBasePath(key);
|
|
180
|
+
} catch (error2) {
|
|
181
|
+
console.warn(error2);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const pkg = JSON.parse((0, import_fs2.readFileSync)((0, import_path2.join)(list[key], "package.json")).toString());
|
|
185
|
+
const deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {}));
|
|
186
|
+
if (pkg.peerDependenciesMeta) {
|
|
187
|
+
Object.keys(pkg.peerDependenciesMeta).forEach((key2) => {
|
|
188
|
+
if (pkg.peerDependenciesMeta[key2].optional) {
|
|
189
|
+
const index = deps.indexOf(key2);
|
|
190
|
+
if (index >= 0)
|
|
191
|
+
deps.splice(index, 1);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
163
194
|
}
|
|
195
|
+
deps.map((d) => findModule(list, d, options));
|
|
164
196
|
}
|
|
165
197
|
function swc(options) {
|
|
166
198
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,11 @@ function loadConfig(root, filename) {
|
|
|
61
61
|
import { deepMerge as deepMerge2 } from "@faasjs/deep_merge";
|
|
62
62
|
import { readFileSync as readFileSync2, unlinkSync } from "fs";
|
|
63
63
|
import { rollup } from "rollup";
|
|
64
|
-
import {
|
|
64
|
+
import {
|
|
65
|
+
join as join2,
|
|
66
|
+
sep as sep2,
|
|
67
|
+
dirname as dirname2
|
|
68
|
+
} from "path";
|
|
65
69
|
import resolve from "@rollup/plugin-node-resolve";
|
|
66
70
|
import { transform } from "@swc/core";
|
|
67
71
|
var FAAS_PACKAGES = [
|
|
@@ -125,6 +129,24 @@ var NODE_PACKAGES = [
|
|
|
125
129
|
"worker_threads",
|
|
126
130
|
"zlib"
|
|
127
131
|
];
|
|
132
|
+
function resolveModuleBasePath(moduleName) {
|
|
133
|
+
const moduleMainFilePath = __require.resolve(moduleName);
|
|
134
|
+
const moduleNameParts = moduleName.split("/");
|
|
135
|
+
let searchForPathSection;
|
|
136
|
+
if (moduleName.startsWith("@") && moduleNameParts.length > 1) {
|
|
137
|
+
const [org, mod] = moduleNameParts;
|
|
138
|
+
searchForPathSection = `node_modules${sep2}${org}${sep2}${mod}`;
|
|
139
|
+
} else {
|
|
140
|
+
const [mod] = moduleNameParts;
|
|
141
|
+
searchForPathSection = `node_modules${sep2}${mod}`;
|
|
142
|
+
}
|
|
143
|
+
const lastIndex = moduleMainFilePath.lastIndexOf(searchForPathSection);
|
|
144
|
+
if (lastIndex === -1) {
|
|
145
|
+
console.log(searchForPathSection, moduleMainFilePath);
|
|
146
|
+
throw new Error(`Couldn't resolve the base path of "${moduleName}". Searched inside the resolved main file path "${moduleMainFilePath}" using "${searchForPathSection}"`);
|
|
147
|
+
}
|
|
148
|
+
return moduleMainFilePath.slice(0, lastIndex + searchForPathSection.length);
|
|
149
|
+
}
|
|
128
150
|
function findModule(list, key, options = { excludes: [] }) {
|
|
129
151
|
if (list[key])
|
|
130
152
|
return;
|
|
@@ -132,12 +154,26 @@ function findModule(list, key, options = { excludes: [] }) {
|
|
|
132
154
|
return;
|
|
133
155
|
try {
|
|
134
156
|
list[key] = dirname2(__require.resolve(join2(key, "package.json")));
|
|
135
|
-
const pkg = JSON.parse(readFileSync2(join2(list[key], "package.json")).toString());
|
|
136
|
-
const deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {}));
|
|
137
|
-
deps.map((d) => findModule(list, d, options));
|
|
138
157
|
} catch (error) {
|
|
139
|
-
console.warn(
|
|
158
|
+
console.warn(error);
|
|
159
|
+
try {
|
|
160
|
+
list[key] = resolveModuleBasePath(key);
|
|
161
|
+
} catch (error2) {
|
|
162
|
+
console.warn(error2);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const pkg = JSON.parse(readFileSync2(join2(list[key], "package.json")).toString());
|
|
166
|
+
const deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {}));
|
|
167
|
+
if (pkg.peerDependenciesMeta) {
|
|
168
|
+
Object.keys(pkg.peerDependenciesMeta).forEach((key2) => {
|
|
169
|
+
if (pkg.peerDependenciesMeta[key2].optional) {
|
|
170
|
+
const index = deps.indexOf(key2);
|
|
171
|
+
if (index >= 0)
|
|
172
|
+
deps.splice(index, 1);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
140
175
|
}
|
|
176
|
+
deps.map((d) => findModule(list, d, options));
|
|
141
177
|
}
|
|
142
178
|
function swc(options) {
|
|
143
179
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/load",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.322",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@faasjs/deep_merge": "^0.0.2-beta.
|
|
26
|
-
"@faasjs/func": "^0.0.2-beta.
|
|
25
|
+
"@faasjs/deep_merge": "^0.0.2-beta.322",
|
|
26
|
+
"@faasjs/func": "^0.0.2-beta.322",
|
|
27
27
|
"@rollup/plugin-node-resolve": "*",
|
|
28
28
|
"@swc/core": "*",
|
|
29
29
|
"js-yaml": "*",
|