Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Module resolution for gulpfile.ts directory #2311

Closed
tonyhallett opened this issue Mar 27, 2019 · 4 comments · Fixed by #2312 · 4 remaining pull requests
Closed

Module resolution for gulpfile.ts directory #2311

tonyhallett opened this issue Mar 27, 2019 · 4 comments · Fixed by #2312 · 4 remaining pull requests

Comments

@tonyhallett
Copy link
Contributor

tonyhallett commented Mar 27, 2019

The docs describe module resolution to a folder named gulpfile.js. Somewhere there should be a mention that this will not work with a folder gulpfile.ts when using gulp-typescript even if it is a given that node module resolution works the same here.

@tonyhallett tonyhallett changed the title Module resolution for Module resolution for gulpfile.ts directory Mar 27, 2019
@demurgos
Copy link
Member

demurgos commented Mar 27, 2019

  • For TypeScript, rename to gulpfile.ts and install the ts-node module.

You need ts-node, not gulp-typescript if you want your config file to be written in TS. gulp-typescript is to use gulp to compile TS files from your lib, not the gulpfile itself.

@tonyhallett
Copy link
Contributor Author

Sorry, that is what I meant. The suggestion to add to the docs remains

@phated
Copy link
Member

phated commented Mar 27, 2019

@tonyhallett how would you phrase that? I believe it would have to go in the "splitting a gulpfile" section and say something like:

If you want to have transpilation support with this strategy, you'll need to name the index.js file to index.ts but keep gulpfile.js as the name of the directory.

That seems a little rough but does it cover the problem you encountered? Also, does my solution actually work? It's abusing a lot of implied behaviors and I don't know how they interact together.

@tonyhallett
Copy link
Contributor Author

@phated I have just re-read the the docs page that I linked to. It does state 'You can write a gulpfile using a language that requires transpilation, like TypeScript or Babel, by changing the extension on your gulpfile.js to indicate the language and install the matching transpiler module.' Perhaps it should have been a bit clearer that gulpfile.js was not necessarily a file and applied to folders.

I will create a pull request with my suggested changes.

# for free to join this conversation on GitHub. Already have an account? # to comment