Skip to content
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

document extension workaround for other bundlers #195

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- Fix JSON deserialization. #181 introduced a regression that caused TwirpScript servers' JSON serialization to fail.
- Distribute strict ESM. A CommonJS is runtime is included for legacy node clients. Code generation uses ESM and requires Node.js v14 or later.
If you're using a compiler other than TypeScript such as `webpack`, please see [these instructions](https://github.com/tatethurston/TwirpScript#webpack-setup)
- Use [ProtoScript](https://github.com/tatethurston/ProtoScript) code generation. This will result in some generated imports coming from `protoscript` instead of `twirpscript`, but this is a non breaking change. These imports were previously delegated to ProtoScript via reexports inside TwirpScript, and that indirection has now been removed.

## v0.0.60
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ TwirpScript implements the latest [Twirp Wire Protocol (v7)](https://twitchtv.gi
- [Working with other tools](#working-with-other-tools)
- [Caveats, Warnings and Issues ⚠️](#caveats-warnings-and-issues-%EF%B8%8F)
- [FAQ](#faq)
- [Webpack Setup](#webpack-setup)
- [Contributing 👫](#contributing-)
- [Licensing 📃](#licensing-)

Expand Down Expand Up @@ -99,6 +100,7 @@ To learn more about the motivation behind Twirp (and a comparison to REST APIs a

- Node.js v16 or greater
- TypeScript v4.7 or greater when using TypeScript
- [webpack setup](#webpack-setup) when using a compiler other than TypeScript (like webpack)

## Getting Started

Expand Down Expand Up @@ -848,6 +850,33 @@ gRPC is great, but has a large runtime (and corresponding complexity) that is un

To learn more about the motivation behind Twirp (and a comparison to REST APIs and gRPC), check out the [announcement blog](https://blog.twitch.tv/en/2018/01/16/twirp-a-sweet-new-rpc-framework-for-go-5f2febbf35f/).

## Webpack Setup

If you're using a compiler other than TypeScript, such as webpack, this [outstanding issue in TypeScript](https://github.com/microsoft/typescript/issues/37582) adds an additional hurdle.

The short summary of the issue:

- Extensions are required for ESM imports.
- Extension-less imports have sidestepped this TypeScript issue, but extensions are required for ESM adoption.
- The TypeScript compiler requires `.js` extensions for imports.
- Compilers other than TypeScript expect `.ts` extensions for imports.

The TypeScript team is investigating [improving this issue](https://github.com/microsoft/TypeScript/issues/37582) in their [4.9 plan](https://github.com/microsoft/TypeScript/issues/50457)

Webpack users can use [extensionAlias](https://webpack.js.org/configuration/resolve/#resolveextensionalias) to solve this problem:

```diff
module.exports = {
+ resolve: {
+ extensionAlias: {
+ ".js": [".ts", ".js"],
+ },
+ },
};
```

For more context, see [TypeScript#37582](https://github.com/microsoft/typescript/issues/37582) and [Webpack#13252](https://github.com/webpack/webpack/issues/13252).

## Contributing 👫

PR's and issues welcomed! For more guidance check out [CONTRIBUTING.md](https://github.com/tatethurston/twirpscript/blob/main/CONTRIBUTING.md)
Expand Down
Loading