Skip to content

Commit

Permalink
fix: update to jiti 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 5, 2024
1 parent 9ae770a commit 9147c3e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"defu": "^6.1.4",
"esbuild": "^0.24.0",
"hookable": "^5.5.3",
"jiti": "^2.2.0",
"jiti": "^2.3.1",
"magic-string": "^0.30.11",
"mkdist": "^1.5.9",
"mlly": "^1.7.1",
Expand Down
78 changes: 39 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ export async function build(
rootDir = resolve(process.cwd(), rootDir || ".");

// Create jiti instance for loading initial config
const jiti = createJiti(rootDir, { interopDefault: true });
const jiti = createJiti(rootDir);

let _buildConfig: BuildConfig | BuildConfig[] =
(await jiti.import("./build.config", { try: true })) || {};
(await jiti.import("./build.config", { try: true, default: true })) || {};
_buildConfig = (_buildConfig as any).default || _buildConfig;
const buildConfigs = (
Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]
).filter(Boolean);

const pkg: PackageJson & Partial<Record<"unbuild" | "build", BuildConfig>> =
((await jiti.import("./package.json", { try: true })) as PackageJson) ||
({} as PackageJson);
((await jiti.import("./package.json", {
try: true,
default: true,
})) as PackageJson) || ({} as PackageJson);

// Invoke build for every build config defined in build.config.ts
const cleanedDirs: string[] = [];
Expand Down

0 comments on commit 9147c3e

Please sign in to comment.