gluegun icon indicating copy to clipboard operation
gluegun copied to clipboard

Commands fails when definition files are preset

Open yordis opened this issue 5 years ago • 8 comments

Here is the case

I would have the following files

/commands
  build.d.ts
  build.js

For some reason here https://github.com/infinitered/gluegun/blob/e30b03f0292ab52124a1076952126456655c6459/src/loaders/module-loader.ts#L13-L14 Node is actually requiring the .d.ts file instead of the JavaScript file. 🤷‍♂️

Node version: v10.10.0

yordis avatar Dec 12 '18 05:12 yordis

are you running your cli via node or ts-node? ts-node does some weird things with requires.

I tried out a sample directory without gluegun or a gluegun cli with run.js, run.ts, build.ts, and build.d.ts. run.{js,ts} each have the same code that does a require('./build'). node run.js returns the correct output but ts-node run.ts does not. ts-node run.ts does a require of the build.d.ts file instead.

cmckni3 avatar Dec 21 '18 04:12 cmckni3

@cmckni3 does work using ts-node since that is why the file is not .ts files.

But once I use the compiled version (node) it doesn't work

yordis avatar Dec 21 '18 05:12 yordis

I’ll have to check tomorrow. I think I meant build.js and build.d.ts

cmckni3 avatar Dec 21 '18 06:12 cmckni3

@yordis Did #420 fix your issue here? Or, rather, would it have, if it had been there when you started using Gluegun?

jamonholmgren avatar Dec 23 '18 02:12 jamonholmgren

@jamonholmgren the issue is actually happening on the released version of the package ... I need to replicate it again since I just pull out the .d.ts out of the released version.

This makes no-sense unless ts-node is present, let me dig in, maybe was me being stupid 😄

yordis avatar Dec 23 '18 03:12 yordis

@jamonholmgren confirmed, this behavior is happening and it is not using node-ts. I will try to put an example project for you,

yordis avatar Jan 08 '19 17:01 yordis

@cmckni3 @jamonholmgren you could fork https://github.com/straw-hat-team/fetcher and downgrade to "@straw-hat/cli": "0.10.1" since that version has declarations on it.

Run yarn release and notice that it will fail.

yordis avatar Jan 24 '19 14:01 yordis

@yordis I'm not sure I'll have time to tackle this soon. Would you want to see if you can figure out a solution?

jamonholmgren avatar Jan 29 '19 19:01 jamonholmgren