Skip to content

Commit

Permalink
patch(build): decode import path when generating manifest using bun
Browse files Browse the repository at this point in the history
Bun likes to encode file URLs for some reason, which causes issues when dynamically importing them.

Let's give Bun a special treatment and decode things.
  • Loading branch information
Pkmmte committed Sep 24, 2023
1 parent 5e4174f commit 203b3a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-seals-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roboplay/robo.js': patch
---

patch(build): decode import path when generating manifest using bun
7 changes: 5 additions & 2 deletions packages/robo/src/cli/utils/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Scope
} from '../../types/index.js'
import { logger } from '../../core/logger.js'
import { findPackagePath, hasProperties, packageJson } from './utils.js'
import { IS_BUN, findPackagePath, hasProperties, packageJson } from './utils.js'
import { loadConfig } from '../../core/config.js'
import { pathToFileURL } from 'node:url'
import { DefaultGen } from './generate-defaults.js'
Expand Down Expand Up @@ -483,7 +483,10 @@ async function generateEntries<T>(
async (fileKeys, fullPath, moduleKeys) => {
logger.debug(`[${type}] Generating`, fileKeys, 'from', fullPath)
const isGenerated = generatedKeys.includes(fileKeys.join('/'))
const importPath = pathToFileURL(fullPath).toString()
let importPath = pathToFileURL(fullPath).toString()
if (IS_BUN) {
importPath = decodeURIComponent(importPath)
}
const module = await import(importPath)
let entry = {
...getValue(type, module.config),
Expand Down

0 comments on commit 203b3a3

Please sign in to comment.