build(bundle): use ES6 to import swagger-client symbols (#6208)

swagger-client in versions =3.10.9 exports it's build artifacts in multiple ways.
One artifact is exposed as ES5 compatible code with ES6 imports.
We use this fact to utilize webpack tree shaking algorithm.
This commit also updates swagger-client to v3.10.0
and decreases bundle size for around 10%.
This commit is contained in:
Vladimir Gorej
2020-07-06 14:19:09 +02:00
committed by GitHub
parent f0f358bd8a
commit e3b3bf03d4
4 changed files with 26 additions and 38 deletions

36
package-lock.json generated
View File

@@ -2331,18 +2331,18 @@
}
},
"@babel/runtime-corejs2": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.5.5.tgz",
"integrity": "sha512-FYATQVR00NSNi7mUfpPDp7E8RYMXDuO8gaix7u/w3GekfUinKgX1AcTxs7SoiEmoEW9mbpjrwqWSW6zCmw5h8A==",
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.10.4.tgz",
"integrity": "sha512-9sArmpZDQsnR1yyAcU51DxQrntWxt0LUKjPp3pIyo7kVLfaqKt8muppcT87QmFkXV5H50qXAF8JWOjk0jaXRYA==",
"requires": {
"core-js": "^2.6.5",
"regenerator-runtime": "^0.13.2"
"regenerator-runtime": "^0.13.4"
},
"dependencies": {
"regenerator-runtime": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz",
"integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw=="
"version": "0.13.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz",
"integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA=="
}
}
},
@@ -21154,11 +21154,11 @@
}
},
"swagger-client": {
"version": "3.10.9",
"resolved": "https://registry.npmjs.org/swagger-client/-/swagger-client-3.10.9.tgz",
"integrity": "sha512-tPnhVQ0AC7wM89jfYsP/LlNvmzArr2Uf0NdQ7N69sHrS+7fibB/i75fOIG1kH4bb78D70Z1hwqszEvAOQaZ0Og==",
"version": "3.10.10",
"resolved": "https://registry.npmjs.org/swagger-client/-/swagger-client-3.10.10.tgz",
"integrity": "sha512-aOR1SaXa+hfNK5pHXeh1oVHO5aM3AgOmyrzaOazItQf0EuQGDbBlbmbSmyylYmWSMQhdkG1V1SQmGF17NiStXA==",
"requires": {
"@babel/runtime-corejs2": "=7.10.2",
"@babel/runtime-corejs2": "=7.10.4",
"btoa": "=1.2.1",
"buffer": "=5.6.0",
"cookie": "=0.4.1",
@@ -21174,15 +21174,6 @@
"url": "=0.11.0"
},
"dependencies": {
"@babel/runtime-corejs2": {
"version": "7.10.2",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.10.2.tgz",
"integrity": "sha512-ZLwsFnNm3WpIARU1aLFtufjMHsmEnc8TjtrfAjmbgMbeoyR+LuQoyESoNdTfeDhL6IdY12SpeycXMgSgl8XGXA==",
"requires": {
"core-js": "^2.6.5",
"regenerator-runtime": "^0.13.4"
}
},
"js-yaml": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
@@ -21196,11 +21187,6 @@
"version": "6.9.4",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz",
"integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ=="
},
"regenerator-runtime": {
"version": "0.13.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz",
"integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA=="
}
}
},

View File

@@ -50,7 +50,7 @@
"start": "npm-run-all --parallel serve-static open-static"
},
"dependencies": {
"@babel/runtime-corejs2": "^7.5.5",
"@babel/runtime-corejs2": "^7.10.4",
"@braintree/sanitize-url": "^4.0.0",
"@kyleshockey/object-assign-deep": "^0.4.2",
"@kyleshockey/xml": "^1.0.2",
@@ -83,7 +83,7 @@
"reselect": "^4.0.0",
"serialize-error": "^2.1.0",
"sha.js": "^2.4.11",
"swagger-client": "=3.10.9",
"swagger-client": "=3.10.10",
"url-parse": "^1.4.7",
"xml-but-prettier": "^1.0.1",
"zenscroll": "^4.0.2"

View File

@@ -1,11 +1,9 @@
import React, { PureComponent } from "react"
import PropTypes from "prop-types"
import ImPropTypes from "react-immutable-proptypes"
import SwaggerClient from "swagger-client"
import { opId } from "swagger-client/es/helpers"
import { Iterable, fromJS, Map } from "immutable"
const { opId } = SwaggerClient.helpers
export default class OperationContainer extends PureComponent {
constructor(props, context) {
super(props, context)

View File

@@ -1,13 +1,17 @@
import SwaggerClient from "swagger-client"
import resolve from "swagger-client/es/resolver"
import { execute, buildRequest } from "swagger-client/es/execute"
import Http, { makeHttp, serializeRes } from "swagger-client/es/http"
import resolveSubtree from "swagger-client/es/subtree-resolver"
import { opId } from "swagger-client/es/helpers"
import * as configsWrapActions from "./configs-wrap-actions"
export default function({ configs, getConfigs }) {
return {
fn: {
fetch: SwaggerClient.makeHttp(configs.preFetch, configs.postFetch),
buildRequest: SwaggerClient.buildRequest,
execute: SwaggerClient.execute,
resolve: SwaggerClient.resolve,
fetch: makeHttp(Http, configs.preFetch, configs.postFetch),
buildRequest,
execute,
resolve,
resolveSubtree: (obj, path, opts, ...rest) => {
if(opts === undefined) {
const freshConfigs = getConfigs()
@@ -19,10 +23,10 @@ export default function({ configs, getConfigs }) {
}
}
return SwaggerClient.resolveSubtree(obj, path, opts, ...rest)
return resolveSubtree(obj, path, opts, ...rest)
},
serializeRes: SwaggerClient.serializeRes,
opId: SwaggerClient.helpers.opId
serializeRes,
opId
},
statePlugins: {
configs: {