Skip to content

Commit

Permalink
fix: absolute path imports that could crash on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
minenwerfer committed Mar 8, 2024
1 parent 1ea9534 commit 73446b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/aeria-build/src/iconsExtraction.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as fs from 'fs/promises'
import path from 'path'
import { extractIcons, iconsEsmContent, iconsCjsContent, iconsDtsContent } from './icons'
import { right } from '@aeriajs/common'
import { right, dynamicImport } from '@aeriajs/common'

const DATA_PATH = '.aeria'

export const iconsExtraction = async () => {
const collections = await import(path.join(process.cwd(), 'dist', 'collections'))
const collections = await dynamicImport(path.join(process.cwd(), 'dist', 'collections', 'index.js'))
const base = path.join(process.cwd(), 'node_modules', DATA_PATH)
const icons = []

Expand Down
4 changes: 2 additions & 2 deletions packages/aeria-build/src/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Collection } from '@aeriajs/types'
import { right } from '@aeriajs/common'
import { right, dynamicImport } from '@aeriajs/common'
import { getDatabase, prepareCollectionName, getDatabaseCollection } from '@aeriajs/api'
import { config as loadEnv } from 'dotenv'
import { log } from './log.js'
Expand All @@ -20,7 +20,7 @@ export const migrate = async () => {
loadEnv()
}

const collections = await import(path.join(process.cwd(), 'dist', 'collections')) as Record<string,
const collections = await dynamicImport(path.join(process.cwd(), 'dist', 'collections', 'index.js')) as Record<string,
| Collection
| (()=> Collection)
>
Expand Down
3 changes: 2 additions & 1 deletion packages/aeria-sdk/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { InstanceConfig } from './types.js'
import { dynamicImport } from '@aeriajs/common'
import path from 'path'

export const apiUrl = (config: InstanceConfig) => {
Expand All @@ -12,7 +13,7 @@ export const apiUrl = (config: InstanceConfig) => {
}

export const getConfig = async () => {
const { aeriaSdk } = await import(path.join(process.cwd(), 'package.json'))
const { aeriaSdk } = await dynamicImport(path.join(process.cwd(), 'package.json'))
if( typeof aeriaSdk !== 'object' || !aeriaSdk ) {
throw new Error('aeriaSdk is absent in package.json')
}
Expand Down

0 comments on commit 73446b0

Please sign in to comment.