[typescript] Support esbuild, second attempt#11465
Merged
macjohnny merged 11 commits intoOpenAPITools:masterfrom Apr 6, 2022
Merged
[typescript] Support esbuild, second attempt#11465macjohnny merged 11 commits intoOpenAPITools:masterfrom
macjohnny merged 11 commits intoOpenAPITools:masterfrom
Conversation
e715416 to
6879aaa
Compare
5 tasks
Contributor
Author
|
Ugh, seems pupeteer does not readily work in the pipeline:
I have added the chromium dependencies to circleci as per the pupeteer instructions. Hope this is the way to go. |
69b39df to
5a9a281
Compare
Contributor
Author
|
Neither |
5a9a281 to
1997a80
Compare
005d2a5 to
b090cbf
Compare
b090cbf to
d74436c
Compare
d74436c to
44fd457
Compare
Contributor
Author
|
Yay it works! 🚀 Please have another look at this PR now. |
cachescrubber
pushed a commit
to cachescrubber/openapi-generator
that referenced
this pull request
Apr 9, 2022
* Install correct typings for url-parse * Use es modules compat mode when es6 output is selected * Consolidate typescript sample generation naming scheme * Regenerate samples * Create new typescript sample to test esmodules in browser * Expose RequiredError type * Make browser integration tests pass locally * Remove cookie tests, because we don’t allow cross-origin cookies * Add output type to package definition * Execute new browser tests in pipeline * Install headless chromium dependencies in circle ci
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first try in #11298 did not work, because it broke the commonjs output.
Now I have differentiated between the two. When es6 is activated, we build an esmodule and when it is deactivated we build the classic commonjs format. For commonjs we don’t need to change our imports, because the esmodule import restrictions don’t apply to the commonjs format. For esmodule output we use a default import.
To make sure everything works, I have added a new sample that has
supportsES6enabled. The tests for it use esbuild as bundler. (Unfortunately a bundler is needed in any case, because we include commonjs polyfills. Ideally the esmodule output could just run in the browser as-is, but that is something for another day.)As before I have included proper typings for url-parse.
I also had to expose the
RequiredErrorexception type to allow explicit casting to it, because typescript regards errors incatchasunknownthese days.Pet API tests are run against
http://localhost/v2as base server, to prevent HSTS in the browser from forcing https.Finally, I added more fields to
package.jsonthat include the module type and entry point, to improve compatibility with node and bundlers, especially when generating esmodule output.PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(5.3.0),6.0.x@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)