@rsbuild/core 1.4.11 → 1.4.13
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/launch-editor-middleware/index.js +32 -21
- package/compiled/launch-editor-middleware/package.json +1 -1
- 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 +13 -2
- package/dist/client/overlay.js +3 -1
- package/dist/index.cjs +1322 -217
- package/dist/index.js +1304 -209
- 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 +1 -0
- package/dist-types/helpers/index.d.ts +2 -2
- package/dist-types/helpers/stats.d.ts +1 -0
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -0
- package/dist-types/server/compilationMiddleware.d.ts +0 -4
- package/dist-types/server/devServer.d.ts +7 -2
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/server/socketServer.d.ts +24 -7
- package/dist-types/types/config.d.ts +20 -10
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +1 -2
- package/package.json +9 -10
- 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/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: {
|
|
@@ -2,6 +2,7 @@ export declare const __filename: string;
|
|
|
2
2
|
export declare const __dirname: string;
|
|
3
3
|
export declare const ROOT_DIST_DIR = "dist";
|
|
4
4
|
export declare const HTML_DIST_DIR = "./";
|
|
5
|
+
export declare const FAVICON_DIST_DIR = "./";
|
|
5
6
|
export declare const JS_DIST_DIR = "static/js";
|
|
6
7
|
export declare const CSS_DIST_DIR = "static/css";
|
|
7
8
|
export declare const SVG_DIST_DIR = "static/svg";
|
|
@@ -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;
|
|
@@ -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): {
|
|
@@ -15,10 +15,6 @@ export declare const setupServerHooks: ({ compiler, token, callbacks: { onDone,
|
|
|
15
15
|
callbacks: ServerCallbacks;
|
|
16
16
|
}) => void;
|
|
17
17
|
export type CompilationMiddlewareOptions = {
|
|
18
|
-
/**
|
|
19
|
-
* To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable.
|
|
20
|
-
*/
|
|
21
|
-
clientPaths?: string[];
|
|
22
18
|
/**
|
|
23
19
|
* Should trigger when compiler hook called
|
|
24
20
|
*/
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
|
|
4
|
+
import type { SocketMessage } from './socketServer';
|
|
4
5
|
type HTTPServer = Server | Http2SecureServer;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type ExtractSocketMessageData<T extends SocketMessage['type']> = Extract<SocketMessage, {
|
|
7
|
+
type: T;
|
|
8
|
+
}> extends {
|
|
9
|
+
data: infer D;
|
|
10
|
+
} ? D : undefined;
|
|
11
|
+
export type SockWrite = <T extends SocketMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
|
|
7
12
|
export type RsbuildDevServer = {
|
|
8
13
|
/**
|
|
9
14
|
* The `connect` app instance.
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
import type { Socket } from 'node:net';
|
|
3
3
|
import type { DevConfig, EnvironmentContext, Rspack } from '../types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export type SocketMessageStaticChanged = {
|
|
5
|
+
type: 'static-changed' | 'content-changed';
|
|
6
|
+
};
|
|
7
|
+
export type SocketMessageHash = {
|
|
8
|
+
type: 'hash';
|
|
9
|
+
data: string;
|
|
10
|
+
};
|
|
11
|
+
export type SocketMessageOk = {
|
|
12
|
+
type: 'ok';
|
|
13
|
+
};
|
|
14
|
+
export type SocketMessageWarnings = {
|
|
15
|
+
type: 'warnings';
|
|
16
|
+
data: {
|
|
17
|
+
text: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type SocketMessageErrors = {
|
|
21
|
+
type: 'errors';
|
|
22
|
+
data: {
|
|
23
|
+
text: string[];
|
|
24
|
+
html: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type SocketMessage = SocketMessageOk | SocketMessageStaticChanged | SocketMessageHash | SocketMessageWarnings | SocketMessageErrors;
|
|
9
28
|
export declare class SocketServer {
|
|
10
29
|
private wsServer;
|
|
11
30
|
private readonly sockets;
|
|
@@ -27,11 +46,9 @@ export declare class SocketServer {
|
|
|
27
46
|
* if not provided, the message will be sent to all sockets
|
|
28
47
|
*/
|
|
29
48
|
sockWrite(message: SocketMessage, token?: string): void;
|
|
30
|
-
private singleWrite;
|
|
31
49
|
close(): Promise<void>;
|
|
32
50
|
private onConnect;
|
|
33
51
|
private getStats;
|
|
34
52
|
private sendStats;
|
|
35
53
|
private send;
|
|
36
54
|
}
|
|
37
|
-
export {};
|
|
@@ -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
|
/**
|
|
@@ -682,7 +683,7 @@ export type DistPathConfig = {
|
|
|
682
683
|
font?: string;
|
|
683
684
|
/**
|
|
684
685
|
* The output directory of HTML files.
|
|
685
|
-
* @default '
|
|
686
|
+
* @default './'
|
|
686
687
|
*/
|
|
687
688
|
html?: string;
|
|
688
689
|
/**
|
|
@@ -705,6 +706,11 @@ export type DistPathConfig = {
|
|
|
705
706
|
* @default 'static/assets'
|
|
706
707
|
*/
|
|
707
708
|
assets?: string;
|
|
709
|
+
/**
|
|
710
|
+
* The output directory of favicon.
|
|
711
|
+
* @default './'
|
|
712
|
+
*/
|
|
713
|
+
favicon?: string;
|
|
708
714
|
};
|
|
709
715
|
export type FilenameConfig = {
|
|
710
716
|
/**
|
|
@@ -1522,6 +1528,10 @@ export type RsbuildConfigMeta = {
|
|
|
1522
1528
|
*/
|
|
1523
1529
|
configFilePath: string;
|
|
1524
1530
|
};
|
|
1531
|
+
/**
|
|
1532
|
+
* Only some dev options can be defined in the environment config
|
|
1533
|
+
*/
|
|
1534
|
+
export type AllowedEnvironmentDevKeys = 'hmr' | 'liveReload' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk';
|
|
1525
1535
|
/**
|
|
1526
1536
|
* The Rsbuild config to run in the specified environment.
|
|
1527
1537
|
* */
|
|
@@ -1529,7 +1539,7 @@ export interface EnvironmentConfig {
|
|
|
1529
1539
|
/**
|
|
1530
1540
|
* Options for local development.
|
|
1531
1541
|
*/
|
|
1532
|
-
dev?: Pick<DevConfig,
|
|
1542
|
+
dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
|
|
1533
1543
|
/**
|
|
1534
1544
|
* Options for HTML generation.
|
|
1535
1545
|
*/
|
|
@@ -1617,7 +1627,7 @@ export interface RsbuildConfig extends EnvironmentConfig {
|
|
|
1617
1627
|
export type MergedEnvironmentConfig = {
|
|
1618
1628
|
mode: RsbuildMode;
|
|
1619
1629
|
root: string;
|
|
1620
|
-
dev: Pick<NormalizedDevConfig,
|
|
1630
|
+
dev: Pick<NormalizedDevConfig, AllowedEnvironmentDevKeys>;
|
|
1621
1631
|
html: NormalizedHtmlConfig;
|
|
1622
1632
|
tools: NormalizedToolsConfig;
|
|
1623
1633
|
resolve: NormalizedResolveConfig;
|
|
@@ -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.13",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -46,17 +46,17 @@
|
|
|
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",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.19",
|
|
59
|
-
"@types/node": "^22.
|
|
59
|
+
"@types/node": "^22.17.0",
|
|
60
60
|
"@types/on-finished": "2.3.5",
|
|
61
61
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
@@ -64,14 +64,13 @@
|
|
|
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",
|
|
71
70
|
"dotenv-expand": "12.0.2",
|
|
72
71
|
"html-rspack-plugin": "6.1.2",
|
|
73
72
|
"http-proxy-middleware": "^2.0.9",
|
|
74
|
-
"launch-editor-middleware": "^2.
|
|
73
|
+
"launch-editor-middleware": "^2.11.0",
|
|
75
74
|
"mrmime": "^2.0.1",
|
|
76
75
|
"on-finished": "2.4.1",
|
|
77
76
|
"open": "^10.2.0",
|
|
@@ -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
|
-
"typescript": "^5.
|
|
92
|
-
"webpack": "^5.
|
|
90
|
+
"typescript": "^5.9.2",
|
|
91
|
+
"webpack": "^5.101.0",
|
|
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"}
|