[SDK] Pure ESM (#18427)
# Introduction While testing the sdk and overall apps in https://github.com/prastoin/twenty-app-hello-world Faced a lot of pure `CJS` external dependencies import issue Replaced all the cjs deps to either esm equivalent or node native replacement
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
import { SyncApplicationOrchestratorStep } from '@/cli/utilities/dev/orchestrator/steps/sync-application-orchestrator-step';
|
||||
import { UploadFilesOrchestratorStep } from '@/cli/utilities/dev/orchestrator/steps/upload-files-orchestrator-step';
|
||||
import { serializeError } from '@/cli/utilities/error/serialize-error';
|
||||
import * as fs from 'fs-extra';
|
||||
import { emptyDir, ensureDir } from '@/cli/utilities/file/fs-utils';
|
||||
import path from 'path';
|
||||
import { OUTPUT_DIR, type Manifest } from 'twenty-shared/application';
|
||||
|
||||
@@ -91,8 +91,8 @@ export class DevModeOrchestrator {
|
||||
async start(): Promise<void> {
|
||||
const outputDir = path.join(this.state.appPath, OUTPUT_DIR);
|
||||
|
||||
await fs.ensureDir(outputDir);
|
||||
await fs.emptyDir(outputDir);
|
||||
await ensureDir(outputDir);
|
||||
await emptyDir(outputDir);
|
||||
|
||||
await this.clientService.ensureGeneratedClientStub({
|
||||
appPath: this.state.appPath,
|
||||
|
||||
+7
-6
@@ -3,8 +3,9 @@ import {
|
||||
type OrchestratorStateBuiltFileInfo,
|
||||
} from '@/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state';
|
||||
import { FileUploader } from '@/cli/utilities/file/file-uploader';
|
||||
import { copy, ensureDir, pathExists } from '@/cli/utilities/file/fs-utils';
|
||||
import crypto from 'crypto';
|
||||
import * as fs from 'fs-extra';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'path';
|
||||
import {
|
||||
OUTPUT_DIR,
|
||||
@@ -126,24 +127,24 @@ export class UploadFilesOrchestratorStep {
|
||||
GENERATED_DIR,
|
||||
);
|
||||
|
||||
if (!(await fs.pathExists(generatedDir))) {
|
||||
if (!(await pathExists(generatedDir))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const outputDir = join(appPath, OUTPUT_DIR, API_CLIENT_DIR);
|
||||
|
||||
await fs.ensureDir(outputDir);
|
||||
await ensureDir(outputDir);
|
||||
|
||||
for (const fileName of API_CLIENT_FILES) {
|
||||
const absoluteSourcePath = join(generatedDir, fileName);
|
||||
|
||||
if (!(await fs.pathExists(absoluteSourcePath))) {
|
||||
if (!(await pathExists(absoluteSourcePath))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
await fs.copy(absoluteSourcePath, join(outputDir, fileName));
|
||||
await copy(absoluteSourcePath, join(outputDir, fileName));
|
||||
|
||||
const content = await fs.readFile(absoluteSourcePath);
|
||||
const content = await readFile(absoluteSourcePath);
|
||||
const checksum = crypto.createHash('md5').update(content).digest('hex');
|
||||
|
||||
const builtPath = join(OUTPUT_DIR, API_CLIENT_DIR, fileName);
|
||||
|
||||
Reference in New Issue
Block a user