Support tsconfig paths
It would be great to support tsconfig "paths" in the cli commands, perhaps using this?
https://www.npmjs.com/package/tsconfig-paths
I'm not sure exactly what was meant by the original issue, but I am running into a wall with tsconfig-paths and oclif-dev manifest
I depend on tsconfig-paths for the typescript build which works fine in dev but when I go to create a manifest, there is no way that I can find to add tsconfig-paths to the node proc that ends up importing things to determine the manifest.
Tried a few likely options:
oclif-dev manifest -r tsconfig-paths/register
› Error: Unexpected argument: tsconfig-paths/register
› See more help with --help
oclif-dev manifest -- -r tsconfig-paths/register
› Error: Unexpected argument: tsconfig-paths/register
› See more help with --help
Can't think of a reasonable workaround here without modifying oclif-dev
You can call the command directly w/ node, and so provide the register that way:
node -r tsconfig-paths/register node_modules/.bin/oclif-dev
"scripts": {
"oclif-dev": "node -r tsconfig-paths/register node_modules/.bin/oclif-dev",
"prepack": "rm -rf lib && ttsc -b && npm run oclif-dev manifest && oclif-dev readme",
"postpack": "rm -f oclif.manifest.json",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md"
},
That's an "ok" solution, but it'd be nice if oclif-dev supported handling this natively.
(this actually applies to all .bin commands that have a shebang for node, as the whole point of the shebang is to automatically "append" the command for you)
You can "fix" it by adding this to bin/run in oclif-dev:
const tsConfig = require('../../../../tsconfig.json');
const tsConfigPaths = require('tsconfig-paths');
tsConfigPaths.register({
baseUrl: './',
paths: tsConfig.compilerOptions.paths
});
you can do that
Calling oclif-dev by js scripts :
const command = require('@oclif/command')
require('ts-node').register({ project })
require('tsconfig-paths').register()
const oclifDevCliPath = './node_modules/@oclif/dev-cli'
async function main() {
const manifestResult = await command.run(['manifest'],oclifDevCliPath)
const readmeResult = await command.run(['readme'], oclifDevCliPath)
}