@rsbuild/core 1.4.10 → 1.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +11 -0
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/dist/client/hmr.js +5 -1
- package/dist/client/overlay.js +3 -1
- package/dist/index.cjs +1316 -202
- package/dist/index.js +1294 -189
- package/dist/transformLoader.mjs +7 -5
- package/dist/transformRawLoader.mjs +7 -5
- package/dist-types/configChain.d.ts +1 -1
- package/dist-types/constants.d.ts +0 -1
- package/dist-types/helpers/index.d.ts +3 -2
- package/dist-types/helpers/stats.d.ts +1 -0
- package/dist-types/index.d.ts +1 -1
- package/dist-types/pluginHelper.d.ts +1 -4
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/types/config.d.ts +14 -8
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +1 -2
- package/package.json +6 -7
- package/compiled/connect-history-api-fallback/index.d.ts +0 -1
- package/compiled/connect-history-api-fallback/index.js +0 -149
- package/compiled/connect-history-api-fallback/license +0 -21
- package/compiled/connect-history-api-fallback/package.json +0 -1
- package/compiled/rspack-chain/index.js +0 -1769
- /package/dist-types/{rspack → rspack-plugins}/RsbuildHtmlPlugin.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/HtmlResourceHintsPlugin.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/doesChunkBelongToHtml.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/extractChunks.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/getResourceType.d.ts +0 -0
package/dist/transformLoader.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
async function transformLoader_transform(source, map) {
|
|
2
2
|
var _this__compiler___rsbuildTransformer, _this__compiler;
|
|
3
|
-
let callback = this.async(), bypass = ()=>
|
|
4
|
-
|
|
3
|
+
let callback = this.async(), bypass = ()=>{
|
|
4
|
+
callback(null, source, map);
|
|
5
|
+
}, { id: transformId, getEnvironment } = this.getOptions();
|
|
6
|
+
if (!transformId) return void bypass();
|
|
5
7
|
let transform = null == (_this__compiler = this._compiler) || null == (_this__compiler___rsbuildTransformer = _this__compiler.__rsbuildTransformer) ? void 0 : _this__compiler___rsbuildTransformer[transformId];
|
|
6
|
-
if (!transform) return bypass();
|
|
8
|
+
if (!transform) return void bypass();
|
|
7
9
|
try {
|
|
8
10
|
let result = await transform({
|
|
9
11
|
code: source,
|
|
@@ -19,8 +21,8 @@ async function transformLoader_transform(source, map) {
|
|
|
19
21
|
importModule: this.importModule.bind(this),
|
|
20
22
|
resolve: this.resolve.bind(this)
|
|
21
23
|
});
|
|
22
|
-
if (null == result) return bypass();
|
|
23
|
-
if ('string' == typeof result) return callback(null, result, map);
|
|
24
|
+
if (null == result) return void bypass();
|
|
25
|
+
if ('string' == typeof result) return void callback(null, result, map);
|
|
24
26
|
let useMap = null != map, finalMap = result.map ?? map;
|
|
25
27
|
callback(null, result.code, useMap ? finalMap : void 0);
|
|
26
28
|
} catch (error) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
let transformRawLoader = async function(source, map) {
|
|
2
2
|
var _this__compiler___rsbuildTransformer, _this__compiler;
|
|
3
|
-
let callback = this.async(), bypass = ()=>
|
|
4
|
-
|
|
3
|
+
let callback = this.async(), bypass = ()=>{
|
|
4
|
+
callback(null, source, map);
|
|
5
|
+
}, { id: transformId, getEnvironment } = this.getOptions();
|
|
6
|
+
if (!transformId) return void bypass();
|
|
5
7
|
let transform = null == (_this__compiler = this._compiler) || null == (_this__compiler___rsbuildTransformer = _this__compiler.__rsbuildTransformer) ? void 0 : _this__compiler___rsbuildTransformer[transformId];
|
|
6
|
-
if (!transform) return bypass();
|
|
8
|
+
if (!transform) return void bypass();
|
|
7
9
|
try {
|
|
8
10
|
let result = await transform({
|
|
9
11
|
code: source,
|
|
@@ -19,8 +21,8 @@ let transformRawLoader = async function(source, map) {
|
|
|
19
21
|
importModule: this.importModule.bind(this),
|
|
20
22
|
resolve: this.resolve.bind(this)
|
|
21
23
|
});
|
|
22
|
-
if (null == result) return bypass();
|
|
23
|
-
if ('string' == typeof result) return callback(null, result, map);
|
|
24
|
+
if (null == result) return void bypass();
|
|
25
|
+
if ('string' == typeof result) return void callback(null, result, map);
|
|
24
26
|
let useMap = null != map, finalMap = result.map ?? map;
|
|
25
27
|
callback(null, result.code, useMap ? finalMap : void 0);
|
|
26
28
|
} catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RspackChain from '
|
|
1
|
+
import { RspackChain } from './helpers';
|
|
2
2
|
import type { InternalContext, ModifyBundlerChainUtils } from './types';
|
|
3
3
|
export declare function modifyBundlerChain(context: InternalContext, utils: ModifyBundlerChainUtils): Promise<RspackChain>;
|
|
4
4
|
export declare const CHAIN_ID: {
|
|
@@ -24,7 +24,6 @@ export declare const DEFAULT_ASSET_PREFIX = "/";
|
|
|
24
24
|
export declare const DEFAULT_BASE_URL = "/";
|
|
25
25
|
export declare const DEFAULT_WEB_BROWSERSLIST: string[];
|
|
26
26
|
export declare const DEFAULT_BROWSERSLIST: Record<string, string[]>;
|
|
27
|
-
export declare const HTML_REGEX: RegExp;
|
|
28
27
|
export declare const JS_REGEX: RegExp;
|
|
29
28
|
export declare const SCRIPT_REGEX: RegExp;
|
|
30
29
|
export declare const CSS_REGEX: RegExp;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import color from '../../compiled/picocolors/index.js';
|
|
2
|
-
import
|
|
2
|
+
import RspackChain from '../../compiled/rspack-chain';
|
|
3
3
|
import type { FilenameConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildTarget, Rspack } from '../types';
|
|
4
4
|
export * from './fs';
|
|
5
5
|
export * from './path';
|
|
6
6
|
export * from './stats';
|
|
7
|
-
export { color };
|
|
7
|
+
export { color, RspackChain };
|
|
8
8
|
export declare const rspackMinVersion = "1.2.4";
|
|
9
9
|
export declare const getNodeEnv: () => string;
|
|
10
10
|
export declare const setNodeEnv: (env: string) => void;
|
|
@@ -31,6 +31,7 @@ export declare const canParse: (url: string) => boolean;
|
|
|
31
31
|
export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
|
|
32
32
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): Rspack.Filename;
|
|
33
33
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): Rspack.CssFilename;
|
|
34
|
+
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'wasm', isProd: boolean): Rspack.WebassemblyModuleFilename;
|
|
34
35
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean): Rspack.AssetModuleFilename;
|
|
35
36
|
export declare function partition<T>(array: T[], predicate: (value: T) => boolean): [T[], T[]];
|
|
36
37
|
export declare const applyToCompiler: (compiler: Rspack.Compiler | Rspack.MultiCompiler, apply: (c: Rspack.Compiler, index: number) => void) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StatsCompilation } from '@rspack/core';
|
|
2
2
|
import type { Rspack } from '../types';
|
|
3
3
|
export declare const getAllStatsErrors: (statsData: StatsCompilation) => Rspack.StatsError[] | undefined;
|
|
4
|
+
export declare const getAssetsFromStats: (stats: Rspack.Stats) => Rspack.StatsAsset[];
|
|
4
5
|
export declare const getAllStatsWarnings: (statsData: StatsCompilation) => Rspack.StatsError[] | undefined;
|
|
5
6
|
export declare function getStatsOptions(compiler: Rspack.Compiler | Rspack.MultiCompiler): Rspack.StatsOptions;
|
|
6
7
|
export declare function formatStats(statsData: Rspack.StatsCompilation, hasErrors: boolean): {
|
package/dist-types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the public API of @rsbuild/core.
|
|
4
4
|
*/
|
|
5
5
|
import type * as Rspack from '@rspack/core';
|
|
6
|
-
import { rspack } from '
|
|
6
|
+
import { rspack } from './rspack';
|
|
7
7
|
export { runCLI } from './cli';
|
|
8
8
|
export { createRsbuild } from './createRsbuild';
|
|
9
9
|
export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, loadConfig, } from './loadConfig';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* This file is used to get/set the global instance for html-plugin and css-extract plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { rspack } from '@rspack/core';
|
|
1
|
+
import { rspack } from './rspack';
|
|
5
2
|
import type { HtmlRspackPlugin } from './types';
|
|
6
3
|
/**
|
|
7
4
|
* This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { SecureServerSessionOptions } from 'node:http2';
|
|
3
3
|
import type { ServerOptions as HttpsServerOptions } from 'node:https';
|
|
4
|
+
import type { URL } from 'node:url';
|
|
4
5
|
import type { Configuration, CopyRspackPluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions } from '@rspack/core';
|
|
5
6
|
import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
|
|
6
7
|
import type cors from '../../compiled/cors/index.js';
|
|
@@ -257,18 +258,17 @@ export type ProxyOptions = HttpProxyOptions & {
|
|
|
257
258
|
export type ProxyConfig = Record<string, string> | Record<string, ProxyOptions> | ProxyOptions[] | ProxyOptions;
|
|
258
259
|
export type HistoryApiFallbackContext = {
|
|
259
260
|
match: RegExpMatchArray;
|
|
260
|
-
parsedUrl:
|
|
261
|
-
request:
|
|
261
|
+
parsedUrl: URL;
|
|
262
|
+
request: IncomingMessage;
|
|
262
263
|
};
|
|
264
|
+
export type HistoryApiFallbackTo = string | ((context: HistoryApiFallbackContext) => string);
|
|
263
265
|
export type HistoryApiFallbackOptions = {
|
|
264
266
|
index?: string;
|
|
265
|
-
verbose?: boolean;
|
|
266
|
-
logger?: typeof console.log;
|
|
267
267
|
htmlAcceptHeaders?: string[];
|
|
268
268
|
disableDotRule?: true;
|
|
269
269
|
rewrites?: Array<{
|
|
270
270
|
from: RegExp;
|
|
271
|
-
to:
|
|
271
|
+
to: HistoryApiFallbackTo;
|
|
272
272
|
}>;
|
|
273
273
|
};
|
|
274
274
|
export type PrintUrls = boolean | ((params: {
|
|
@@ -362,8 +362,9 @@ export interface ServerConfig {
|
|
|
362
362
|
*/
|
|
363
363
|
htmlFallback?: HtmlFallback;
|
|
364
364
|
/**
|
|
365
|
-
*
|
|
366
|
-
*
|
|
365
|
+
* Used to support routing based on the history API.
|
|
366
|
+
* When a user visits a path that does not exist, it will automatically
|
|
367
|
+
* return a specified HTML file to avoid a 404 error.
|
|
367
368
|
*/
|
|
368
369
|
historyApiFallback?: boolean | HistoryApiFallbackOptions;
|
|
369
370
|
/**
|
|
@@ -747,7 +748,12 @@ export type FilenameConfig = {
|
|
|
747
748
|
*/
|
|
748
749
|
media?: Rspack.AssetModuleFilename;
|
|
749
750
|
/**
|
|
750
|
-
*
|
|
751
|
+
* The name of Wasm files.
|
|
752
|
+
* @default '[hash].module.wasm'
|
|
753
|
+
*/
|
|
754
|
+
wasm?: Rspack.WebassemblyModuleFilename;
|
|
755
|
+
/**
|
|
756
|
+
* The name of other assets, except for above (image, svg, font, html, wasm...)
|
|
751
757
|
* @default '[name].[contenthash:8][ext]'
|
|
752
758
|
*/
|
|
753
759
|
assets?: Rspack.AssetModuleFilename;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { rspack } from '@rspack/core';
|
|
2
|
-
import type RspackChain from '../../compiled/rspack-chain';
|
|
3
2
|
import type { ChainIdentifier, ManifestData } from '..';
|
|
4
3
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
4
|
+
import type { RspackChain } from '../types';
|
|
5
5
|
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
6
6
|
import type { RsbuildEntry, RsbuildTarget } from './rsbuild';
|
|
7
7
|
import type { Rspack } from './rspack';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/** @ts-ignore `webpack` type only exists when `@rsbuild/webpack` is installed */
|
|
2
2
|
import type { RuleSetRule, Configuration as WebpackConfig, WebpackPluginInstance } from 'webpack';
|
|
3
|
-
import type RspackChain from '../../compiled/rspack-chain';
|
|
4
3
|
import type { ChainIdentifier } from '../configChain';
|
|
5
4
|
import type { Logger } from '../logger';
|
|
6
5
|
import type { ModifyRspackConfigUtils, NarrowedRspackConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig, RspackMerge } from './config';
|
|
7
6
|
import type { RsbuildContext } from './context';
|
|
8
7
|
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from './hooks';
|
|
9
8
|
import type { AddPluginsOptions, RsbuildInstance, RsbuildTarget } from './rsbuild';
|
|
10
|
-
import type { Rspack } from './rspack';
|
|
9
|
+
import type { Rspack, RspackChain } from './rspack';
|
|
11
10
|
import type { HtmlRspackPlugin } from './thirdParty';
|
|
12
11
|
import type { Falsy, MaybePromise } from './utils';
|
|
13
12
|
type HookOrder = 'pre' | 'post' | 'default';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.12",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.4.
|
|
49
|
+
"@rspack/core": "1.4.11",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
52
|
"core-js": "~3.44.0",
|
|
53
|
-
"jiti": "^2.5.
|
|
53
|
+
"jiti": "^2.5.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@rslib/core": "0.11.0",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"cac": "^6.7.14",
|
|
65
65
|
"chokidar": "^4.0.3",
|
|
66
66
|
"connect": "3.7.0",
|
|
67
|
-
"connect-history-api-fallback": "^2.0.0",
|
|
68
67
|
"cors": "^2.8.5",
|
|
69
68
|
"css-loader": "7.1.2",
|
|
70
69
|
"deepmerge": "^4.3.1",
|
|
@@ -79,17 +78,17 @@
|
|
|
79
78
|
"postcss": "^8.5.6",
|
|
80
79
|
"postcss-load-config": "6.0.1",
|
|
81
80
|
"postcss-loader": "8.1.1",
|
|
82
|
-
"prebundle": "1.
|
|
81
|
+
"prebundle": "1.4.0",
|
|
83
82
|
"reduce-configs": "^1.1.0",
|
|
84
83
|
"rsbuild-dev-middleware": "0.3.0",
|
|
85
84
|
"rslog": "^1.2.9",
|
|
86
|
-
"rspack-chain": "^1.
|
|
85
|
+
"rspack-chain": "^1.3.1",
|
|
87
86
|
"rspack-manifest-plugin": "5.0.3",
|
|
88
87
|
"sirv": "^3.0.1",
|
|
89
88
|
"style-loader": "3.3.4",
|
|
90
89
|
"tinyglobby": "^0.2.14",
|
|
91
90
|
"typescript": "^5.8.3",
|
|
92
|
-
"webpack": "^5.
|
|
91
|
+
"webpack": "^5.100.2",
|
|
93
92
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
94
93
|
"webpack-merge": "6.0.1",
|
|
95
94
|
"ws": "^8.18.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export = any;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
"use strict";
|
|
3
|
-
var __webpack_modules__ = {
|
|
4
|
-
40: (module, exports, __nccwpck_require__) => {
|
|
5
|
-
var url = __nccwpck_require__(16);
|
|
6
|
-
exports = module.exports = function historyApiFallback(options) {
|
|
7
|
-
options = options || {};
|
|
8
|
-
var logger = getLogger(options);
|
|
9
|
-
return function (req, res, next) {
|
|
10
|
-
var headers = req.headers;
|
|
11
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
12
|
-
logger(
|
|
13
|
-
"Not rewriting",
|
|
14
|
-
req.method,
|
|
15
|
-
req.url,
|
|
16
|
-
"because the method is not GET or HEAD.",
|
|
17
|
-
);
|
|
18
|
-
return next();
|
|
19
|
-
} else if (!headers || typeof headers.accept !== "string") {
|
|
20
|
-
logger(
|
|
21
|
-
"Not rewriting",
|
|
22
|
-
req.method,
|
|
23
|
-
req.url,
|
|
24
|
-
"because the client did not send an HTTP accept header.",
|
|
25
|
-
);
|
|
26
|
-
return next();
|
|
27
|
-
} else if (headers.accept.indexOf("application/json") === 0) {
|
|
28
|
-
logger(
|
|
29
|
-
"Not rewriting",
|
|
30
|
-
req.method,
|
|
31
|
-
req.url,
|
|
32
|
-
"because the client prefers JSON.",
|
|
33
|
-
);
|
|
34
|
-
return next();
|
|
35
|
-
} else if (!acceptsHtml(headers.accept, options)) {
|
|
36
|
-
logger(
|
|
37
|
-
"Not rewriting",
|
|
38
|
-
req.method,
|
|
39
|
-
req.url,
|
|
40
|
-
"because the client does not accept HTML.",
|
|
41
|
-
);
|
|
42
|
-
return next();
|
|
43
|
-
}
|
|
44
|
-
var parsedUrl = url.parse(req.url);
|
|
45
|
-
var rewriteTarget;
|
|
46
|
-
options.rewrites = options.rewrites || [];
|
|
47
|
-
for (var i = 0; i < options.rewrites.length; i++) {
|
|
48
|
-
var rewrite = options.rewrites[i];
|
|
49
|
-
var match = parsedUrl.pathname.match(rewrite.from);
|
|
50
|
-
if (match !== null) {
|
|
51
|
-
rewriteTarget = evaluateRewriteRule(
|
|
52
|
-
parsedUrl,
|
|
53
|
-
match,
|
|
54
|
-
rewrite.to,
|
|
55
|
-
req,
|
|
56
|
-
);
|
|
57
|
-
if (rewriteTarget.charAt(0) !== "/") {
|
|
58
|
-
logger(
|
|
59
|
-
"We recommend using an absolute path for the rewrite target.",
|
|
60
|
-
"Received a non-absolute rewrite target",
|
|
61
|
-
rewriteTarget,
|
|
62
|
-
"for URL",
|
|
63
|
-
req.url,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
logger("Rewriting", req.method, req.url, "to", rewriteTarget);
|
|
67
|
-
req.url = rewriteTarget;
|
|
68
|
-
return next();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
var pathname = parsedUrl.pathname;
|
|
72
|
-
if (
|
|
73
|
-
pathname.lastIndexOf(".") > pathname.lastIndexOf("/") &&
|
|
74
|
-
options.disableDotRule !== true
|
|
75
|
-
) {
|
|
76
|
-
logger(
|
|
77
|
-
"Not rewriting",
|
|
78
|
-
req.method,
|
|
79
|
-
req.url,
|
|
80
|
-
"because the path includes a dot (.) character.",
|
|
81
|
-
);
|
|
82
|
-
return next();
|
|
83
|
-
}
|
|
84
|
-
rewriteTarget = options.index || "/index.html";
|
|
85
|
-
logger("Rewriting", req.method, req.url, "to", rewriteTarget);
|
|
86
|
-
req.url = rewriteTarget;
|
|
87
|
-
next();
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
function evaluateRewriteRule(parsedUrl, match, rule, req) {
|
|
91
|
-
if (typeof rule === "string") {
|
|
92
|
-
return rule;
|
|
93
|
-
} else if (typeof rule !== "function") {
|
|
94
|
-
throw new Error(
|
|
95
|
-
"Rewrite rule can only be of type string or function.",
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return rule({ parsedUrl, match, request: req });
|
|
99
|
-
}
|
|
100
|
-
function acceptsHtml(header, options) {
|
|
101
|
-
options.htmlAcceptHeaders = options.htmlAcceptHeaders || [
|
|
102
|
-
"text/html",
|
|
103
|
-
"*/*",
|
|
104
|
-
];
|
|
105
|
-
for (var i = 0; i < options.htmlAcceptHeaders.length; i++) {
|
|
106
|
-
if (header.indexOf(options.htmlAcceptHeaders[i]) !== -1) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
function getLogger(options) {
|
|
113
|
-
if (options && options.logger) {
|
|
114
|
-
return options.logger;
|
|
115
|
-
} else if (options && options.verbose) {
|
|
116
|
-
return console.log.bind(console);
|
|
117
|
-
}
|
|
118
|
-
return function () {};
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
16: (module) => {
|
|
122
|
-
module.exports = require("url");
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
var __webpack_module_cache__ = {};
|
|
126
|
-
function __nccwpck_require__(moduleId) {
|
|
127
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
128
|
-
if (cachedModule !== undefined) {
|
|
129
|
-
return cachedModule.exports;
|
|
130
|
-
}
|
|
131
|
-
var module = (__webpack_module_cache__[moduleId] = { exports: {} });
|
|
132
|
-
var threw = true;
|
|
133
|
-
try {
|
|
134
|
-
__webpack_modules__[moduleId](
|
|
135
|
-
module,
|
|
136
|
-
module.exports,
|
|
137
|
-
__nccwpck_require__,
|
|
138
|
-
);
|
|
139
|
-
threw = false;
|
|
140
|
-
} finally {
|
|
141
|
-
if (threw) delete __webpack_module_cache__[moduleId];
|
|
142
|
-
}
|
|
143
|
-
return module.exports;
|
|
144
|
-
}
|
|
145
|
-
if (typeof __nccwpck_require__ !== "undefined")
|
|
146
|
-
__nccwpck_require__.ab = __dirname + "/";
|
|
147
|
-
var __webpack_exports__ = __nccwpck_require__(40);
|
|
148
|
-
module.exports = __webpack_exports__;
|
|
149
|
-
})();
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Ben Blackmore and contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"connect-history-api-fallback","author":{"name":"Ben Ripkens","email":"bripkens@gmail.com"},"version":"2.0.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|