From 6de3523eb0976ed56797a3f0ed51bf7fc5b9173c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 10 May 2019 18:03:28 +0300 Subject: [PATCH] chore: fix bundle after oas-kit update --- demo/webpack.config.ts | 3 +++ package.json | 2 +- src/utils/loadAndBundleSpec.ts | 2 +- webpack.config.ts | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/demo/webpack.config.ts b/demo/webpack.config.ts index 0a5be014..5e717552 100644 --- a/demo/webpack.config.ts +++ b/demo/webpack.config.ts @@ -94,6 +94,9 @@ export default (env: { playground?: boolean; bench?: boolean } = {}, { mode }) = externals: { esprima: 'esprima', 'node-fetch': 'null', + 'node-fetch-h2': 'null', + yaml: 'null', + 'safe-json-stringify': 'null', }, module: { diff --git a/package.json b/package.json index 29c4c573..8300cc54 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "cy:open": "cypress open", "bundle:clean": "rimraf bundles", "bundle:standalone": "webpack --env.standalone --mode=production", - "bundle:lib": "webpack --mode=production", + "bundle:lib": "webpack --mode=production && npm run declarations", "bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone", "declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json && cp -R src/types typings/", "stats": "webpack --env.standalone --json --profile --mode=production > stats.json", diff --git a/src/utils/loadAndBundleSpec.ts b/src/utils/loadAndBundleSpec.ts index c97378ea..fb8c93b3 100644 --- a/src/utils/loadAndBundleSpec.ts +++ b/src/utils/loadAndBundleSpec.ts @@ -19,7 +19,7 @@ export async function loadAndBundleSpec(specUrlOrObject: object | string): Promi export function convertSwagger2OpenAPI(spec: any): Promise { console.warn('[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0'); return new Promise((resolve, reject) => - convertObj(spec, { patch: true, warnOnly: true }, (err, res) => { + convertObj(spec, { patch: true, warnOnly: true, text: '{}' }, (err, res) => { // TODO: log any warnings if (err) { return reject(err); diff --git a/webpack.config.ts b/webpack.config.ts index 7bbe8f7d..b61feac6 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -65,13 +65,13 @@ export default (env: { standalone?: boolean } = {}, { mode }) => ({ ? { esprima: 'esprima', 'node-fetch': 'null', + 'node-fetch-h2': 'null', + yaml: 'null', + 'safe-json-stringify': 'null', } : (context, request, callback) => { // ignore node-fetch dep of swagger2openapi as it is not used - if (/node-fetch$/i.test(request)) { - return callback(null, 'var undefined'); - } - if (/esprima$/i.test(request)) { + if (/esprima|node-fetch|node-fetch-h2|yaml|safe-json-stringify$/i.test(request)) { return callback(null, 'var undefined'); } return nodeExternals(context, request, callback);