[REQ] [typescript-fetch] Introduce ES2015+ module builds and other improvements
Created by: someone1
Is your feature request related to a problem? Please describe.
Treeshaking the client from the generator doesn't work all that well. Introducing a module version to the build script and additional package.json options can help with this.
For example, if the generated client produces 4 different API clients, but your app only uses 2, all 4 are still bundled into the project.
Describe the solution you'd like
All suggestions should be non-breaking changes:
- A new
tsconfig.esm.json
file generated alongside the current with the settingmodule: "esnext"
- Build task in the
package.json
to generate as-is and a module version based on the new config (e.g.*.esm.js
versions) -
package.json
updated to include the following options:
"module": "./dist/index.esm.js",
"sideEffects": false,
I don't believe any of the code generated has any side effects.
Describe alternatives you've considered
using a series of jq
commands post-generation to do it for our needs, but seems like a backwards-compatible change that can benefit all users.
Additional context
Should help webpack (and maybe rollup?) use module imports when the project is able to and enable tree shaking.
I'd be willing to try to implement the changes myself if this is a change OKAYed for the project.
CC @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)