-
-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation on Gulp usage #26
Comments
👍 Any notes on Gulp would make my life much prettier right now. |
@ianbytchek What do you need specifically? Have you tried creating |
I've been googling earlier on today on how to write gulp tasks straight in TS and not worry about the manual Is it actually possible to write gulpfile in TS and execute it without compiling first? I'm not seeing how gulpfile.ts can help unless compiled first or ran not through PS: thanks for all the cool TypeScript work. Started playing with it a few days ago, having a good time. |
@ianbytchek Yep, definitely works. Give it a go. Gulp uses https://www.npmjs.com/package/liftoff which uses https://www.npmjs.com/package/rechoir, so Edit: Sorry it's non-obvious, definitely requires a see it to believe approach 🙏 |
@blakeembrey I'm missing something. So I installed ts-node globally, but get a bunch of errors when run gulp.
I tried installing |
@ianbytchek Try installing |
I actually tried that too, didn't help. I figured that doing |
@ianbytchek Odd, I get the message too - but the file actually does load, I'll look into this. |
@ianbytchek Just realised what it was. |
@blakeembrey I have it.
|
Make sure you install both locally, not globally. I'll have a better error message in |
Thanks, I'll give it a go now! |
|
@ianbytchek Can you create a copy of the project you're using that I can replicate? That would be perfect 👍 |
@blakeembrey try ianbytchek/guild. # Install dependencies.
cd dependency
tsd install
npm install; npm install gulp; npm install ts-node; npm install typescript
// Run gulp.
cd ../build
gulp # Fails…
gulp --require ts-node/register # Succeeds… |
I've been using TypeScript for my gulpfile.ts and this is how I got it to work. I create a gulpfile.js file containing only these two lines: require('ts-node/register');
require('./gulpfile.ts'); Then I write all my Gulp tasks in gulpfile.ts. Works like a charm. Since ts-node doesn't compile the js file in the same directory, it doesn't clobber the gulpfile.js file. |
You shouldn't need to require Disclaimer – I haven't tried a |
@joeskeen thanks, this is a better solution than doing |
@jedmao yeah, I have seen those before, but for whatever reason, I wasn't able to get it to work without adding a |
You boys got me all curious now, so I created |
@jedmao thanks for looking into this. This is still failing on me: ianbytchek@ibmbp:gulpfile-ts-master$ npm install
ianbytchek@ibmbp:gulpfile-ts-master$ tsd install
ianbytchek@ibmbp:gulpfile-ts-master$ gulp
[13:54:11] Failed to load external module typescript-node/register
[13:54:11] Failed to load external module typescript-register
[13:54:11] Failed to load external module typescript-require
/Users/ianbytchek/Downloads/gulpfile-ts-master/gulpfile.ts:1
(function (exports, require, module, __filename, __dirname) { import * as gulp from 'gulp';
^^^^^^
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3) There is something wrong… Can you show the output of your |
/.../GitHub/gulpfile-ts (master u=)$npm ls -g --depth 0
C:\Users\jedma\AppData\Roaming\npm
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
/.../GitHub/gulpfile-ts (master u=)$node -v
v5.5.0
/.../GitHub/gulpfile-ts (master u=)$npm -v
3.3.12 FWIW, I'm on Windows 10. BTW – the task was Let me know any other way I can help. |
@ianbytchek I finally got around to trying your demo, it appears to work fine for me. |
@blakeembrey I've figured something odd is going on. I'll try to reinstall some global packages see if that helps. |
For what it's worth, I went back and tried Edit: I thought at first it was slower, but I tried it both ways and it was about the same ~2 second delay before my gulpfile starts up |
I've made a PR to log the |
Closing with https://github.com/TypeStrong/ts-node#gulp. |
I had same issue as @ianbytchek and resolved only after I updated my global gulp to 3.9.1 (previously had 3.9.0. If 3.9.1 is the minimal requirement then this needs to be specified somewhere |
Hi guys, i'm still having this issue when using Gulp 4, any thoughts? |
You can always create an issue and describe the problem you're facing. |
Updating gulp to 3.9.1 fixed the same I issue I had. |
From #24. Should also clarify that certain issues are coming from node and that this always loads
tsconfig.json
by default - how to use twotsconfig.json
files.The text was updated successfully, but these errors were encountered: