mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-01 08:30:33 +03:00
fix: add browser build for webpack 5 (#1796)
This commit is contained in:
parent
b604bd8da8
commit
0e43ad3102
|
@ -27,6 +27,7 @@
|
|||
"React.js"
|
||||
],
|
||||
"main": "bundles/redoc.lib.js",
|
||||
"browser": "bundles/redoc.browser.lib.js",
|
||||
"types": "typings/index.d.ts",
|
||||
"scripts": {
|
||||
"start": "webpack serve --mode=development --env playground --hot --config demo/webpack.config.ts",
|
||||
|
@ -42,7 +43,8 @@
|
|||
"bundle:clean": "rimraf bundles",
|
||||
"bundle:standalone": "webpack --env production --env standalone --mode=production",
|
||||
"bundle:lib": "webpack --mode=production && npm run declarations",
|
||||
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone",
|
||||
"bundle:browser": "webpack --env production --env browser --mode=production",
|
||||
"bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:browser && npm run bundle:standalone",
|
||||
"declarations": "tsc --emitDeclarationOnly -p tsconfig.lib.json && cp -R src/types typings/",
|
||||
"stats": "webpack --env production --env standalone --json --profile --mode=production > stats.json",
|
||||
"prettier": "prettier --write \"cli/index.ts\" \"src/**/*.{ts,tsx}\"",
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
import * as lunr from 'lunr';
|
||||
|
||||
try {
|
||||
// tslint:disable-next-line
|
||||
require('core-js/es/promise'); // bundle into worker
|
||||
} catch (_) {
|
||||
// nope
|
||||
}
|
||||
|
||||
/* just for better typings */
|
||||
export default class Worker {
|
||||
add: typeof add = add;
|
||||
|
|
|
@ -32,10 +32,10 @@ const BANNER = `ReDoc - OpenAPI/Swagger-generated API Reference Documentation
|
|||
Version: ${VERSION}
|
||||
Repo: https://github.com/Redocly/redoc`;
|
||||
|
||||
export default (env: { standalone?: boolean } = {}) => ({
|
||||
export default (env: { standalone?: boolean, browser?: boolean } = {}) => ({
|
||||
entry: env.standalone ? ['./src/polyfills.ts', './src/standalone.tsx'] : './src/index.ts',
|
||||
output: {
|
||||
filename: env.standalone ? 'redoc.standalone.js' : 'redoc.lib.js',
|
||||
filename: env.standalone ? 'redoc.standalone.js' : env.browser ? 'redoc.browser.lib.js' : 'redoc.lib.js',
|
||||
path: path.join(__dirname, '/bundles'),
|
||||
library: 'Redoc',
|
||||
libraryTarget: 'umd',
|
||||
|
@ -47,13 +47,13 @@ export default (env: { standalone?: boolean } = {}) => ({
|
|||
fallback: {
|
||||
path: require.resolve('path-browserify'),
|
||||
http: false,
|
||||
fs: false,
|
||||
os: false,
|
||||
fs: path.resolve(__dirname, 'src/empty.js'),
|
||||
os: path.resolve(__dirname, 'src/empty.js'),
|
||||
tty: path.resolve(__dirname, 'src/empty.js'),
|
||||
}
|
||||
},
|
||||
performance: false,
|
||||
// target: 'node',
|
||||
externalsPresets: env.standalone ? {} : { node: true },
|
||||
externalsPresets: env.standalone || env.browser ? {} : { node: true },
|
||||
externals: env.standalone
|
||||
? {
|
||||
esprima: 'null',
|
||||
|
|
Loading…
Reference in New Issue
Block a user