-
Notifications
You must be signed in to change notification settings - Fork 99
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
Implement fast incremental compiler #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍 – I'll see if I can take a stab at some of the other pieces, perhaps this afternoon or tomorrow.
|
||
function makeTempDir() { | ||
// TODO: the directory won't get monitored if it's in tmp/ | ||
const dir = '.e-c-ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable compromise to me; we'll just want to do two things if we run with it:
- Document it.
- Figure out how to automatically update
.gitignore
on installing the app, so that this directory is always excluded.
annotation: 'JS files', | ||
}); | ||
|
||
// TODO: how to disable watching .ts files? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we figure out how to correctly identify the environment, it should either be available in the same way here or we can use it to set a flag on the this
instance that we pass in so that we watch or not as appropriate for the environment.
Alternatively, maybe in the fast-compiler we intentionally just ignore these files entirely and only trigger on the files in the .e-c-ts
directory changing?
I think the main problem are the two rebuilds
It's a bit faster than broccoli-typescript-compiler but still not as fast as running |
Ah, I misunderstood part of the flow in practice (a bit aspirationally I suppose). My assumption was (and I think if we could get there it would make sense if) it did:
The main challenge I'd foresee with that approach would be getting the bits from |
The advantage of using the preprocessor hooks is they have already sorted out and merged all the trees. In your step 2, ember-cli also sees the change to |
Mmmm. 🤔 @rwjblue, any suggestions here? |
I changed this to use a separate command instead so that I can tweak the watcher
It works! and it's really fast, as if you're not using typescript at all |
Sweet! I’ll test it out and we can ship it!
|
These test failures are incredibly annoying. Nothing changed on our end for them. 😑 |
Two quick notes:
|
Next comment: holy smokes this is fast. |
Played with it a good bit; other than needing that fix for the blueprints directory and getting rid of the So, to ready this for shipping it:
Edit: heh, and maybe also:
|
Maybe |
We have actually 2 separate builds: running |
I also figured out why I couldn't put |
@dwickern do you know what we need to do so we're not swallowing type errors when doing these incremental builds? I'd like to knock this out and ship it, and I think I know how to tackle the rest of it, but am unsure why those are getting swallowed at present. 🤔 Hopefully we can ship this as 1.1 this week, and ship the addon support soon as well. |
Implement `Command#onInterrupt` to remove directory during shutdown. Also add prettier flag not to tweak the layout of tsc process fork.
Implement `Command#onInterrupt` to remove directory during shutdown. Also add prettier-ignore for the tsc process creation, since arguments are *not* like ordinary arrays.
3f49802
to
2a2952b
Compare
I get an error on startup now
|
Huh. I’ll straighten it out tomorrow. Not sure which of my changes would have caused that. 🤔
|
This reverts commit 2feb95a.
Also fix things when linking
Solve 'The Mystery of the Missing app.js 🕵️♂️'
.travis.yml
Outdated
@@ -3,7 +3,7 @@ language: node_js | |||
node_js: | |||
- "6" | |||
|
|||
sudo: false | |||
sudo: required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assorted improvements
lib/serve-ts.js
Outdated
this.tsc = child_process.fork( | ||
'node_modules/typescript/bin/tsc', | ||
[ | ||
'--watch', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dwickern @dfreeman one thing I've been thinking is: we should be able to get and use the project's tsconfig, and then use that here (using -p <path to project>
) except with overrides. I believe TS properly does the override sequence if you just hand it a project file and then a set of overrides.
Does that make sense to both of you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative approach: do the usual JSON.parse(tsConfig)
dance and set only the properties we want to set here, e.g. sourceMap: <whatever is in the config
That might be better.
Also, I don't think we need to worry about using a global install of tsc
; we should only be using the local version, since that's what will be used for the final build, as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of using -p <path-to-project>
and overriding with the handful of flags we need — it feels simpler (and I also think tsc
will actually let you get away with nonconformant JSON, so we'd need something fancier than JSON.parse
for that approach)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it already picks up the tsconfig in the project root based on the cwd? We could pass the path explicitly though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I just went back and read the docs, and you're both correct about those pieces. So here, we should just be able to override only what we need to – and presumably, other than outdir, that should largely match what we have in the overrides in the TypescriptPreprocessor
class (starting here).
Note that that's assuming valid JSON. 🤔
1b45638
to
0b4b4fe
Compare
Two things:
Just logging those here in case either of you gets to them ahead of me. I'll be at it again tomorrow. |
…-cli commands work
Incremental compiler with broccoli integration
Implement fast incremental compiler
The idea here is to use
tsc --watch
instead of broccoli-typescript-compiler, sincetsc
has much faster incremental compile logic. There is no public API for the incremental compiler yet, but once microsoft/TypeScript#9282 is implemented, broccoli-typescript-compiler should be equally fast and this PR will be obsolete.There are lots of issues with my hacked together implementation
.ts
are still being watched, so each change triggers two rebuilds. Fixing this should make it faster.tmp
so I put the compiled js into an.e-c-ts
directorytsc
since the error messages are nasty, e.g.