chore: fix bundle after oas-kit update

This commit is contained in:
Roman Hotsiy 2019-05-10 18:03:28 +03:00
parent 5297fdf01a
commit 6de3523eb0
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
4 changed files with 9 additions and 6 deletions

View File

@ -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: {

View File

@ -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",

View File

@ -19,7 +19,7 @@ export async function loadAndBundleSpec(specUrlOrObject: object | string): Promi
export function convertSwagger2OpenAPI(spec: any): Promise<OpenAPISpec> {
console.warn('[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0');
return new Promise<OpenAPISpec>((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);

View File

@ -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);