Skip to content

Commit

Permalink
refactor: ensure .esbuild-dev/package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Sep 20, 2024
1 parent 47c6c3b commit ae6d491
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- **refactor**: Test `.esbuild-dev/package.json` instead of its parent dir.

## 0.10.11

- **refactor**: Disable `--cache` by default, it might be too aggressive.
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@hyrious/esbuild-plugin-external": "^0.1.4",
"@types/node": "^20.14.13",
"esbuild": "^0.21.5",
"prettier": "^3.3.3",
"undici": "^6.19.4",
"vitepress": "^1.3.1"
},
Expand Down
7 changes: 5 additions & 2 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const supportsPackagesExternal = /*#__PURE__*/ (() => {
})();

class BuildError extends Error implements BuildFailure {
constructor(public errors: Message[], public warnings: Message[]) {
constructor(
public errors: Message[],
public warnings: Message[],
) {
super("Build failed");
this.name = "BuildFailure";
}
Expand Down Expand Up @@ -79,7 +82,7 @@ export async function build(
watchOptions?: { onRebuild: (error: BuildFailure | null, stop: () => void) => void },
) {
let tmpdir = tempDirectory(cacheOptions?.cwd);
if (!existsSync(tmpdir)) {
if (!existsSync(join(tmpdir, "package.json"))) {
mkdirSync(tmpdir, { recursive: true });
writeFileSync(join(tmpdir, "package.json"), '{"type":"module"}');
}
Expand Down

0 comments on commit ae6d491

Please sign in to comment.