sliftutils 0.7.12 → 0.7.13
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/bundler/bundleRequire.ts +8 -8
- package/package.json +1 -1
package/bundler/bundleRequire.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
48
48
|
events: class EventEmitter { },
|
|
49
49
|
};
|
|
50
50
|
if (typeof document === "undefined" && typeof require !== "undefined") {
|
|
51
|
-
const builtInRequire =
|
|
51
|
+
const builtInRequire = require;
|
|
52
52
|
let allBuiltInModules = new Set<string>();
|
|
53
53
|
allBuiltInModules.add("electron");
|
|
54
54
|
allBuiltInModules.add("original-fs");
|
|
@@ -161,7 +161,7 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
161
161
|
loaded: false,
|
|
162
162
|
path: dirname(resolveAbsolutePath),
|
|
163
163
|
paths: serialized?.paths || [],
|
|
164
|
-
require,
|
|
164
|
+
require: requireFnc,
|
|
165
165
|
load,
|
|
166
166
|
} as any;
|
|
167
167
|
newModule.exports.default = newModule.exports;
|
|
@@ -175,10 +175,10 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
175
175
|
resolve.paths = (request: string) => [];
|
|
176
176
|
|
|
177
177
|
requireCache[newModule.id] = newModule;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
requireFnc.resolve = resolve;
|
|
179
|
+
requireFnc.cache = requireCache;
|
|
180
|
+
requireFnc.main = newModule;
|
|
181
|
+
requireFnc.extensions = "extension not implemented yet" as any;
|
|
182
182
|
|
|
183
183
|
// Resolves file extensions
|
|
184
184
|
function innerResolve(path: string): string {
|
|
@@ -216,7 +216,7 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
216
216
|
// throw new Error(`Module ${path} not found`);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
function
|
|
219
|
+
function requireFnc(path: string) {
|
|
220
220
|
if (path in builtInModuleExports) {
|
|
221
221
|
return builtInModuleExports[path as keyof typeof builtInModuleExports];
|
|
222
222
|
}
|
|
@@ -235,7 +235,7 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
235
235
|
newModule.loaded = true;
|
|
236
236
|
|
|
237
237
|
if (serialized) {
|
|
238
|
-
serialized.moduleFnc(newModule.exports,
|
|
238
|
+
serialized.moduleFnc(newModule.exports, requireFnc, newModule, newModule.filename, newModule.path);
|
|
239
239
|
} else {
|
|
240
240
|
// If we are being imported by the root module, we need to throw an error
|
|
241
241
|
if (!config.parentModule?.parent) {
|