Skip to content

Commit

Permalink
Merge pull request #211 from TheUltDev/patch-1
Browse files Browse the repository at this point in the history
Fix Windows
  • Loading branch information
yuanqing authored Apr 3, 2024
2 parents 61a2f51 + 3cd359f commit 5c32828
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { resolve } from 'node:path'

Check failure on line 1 in packages/build/src/utilities/build-bundles-async/build-bundles-async.ts

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!
import { platform } from 'node:os'
import { pathToFileURL } from 'node:url'

import {
Config,
Expand All @@ -16,6 +18,8 @@ import { importFresh } from '../import-fresh.js'
import { esbuildCssModulesPlugin } from './esbuild-css-modules-plugin.js'
import { esbuildPreactCompatPlugin } from './esbuild-preact-compat-plugin.js'

const isWindows = platform() === 'win32'

interface EntryFile extends ConfigFile {
commandId: string
}
Expand Down Expand Up @@ -48,10 +52,13 @@ async function overrideEsbuildConfigAsync(
buildOptions: BuildOptions,
configGlobPattern: string
): Promise<BuildOptions> {
const filePaths = await globby(configGlobPattern, { absolute: true })
let filePaths = await globby(configGlobPattern, { absolute: true })
if (filePaths.length === 0) {
return buildOptions
}
if (isWindows) {
filePaths = filePaths.map(p => pathToFileURL(p).href)

Check failure on line 60 in packages/build/src/utilities/build-bundles-async/build-bundles-async.ts

View workflow job for this annotation

GitHub Actions / build

Replace `p` with `(p)`
}
const overrideEsbuildConfig:
| OverrideEsbuildConfig
| { default: OverrideEsbuildConfig } = await importFresh(filePaths[0])
Expand Down
9 changes: 8 additions & 1 deletion packages/build/src/utilities/build-manifest-async.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */

import { resolve } from 'node:path'

Check failure on line 3 in packages/build/src/utilities/build-manifest-async.ts

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!
import { platform } from 'node:os'
import { pathToFileURL } from 'node:url'

import {
Config,
Expand All @@ -22,6 +24,8 @@ import { globby } from 'globby'

import { importFresh } from './import-fresh.js'

const isWindows = platform() === 'win32'

export async function buildManifestAsync(options: {
config: Config
minify: boolean
Expand Down Expand Up @@ -209,12 +213,15 @@ function createManifestNetworkAccess(
async function overrideManifestAsync(
manifest: Manifest
): Promise<Record<string, any>> {
const filePaths = await globby(constants.build.manifestConfigGlobPattern, {
let filePaths = await globby(constants.build.manifestConfigGlobPattern, {
absolute: true
})
if (filePaths.length === 0) {
return manifest
}
if (isWindows) {
filePaths = filePaths.map(p => pathToFileURL(p).href)

Check failure on line 223 in packages/build/src/utilities/build-manifest-async.ts

View workflow job for this annotation

GitHub Actions / build

Replace `p` with `(p)`
}
const { default: overrideManifest } = await importFresh(filePaths[0])
return overrideManifest(manifest)
}

0 comments on commit 5c32828

Please sign in to comment.