phetsims / chipper

Tools for developing and building PhET interactive simulations.
MIT License
11 stars 12 forks source link

Enable TypeScript in chipper and perennial #1437

Open samreid opened 2 months ago

samreid commented 2 months ago

I swamped https://github.com/phetsims/chipper/issues/1272 with commits, so let's continue over here. In summary, we would like to enable TypeScript usage in perennial & chipper. Recent dev meeting notes are in: https://docs.google.com/document/d/11Gt3Ulalj0fCD2fFeCjPT5ni_9mM2WjkGc4ysisQmo8/edit

A summary is in https://github.com/phetsims/chipper/issues/1272#issuecomment-2050288975

  • @zepumph is doing regular work in perennial and chipper and feels like it would be a significant productivity improvement to have the code in TS.
  • @samreid feels that he has taken it about as far as he can on his own and would like help from either @jonathanolson, @pixelzoom, or @zepumph.

The general conclusion is that we should definitely go for an incremental process, and @samreid will review everyone's input in the developer notes doc and we will subsequently discuss the incremental plan, and @marlitas will get this item on the planning list for the next iteration. (UPDATE: or the current iteration)

From https://github.com/phetsims/chipper/issues/1272#issuecomment-2050453575

Also, the revelation that we can use import statements anywhere in the chain and everything will still work because the transpiler outputs require statements that grunt can consume.

Current checklist from https://github.com/phetsims/chipper/issues/1272#issuecomment-2051005300

Next steps:

samreid commented 2 months ago

@zepumph and I reviewed the current status and agreed it is at a good point to put on hold until we have more bandwidth to "flip the switch".

zepumph commented 1 month ago

We want to prioritize https://github.com/phetsims/chipper/issues/1356 first.

zepumph commented 4 weeks ago

@samreid and I met today to discuss this further. We had the following discussions:

  1. ts-node may be worth investigating to drive our node-based typescript, but we were totally thwarted even by a hello world, and see no path forward to getting it to work with grunt.
  2. Transpiling with our custom transpiler into two modes seems good and reasonable as a step forward. We don't need to investigate other strategies to unblock this issue (but could at a different time independently). TSC will most likely never be as fast as the babel script we are using in Transpiler.js.
zepumph commented 4 weeks ago

What will it take to commit flipping the feature flag in gruntMain?

 mjkauzmann ~/PHET/git/buoyancy (main)
 $ grunt --lint=false
Running "report-media" task

Running "clean" task

Running "build" task
Fatal error: Perennial task failed:
Error: ENOENT: no such file or directory, open 'C:\Users\mjkauzmann\PHET\git\chipper\dist\commonjs\perennial-alias\data\active-repos'
    at Object.openSync (node:fs:601:3)
    at Object.readFileSync (node:fs:469:35)
    at Object.<anonymous> (C:\Users\mjkauzmann\PHET\git\chipper\dist\commonjs\chipper\js\grunt\webpackBuild.js:29:22)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (C:\Users\mjkauzmann\PHET\git\chipper\dist\commonjs\chipper\js\grunt\buildStandalone.js:26:20)
Full Error details:
Error: ENOENT: no such file or directory, open 'C:\Users\mjkauzmann\PHET\git\chipper\dist\commonjs\perennial-alias\data\active-repos'
samreid commented 4 weeks ago

It seems like data/active-repos is accessed through a relative path. Two ideas:

UPDATE: There are 12 occurrences of __dirname in chipper. Perhaps convert those to a path relative to the runtime directory?

samreid commented 4 weeks ago

I added some commits in a branch. After the change above, grunt lint succeeds in buoyancy.