Skip to content

Commit

Permalink
fix: esm docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 5, 2023
1 parent 84617a1 commit 317eb6e
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions docs/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,29 @@ Rename `bin/dev` to `bin/dev.js` and replace the existing code with the followin
```js
#!/usr/bin/env node
// eslint-disable-next-line node/shebang
(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({development: true, dir: import.meta.url})
})()
async function main() {
const {execute} = await import('@oclif/core')
await execute({development: true, dir: import.meta.url})
}

await main()
```
This leverages oclif's `execute` function which handles all the development setup for you. You no longer need set the `NODE_ENV` env var or register the project with `ts-node`. You still adjust oclif `settings` before executing the CLI. For example,
```js
#!/usr/bin/env node
// eslint-disable-next-line node/shebang
(async () => {
const oclif = await import('@oclif/core')
oclif.settings.performanceEnabled = true
await oclif.execute({type: 'esm', development: true, dir: import.meta.url})
})()
```
#### bin/run → bin/run.js
Rename `bin/run` to `bin/run.js` and replace the existing code with the following:
```js
#!/usr/bin/env node
(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({dir: import.meta.url})
})()
async function main() {
const {execute} = await import('@oclif/core')
await execute({dir: import.meta.url})
}

await main()
```
### Update tsconfig.json
Expand Down

0 comments on commit 317eb6e

Please sign in to comment.