From 458191546e76e51456c20ffb83b211de3d2cd76b Mon Sep 17 00:00:00 2001 From: Martin Oppitz Date: Wed, 20 Dec 2023 03:15:08 +0100 Subject: [PATCH] fix: esm --- packages/stack/core/src/mjs/index.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/stack/core/src/mjs/index.ts b/packages/stack/core/src/mjs/index.ts index bbca662734..82f471d379 100644 --- a/packages/stack/core/src/mjs/index.ts +++ b/packages/stack/core/src/mjs/index.ts @@ -1,23 +1,27 @@ +import fs from 'fs'; import path from 'path'; -import { createRequire } from 'module'; - -const require = createRequire(import.meta.url); export let PROXIES: Object = {}; try { - PROXIES = require(path.resolve(process.cwd(), 'proxy.conf.json')); + PROXIES = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'proxy.conf.json'), 'utf-8')); } catch (error) { PROXIES = {}; } -const packageJsonApp = require(path.resolve(process.cwd(), 'package.json')); -const packageJsonCli = require(path.resolve(process.cwd(), 'node_modules/@leanup/stack/package.json')); +let packageJsonApp; +try { + packageJsonApp = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8')); +} catch (error) { + packageJsonApp = {}; +} -let proxyConfig; +let packageJsonCli; try { - proxyConfig = require(path.resolve(process.cwd(), 'proxy.conf.json')); + packageJsonCli = JSON.parse( + fs.readFileSync(path.resolve(process.cwd(), 'node_modules/@leanup/stack/package.json'), 'utf-8') + ); } catch (error) { - proxyConfig = {}; + packageJsonCli = {}; } export interface Replacement {