Skip to content

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

Merged
merged 8 commits into from
Sep 25, 2024
Merged

Conversation

georgyangelov
Copy link
Contributor

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 the React 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?

Copy link
Contributor

@cwillisf cwillisf left a 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...

@georgyangelov
Copy link
Contributor Author

Also, @cwillisf what should I do to handle the versioning? This should probably be a minor version?

@cwillisf
Copy link
Contributor

Also, @cwillisf what should I do to handle the versioning? This should probably be a minor version?

semantic-release will calculate a new version number based on the "conventional commit" tags on your commits. Since you have feat: but no ! or BREAKING CHANGE, it'll make a minor version bump.

@georgyangelov georgyangelov merged commit 7e0ca07 into main Sep 25, 2024
2 checks passed
@georgyangelov georgyangelov deleted the nextgen branch September 25, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants