-
Notifications
You must be signed in to change notification settings - Fork 4
Add TypeScript support & make externals configurable #54
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
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.
The exclude
clause sent me down quite a path! I guess we need a more careful not
clause to ensure that Babel doesn't process things like node_modules/cat-blocks/msg/scratch_msgs.js
, like you said, but does process things like node_modules/scratch-vm/src/virtual-machine.js
. I haven't yet tried this in a monorepo context, so I'm not sure if the exclude
needs further modification for that...
Also, @cwillisf what should I do to handle the versioning? This should probably be a minor version? |
|
This adds a configuration option for using TypeScript in projects.
The first use-case will be scratch-gui where we'd like to use TS for configuration interfaces that would be exposed to scratch-web.
Making a project use TS also involves including a tsconfig.json and the typescript dependency in the project itself, but the change here enables it to be processed by webpack. The
ts-loader
is the main thing here which transforms TS -> JS. Then the code is processed as before using Babel. Babel is usually not necessary given TS can process things like downleveling code and JSX conversion, but we have a lot of pure-js code to take care of.I've configured the ts-loader to also does JSX conversion (requires the
"jsx": "react"
option in the tsconfig of each project) because otherwise they conflict on theReact
import (TS removes it as it thinks it's type-only, then Babel does not have it). It should be pretty safe to let TS do that for TS files.Additionally, I've added an
addExternals
function so that we can safely add new externals without overriding any default ones.@cwillisf I was careful not to change behavior for projects with enableTS = false, but may have missed something. Which builds do you think make sense to test better?