Why oclif-dev manifest command is executing source code?

310 views Asked by At

oclif-dev manifest will execute your source code, why is this happening?

Step to reproduce:

  1. run npx oclif multi mynewcli
  2. create an index.ts file under root folder src/app/index.ts
  3. you put console.log("test..."); inside the index.ts file
  4. import the file in your src/commands/hello.ts
import { Command } from "@oclif/command";
import * as fs from "fs-extra";
+ import "../app/index";

export default class extends Command {
  async run() {
  }
}
  1. Now you run yarn run prepack, terminal shows
mynewcli % yarn run prepack
yarn run v1.22.4
$ rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme
test...

I thought oclif will only transpile your source code, turns out it executes it, that's quite strange when you're building an npm library.

The current solution is to write everything inside a function.

0

There are 0 answers