sliftutils 0.7.12 → 0.7.14

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.
@@ -47,17 +47,19 @@ export function bundleRequire(config: BundleRequireConfig) {
47
47
  child_process: {},
48
48
  events: class EventEmitter { },
49
49
  };
50
- if (typeof document === "undefined" && typeof require !== "undefined") {
51
- const builtInRequire = globalThis.require;
50
+ if (typeof require !== "undefined") {
51
+ const builtInRequire = require;
52
52
  let allBuiltInModules = new Set<string>();
53
53
  allBuiltInModules.add("electron");
54
54
  allBuiltInModules.add("original-fs");
55
55
  allBuiltInModules.add("vscode");
56
- // Change the builts ins to use the actual built ins!
57
- let { builtinModules } = require("node:module");
58
- for (let key of builtinModules) {
59
- allBuiltInModules.add(key);
60
- }
56
+ try {
57
+ // Change the builts ins to use the actual built ins!
58
+ let { builtinModules } = require("node:module");
59
+ for (let key of builtinModules) {
60
+ allBuiltInModules.add(key);
61
+ }
62
+ } catch { }
61
63
 
62
64
  for (let key of allBuiltInModules) {
63
65
  Object.defineProperty(builtInModuleExports, key, {
@@ -161,7 +163,7 @@ export function bundleRequire(config: BundleRequireConfig) {
161
163
  loaded: false,
162
164
  path: dirname(resolveAbsolutePath),
163
165
  paths: serialized?.paths || [],
164
- require,
166
+ require: requireFnc,
165
167
  load,
166
168
  } as any;
167
169
  newModule.exports.default = newModule.exports;
@@ -175,10 +177,10 @@ export function bundleRequire(config: BundleRequireConfig) {
175
177
  resolve.paths = (request: string) => [];
176
178
 
177
179
  requireCache[newModule.id] = newModule;
178
- require.resolve = resolve;
179
- require.cache = requireCache;
180
- require.main = newModule;
181
- require.extensions = "extension not implemented yet" as any;
180
+ requireFnc.resolve = resolve;
181
+ requireFnc.cache = requireCache;
182
+ requireFnc.main = newModule;
183
+ requireFnc.extensions = "extension not implemented yet" as any;
182
184
 
183
185
  // Resolves file extensions
184
186
  function innerResolve(path: string): string {
@@ -216,7 +218,7 @@ export function bundleRequire(config: BundleRequireConfig) {
216
218
  // throw new Error(`Module ${path} not found`);
217
219
  }
218
220
 
219
- function require(path: string) {
221
+ function requireFnc(path: string) {
220
222
  if (path in builtInModuleExports) {
221
223
  return builtInModuleExports[path as keyof typeof builtInModuleExports];
222
224
  }
@@ -235,7 +237,7 @@ export function bundleRequire(config: BundleRequireConfig) {
235
237
  newModule.loaded = true;
236
238
 
237
239
  if (serialized) {
238
- serialized.moduleFnc(newModule.exports, require, newModule, newModule.filename, newModule.path);
240
+ serialized.moduleFnc(newModule.exports, requireFnc, newModule, newModule.filename, newModule.path);
239
241
  } else {
240
242
  // If we are being imported by the root module, we need to throw an error
241
243
  if (!config.parentModule?.parent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {