Skip to content

Commit

Permalink
fix #1913: enable the CLI with Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jan 6, 2022
1 parent 9d5fdb6 commit aeae3cf
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
╵ ~~~~~~
```

* Enable esbuild's CLI with Deno ([#1913](https://github.com/evanw/esbuild/issues/1913))

This release allows you to use Deno as an esbuild installer, without also needing to use esbuild's JavaScript API. You can now use esbuild's CLI with Deno:

```
deno run --allow-all "https://deno.land/x/esbuild@v0.14.11/mod.js" --version
```

## 0.14.10

* Enable tree shaking of classes with lowered static fields ([#175](https://github.com/evanw/esbuild/issues/175))
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ node-unref-tests: | scripts/node_modules
node scripts/node-unref-tests.js

lib-typecheck: | lib/node_modules
cd lib && node_modules/.bin/tsc -noEmit -p .
cd lib && node_modules/.bin/tsc -noEmit -p tsconfig.json
cd lib && node_modules/.bin/tsc -noEmit -p tsconfig-deno.json

# End-to-end tests
test-e2e: test-e2e-npm test-e2e-pnpm test-e2e-yarn-berry
Expand Down
13 changes: 13 additions & 0 deletions lib/deno/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,16 @@ let ensureServiceIsRunning = (): Promise<Service> => {
}
return longLivedService
}

// If we're called as the main script, forward the CLI to the underlying executable
if (import.meta.main) {
Deno.run({
cmd: [await install()].concat(Deno.args),
cwd: defaultWD,
stdin: 'inherit',
stdout: 'inherit',
stderr: 'inherit',
}).status().then(({ code }) => {
Deno.exit(code)
})
}
10 changes: 10 additions & 0 deletions lib/tsconfig-deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "es2020", // Allow the "import.meta" syntax
"target": "es2017", // Allow calling APIs such as "Object.entries"
"strict": true,
},
"exclude": [
"npm",
],
}
7 changes: 5 additions & 2 deletions lib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"compilerOptions": {
"module": "CommonJS", // Allow the "import assignment" syntax
"target": "es2017", // Allow calling APIs such as "Object.entries"
"strict": true
}
"strict": true,
},
"exclude": [
"deno",
],
}
2 changes: 1 addition & 1 deletion scripts/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const buildDenoLib = (esbuildPath) => {
path.join(repoDir, 'lib', 'deno', 'mod.ts'),
'--bundle',
'--outfile=' + path.join(denoDir, 'mod.js'),
'--target=es2020',
'--target=esnext',
'--define:ESBUILD_VERSION=' + JSON.stringify(version),
'--platform=neutral',
'--log-level=warning',
Expand Down

0 comments on commit aeae3cf

Please sign in to comment.