@rspack/core 0.6.1-canary-73a9832-20240414004901 → 0.6.1-canary-a6841aa-20240417004703
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/dist/Compilation.d.ts +6 -6
- package/dist/Compilation.js +3 -4
- package/dist/Compiler.d.ts +5 -5
- package/dist/Compiler.js +8 -8
- package/dist/MultiCompiler.d.ts +8 -18
- package/dist/MultiCompiler.js +7 -17
- package/dist/MultiWatching.d.ts +2 -10
- package/dist/MultiWatching.js +2 -10
- package/dist/RuntimeGlobals.d.ts +10 -10
- package/dist/RuntimeGlobals.js +10 -10
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +8 -3
- package/dist/builtin-plugin/IgnorePlugin.js +15 -1
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.js +1 -1
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/config/adapter.js +1 -0
- package/dist/config/adapterRuleUse.d.ts +1 -1
- package/dist/config/defaults.js +2 -2
- package/dist/config/normalization.d.ts +2 -2
- package/dist/config/zod.d.ts +125 -67
- package/dist/config/zod.js +1 -0
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +44 -846
- package/dist/exports.js +6 -4
- package/dist/lib/ModuleFilenameHelpers.d.ts +44 -6
- package/dist/lib/ModuleFilenameHelpers.js +50 -26
- package/package.json +7 -5
- package/dist/ModuleFilenameHelpers.d.ts +0 -44
- package/dist/ModuleFilenameHelpers.js +0 -76
package/dist/exports.js
CHANGED
|
@@ -24,10 +24,12 @@ var MultiStats_1 = require("./MultiStats");
|
|
|
24
24
|
Object.defineProperty(exports, "MultiStats", { enumerable: true, get: function () { return MultiStats_1.MultiStats; } });
|
|
25
25
|
var NormalModule_1 = require("./NormalModule");
|
|
26
26
|
Object.defineProperty(exports, "NormalModule", { enumerable: true, get: function () { return NormalModule_1.NormalModule; } });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
// API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
|
|
28
|
+
const ModuleFilenameHelpers = require("./lib/ModuleFilenameHelpers");
|
|
29
|
+
exports.ModuleFilenameHelpers = ModuleFilenameHelpers;
|
|
30
|
+
// API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
|
|
31
|
+
const Template = require("./Template");
|
|
32
|
+
exports.Template = Template;
|
|
31
33
|
exports.WebpackError = Error;
|
|
32
34
|
const sources = require("webpack-sources"); // use require to avoid wrong types, @types/webpack-sources is outdate
|
|
33
35
|
exports.sources = sources;
|
|
@@ -1,6 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
type Matcher = string | RegExp | (string | RegExp)[];
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function that returns the string with the token replaced with the replacement
|
|
4
|
+
* @example
|
|
5
|
+
* ```js
|
|
6
|
+
* const test = asRegExp("test");
|
|
7
|
+
* test.test("test"); // true
|
|
8
|
+
*
|
|
9
|
+
* const test2 = asRegExp(/test/);
|
|
10
|
+
* test2.test("test"); // true
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const asRegExp: (test: string | RegExp) => RegExp;
|
|
14
|
+
export declare const matchPart: (str: string, test: Matcher) => boolean;
|
|
15
|
+
interface MatchObject {
|
|
16
|
+
test?: Matcher;
|
|
17
|
+
include?: Matcher;
|
|
18
|
+
exclude?: Matcher;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Tests if a string matches a match object. The match object can have the following properties:
|
|
22
|
+
* - `test`: a RegExp or an array of RegExp
|
|
23
|
+
* - `include`: a RegExp or an array of RegExp
|
|
24
|
+
* - `exclude`: a RegExp or an array of RegExp
|
|
25
|
+
*
|
|
26
|
+
* The `test` property is tested first, then `include` and then `exclude`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```js
|
|
30
|
+
* ModuleFilenameHelpers.matchObject({ test: "foo.js" }, "foo.js"); // true
|
|
31
|
+
* ModuleFilenameHelpers.matchObject({ test: /^foo/ }, "foo.js"); // true
|
|
32
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "foo.js"); // true
|
|
33
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "baz.js"); // false
|
|
34
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "foo.js"); // true
|
|
35
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "bar.js"); // false
|
|
36
|
+
* ModuleFilenameHelpers.matchObject({ include: /^foo/ }, "foo.js"); // true
|
|
37
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "foo.js"); // true
|
|
38
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "baz.js"); // false
|
|
39
|
+
* ModuleFilenameHelpers.matchObject({ exclude: "foo.js" }, "foo.js"); // false
|
|
40
|
+
* ModuleFilenameHelpers.matchObject({ exclude: [/^foo/, "bar"] }, "foo.js"); // false
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const matchObject: (obj: MatchObject, str: string) => boolean;
|
|
44
|
+
export {};
|
|
@@ -1,52 +1,76 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
1
|
"use strict";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchObject = exports.matchPart = exports.asRegExp = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function that returns the string with the token replaced with the replacement
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* const test = asRegExp("test");
|
|
9
|
+
* test.test("test"); // true
|
|
10
|
+
*
|
|
11
|
+
* const test2 = asRegExp(/test/);
|
|
12
|
+
* test2.test("test"); // true
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
const asRegExp = (test) => {
|
|
17
16
|
if (typeof test === "string") {
|
|
18
|
-
|
|
17
|
+
// Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
|
|
18
|
+
// adding a backslash before each special character
|
|
19
|
+
return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
|
19
20
|
}
|
|
20
21
|
return test;
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
exports.asRegExp = asRegExp;
|
|
24
|
+
const matchPart = (str, test) => {
|
|
24
25
|
if (!test)
|
|
25
26
|
return true;
|
|
26
|
-
test = asRegExp(test);
|
|
27
27
|
if (Array.isArray(test)) {
|
|
28
|
-
return test.map(asRegExp).some(regExp => regExp.test(str));
|
|
28
|
+
return test.map(exports.asRegExp).some(regExp => regExp.test(str));
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
return test.test(str);
|
|
31
|
+
return (0, exports.asRegExp)(test).test(str);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
exports.matchPart = matchPart;
|
|
35
|
+
/**
|
|
36
|
+
* Tests if a string matches a match object. The match object can have the following properties:
|
|
37
|
+
* - `test`: a RegExp or an array of RegExp
|
|
38
|
+
* - `include`: a RegExp or an array of RegExp
|
|
39
|
+
* - `exclude`: a RegExp or an array of RegExp
|
|
40
|
+
*
|
|
41
|
+
* The `test` property is tested first, then `include` and then `exclude`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```js
|
|
45
|
+
* ModuleFilenameHelpers.matchObject({ test: "foo.js" }, "foo.js"); // true
|
|
46
|
+
* ModuleFilenameHelpers.matchObject({ test: /^foo/ }, "foo.js"); // true
|
|
47
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "foo.js"); // true
|
|
48
|
+
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "baz.js"); // false
|
|
49
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "foo.js"); // true
|
|
50
|
+
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "bar.js"); // false
|
|
51
|
+
* ModuleFilenameHelpers.matchObject({ include: /^foo/ }, "foo.js"); // true
|
|
52
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "foo.js"); // true
|
|
53
|
+
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "baz.js"); // false
|
|
54
|
+
* ModuleFilenameHelpers.matchObject({ exclude: "foo.js" }, "foo.js"); // false
|
|
55
|
+
* ModuleFilenameHelpers.matchObject({ exclude: [/^foo/, "bar"] }, "foo.js"); // false
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
const matchObject = (obj, str) => {
|
|
36
59
|
if (obj.test) {
|
|
37
|
-
if (!
|
|
60
|
+
if (!(0, exports.matchPart)(str, obj.test)) {
|
|
38
61
|
return false;
|
|
39
62
|
}
|
|
40
63
|
}
|
|
41
64
|
if (obj.include) {
|
|
42
|
-
if (!
|
|
65
|
+
if (!(0, exports.matchPart)(str, obj.include)) {
|
|
43
66
|
return false;
|
|
44
67
|
}
|
|
45
68
|
}
|
|
46
69
|
if (obj.exclude) {
|
|
47
|
-
if (
|
|
70
|
+
if ((0, exports.matchPart)(str, obj.exclude)) {
|
|
48
71
|
return false;
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
74
|
return true;
|
|
52
75
|
};
|
|
76
|
+
exports.matchObject = matchObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.6.1-canary-
|
|
3
|
+
"version": "0.6.1-canary-a6841aa-20240417004703",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"styled-components": "^6.0.8",
|
|
61
61
|
"terser": "5.27.2",
|
|
62
62
|
"wast-loader": "^1.11.4",
|
|
63
|
-
"@rspack/core": "0.6.1-canary-
|
|
64
|
-
"@rspack/plugin-minify": "^0.6.1-canary-
|
|
63
|
+
"@rspack/core": "0.6.1-canary-a6841aa-20240417004703",
|
|
64
|
+
"@rspack/plugin-minify": "^0.6.1-canary-a6841aa-20240417004703"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@module-federation/runtime-tools": "0.0.8",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"webpack-sources": "3.2.3",
|
|
77
77
|
"zod": "^3.21.4",
|
|
78
78
|
"zod-validation-error": "1.3.1",
|
|
79
|
-
"@rspack/binding": "0.6.1-canary-
|
|
79
|
+
"@rspack/binding": "0.6.1-canary-a6841aa-20240417004703"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@swc/helpers": ">=0.5.1"
|
|
@@ -89,6 +89,8 @@
|
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "tsc -b ./tsconfig.build.json",
|
|
91
91
|
"dev": "tsc -w",
|
|
92
|
-
"test": "cross-env NO_COLOR=1 node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage"
|
|
92
|
+
"test": "cross-env NO_COLOR=1 node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage",
|
|
93
|
+
"api-extractor": "api-extractor run --verbose",
|
|
94
|
+
"api-extractor:ci": "api-extractor run --verbose || diff temp/api.md etc/api.md"
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
type Matcher = string | RegExp | (string | RegExp)[];
|
|
2
|
-
/**
|
|
3
|
-
* Returns a function that returns the string with the token replaced with the replacement
|
|
4
|
-
* @example
|
|
5
|
-
* ```js
|
|
6
|
-
* const test = asRegExp("test");
|
|
7
|
-
* test.test("test"); // true
|
|
8
|
-
*
|
|
9
|
-
* const test2 = asRegExp(/test/);
|
|
10
|
-
* test2.test("test"); // true
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare const asRegExp: (test: string | RegExp) => RegExp;
|
|
14
|
-
export declare const matchPart: (str: string, test: Matcher) => boolean;
|
|
15
|
-
interface MatchObject {
|
|
16
|
-
test?: Matcher;
|
|
17
|
-
include?: Matcher;
|
|
18
|
-
exclude?: Matcher;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Tests if a string matches a match object. The match object can have the following properties:
|
|
22
|
-
* - `test`: a RegExp or an array of RegExp
|
|
23
|
-
* - `include`: a RegExp or an array of RegExp
|
|
24
|
-
* - `exclude`: a RegExp or an array of RegExp
|
|
25
|
-
*
|
|
26
|
-
* The `test` property is tested first, then `include` and then `exclude`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```js
|
|
30
|
-
* ModuleFilenameHelpers.matchObject({ test: "foo.js" }, "foo.js"); // true
|
|
31
|
-
* ModuleFilenameHelpers.matchObject({ test: /^foo/ }, "foo.js"); // true
|
|
32
|
-
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "foo.js"); // true
|
|
33
|
-
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "baz.js"); // false
|
|
34
|
-
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "foo.js"); // true
|
|
35
|
-
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "bar.js"); // false
|
|
36
|
-
* ModuleFilenameHelpers.matchObject({ include: /^foo/ }, "foo.js"); // true
|
|
37
|
-
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "foo.js"); // true
|
|
38
|
-
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "baz.js"); // false
|
|
39
|
-
* ModuleFilenameHelpers.matchObject({ exclude: "foo.js" }, "foo.js"); // false
|
|
40
|
-
* ModuleFilenameHelpers.matchObject({ exclude: [/^foo/, "bar"] }, "foo.js"); // false
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare const matchObject: (obj: MatchObject, str: string) => boolean;
|
|
44
|
-
export {};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchObject = exports.matchPart = exports.asRegExp = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Returns a function that returns the string with the token replaced with the replacement
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const test = asRegExp("test");
|
|
9
|
-
* test.test("test"); // true
|
|
10
|
-
*
|
|
11
|
-
* const test2 = asRegExp(/test/);
|
|
12
|
-
* test2.test("test"); // true
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
const asRegExp = (test) => {
|
|
16
|
-
if (typeof test === "string") {
|
|
17
|
-
// Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
|
|
18
|
-
// adding a backslash before each special character
|
|
19
|
-
return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
|
20
|
-
}
|
|
21
|
-
return test;
|
|
22
|
-
};
|
|
23
|
-
exports.asRegExp = asRegExp;
|
|
24
|
-
const matchPart = (str, test) => {
|
|
25
|
-
if (!test)
|
|
26
|
-
return true;
|
|
27
|
-
if (Array.isArray(test)) {
|
|
28
|
-
return test.map(exports.asRegExp).some(regExp => regExp.test(str));
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return (0, exports.asRegExp)(test).test(str);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
exports.matchPart = matchPart;
|
|
35
|
-
/**
|
|
36
|
-
* Tests if a string matches a match object. The match object can have the following properties:
|
|
37
|
-
* - `test`: a RegExp or an array of RegExp
|
|
38
|
-
* - `include`: a RegExp or an array of RegExp
|
|
39
|
-
* - `exclude`: a RegExp or an array of RegExp
|
|
40
|
-
*
|
|
41
|
-
* The `test` property is tested first, then `include` and then `exclude`.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```js
|
|
45
|
-
* ModuleFilenameHelpers.matchObject({ test: "foo.js" }, "foo.js"); // true
|
|
46
|
-
* ModuleFilenameHelpers.matchObject({ test: /^foo/ }, "foo.js"); // true
|
|
47
|
-
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "foo.js"); // true
|
|
48
|
-
* ModuleFilenameHelpers.matchObject({ test: [/^foo/, "bar"] }, "baz.js"); // false
|
|
49
|
-
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "foo.js"); // true
|
|
50
|
-
* ModuleFilenameHelpers.matchObject({ include: "foo.js" }, "bar.js"); // false
|
|
51
|
-
* ModuleFilenameHelpers.matchObject({ include: /^foo/ }, "foo.js"); // true
|
|
52
|
-
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "foo.js"); // true
|
|
53
|
-
* ModuleFilenameHelpers.matchObject({ include: [/^foo/, "bar"] }, "baz.js"); // false
|
|
54
|
-
* ModuleFilenameHelpers.matchObject({ exclude: "foo.js" }, "foo.js"); // false
|
|
55
|
-
* ModuleFilenameHelpers.matchObject({ exclude: [/^foo/, "bar"] }, "foo.js"); // false
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
const matchObject = (obj, str) => {
|
|
59
|
-
if (obj.test) {
|
|
60
|
-
if (!(0, exports.matchPart)(str, obj.test)) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (obj.include) {
|
|
65
|
-
if (!(0, exports.matchPart)(str, obj.include)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (obj.exclude) {
|
|
70
|
-
if ((0, exports.matchPart)(str, obj.exclude)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
};
|
|
76
|
-
exports.matchObject = matchObject;
|