Skip to content

Commit

Permalink
chore: fix bundle after oas-kit update
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed May 12, 2019
1 parent 5297fdf commit 6de3523
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions demo/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/loadAndBundleSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6de3523

Please sign in to comment.