@ohos-ports/rsbuild-core 2.2.9-beta.0
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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@rstackjs/load-config/index.d.ts +87 -0
- package/compiled/@rstackjs/load-config/license +21 -0
- package/compiled/@rstackjs/load-config/package.json +1 -0
- package/compiled/chokidar/index.d.ts +385 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect-next/index.d.ts +57 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/htmlLoader.js +157 -0
- package/compiled/html-rspack-plugin/index.d.ts +395 -0
- package/compiled/html-rspack-plugin/index.js +2400 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +455 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/LICENSE +21 -0
- package/compiled/jiti/README.md +258 -0
- package/compiled/jiti/dist/babel.cjs +47446 -0
- package/compiled/jiti/dist/jiti.cjs +5990 -0
- package/compiled/jiti/lib/jiti-cli.mjs +19 -0
- package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
- package/compiled/jiti/lib/jiti-native.mjs +76 -0
- package/compiled/jiti/lib/jiti-register.d.mts +1 -0
- package/compiled/jiti/lib/jiti-register.mjs +2 -0
- package/compiled/jiti/lib/jiti-static.mjs +19 -0
- package/compiled/jiti/lib/jiti.cjs +24 -0
- package/compiled/jiti/lib/jiti.d.cts +8 -0
- package/compiled/jiti/lib/jiti.d.mts +8 -0
- package/compiled/jiti/lib/jiti.mjs +23 -0
- package/compiled/jiti/lib/types.d.ts +420 -0
- package/compiled/jiti/package.json +146 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +139 -0
- package/compiled/postcss/lib/comment.d.ts +67 -0
- package/compiled/postcss/lib/container.d.ts +474 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +247 -0
- package/compiled/postcss/lib/declaration.d.ts +150 -0
- package/compiled/postcss/lib/document.d.ts +68 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +226 -0
- package/compiled/postcss/lib/lazy-result.d.ts +189 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +45 -0
- package/compiled/postcss/lib/node.d.ts +555 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +464 -0
- package/compiled/postcss/lib/previous-map.d.ts +80 -0
- package/compiled/postcss/lib/processor.d.ts +114 -0
- package/compiled/postcss/lib/result.d.ts +204 -0
- package/compiled/postcss/lib/root.d.ts +86 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +45 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +146 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +721 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +98 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +515 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +52 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +370 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/ws/index.d.ts +445 -0
- package/compiled/ws/license +21 -0
- package/compiled/ws/package.json +1 -0
- package/dist/build.d.ts +4 -0
- package/dist/c.js +10 -0
- package/dist/chokidar.js +2 -0
- package/dist/chokidar.js.LICENSE.txt +1 -0
- package/dist/cli/commands.d.ts +31 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/init.d.ts +7 -0
- package/dist/client/f~0.js +22 -0
- package/dist/client/hmr.js +267 -0
- package/dist/client/overlay.js +214 -0
- package/dist/configChain.d.ts +84 -0
- package/dist/connect-next.js +2 -0
- package/dist/connect-next.js.LICENSE.txt +57 -0
- package/dist/constants.d.ts +67 -0
- package/dist/cors.js +188 -0
- package/dist/cors.js.LICENSE.txt +11 -0
- package/dist/createCompiler.d.ts +6 -0
- package/dist/createContext.d.ts +12 -0
- package/dist/createRsbuild.d.ts +4 -0
- package/dist/cssUrlLoader.mjs +34 -0
- package/dist/defaultConfig.d.ts +23 -0
- package/dist/freshImport.js +90 -0
- package/dist/helpers/cachedImport.d.ts +2 -0
- package/dist/helpers/compiler.d.ts +5 -0
- package/dist/helpers/css.d.ts +3 -0
- package/dist/helpers/exitHook.d.ts +3 -0
- package/dist/helpers/format.d.ts +4 -0
- package/dist/helpers/fs.d.ts +16 -0
- package/dist/helpers/html.d.ts +2 -0
- package/dist/helpers/index.d.ts +29 -0
- package/dist/helpers/overlayConfig.d.ts +4 -0
- package/dist/helpers/packageJson.d.ts +9 -0
- package/dist/helpers/path.d.ts +22 -0
- package/dist/helpers/restartManager.d.ts +15 -0
- package/dist/helpers/stats.d.ts +17 -0
- package/dist/helpers/url.d.ts +11 -0
- package/dist/helpers/vendors.d.ts +12 -0
- package/dist/helpers/version.d.ts +7 -0
- package/dist/hooks.d.ts +41 -0
- package/dist/http-proxy-middleware.js +14 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +34 -0
- package/dist/ignoreCssLoader.mjs +9 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -0
- package/dist/initConfigs.d.ts +18 -0
- package/dist/initPlugins.d.ts +7 -0
- package/dist/inspectConfig.d.ts +7 -0
- package/dist/launch-editor-middleware.js +1 -0
- package/dist/loadConfig.d.ts +31 -0
- package/dist/loadEnv.d.ts +54 -0
- package/dist/loader/cssUrlLoader.d.ts +9 -0
- package/dist/loader/ignoreCssLoader.d.ts +10 -0
- package/dist/loader/transformLoader.d.ts +8 -0
- package/dist/loader/transformRawLoader.d.ts +4 -0
- package/dist/loader/workerLoader.d.ts +6 -0
- package/dist/logger.d.ts +24 -0
- package/dist/m.js +10348 -0
- package/dist/m.js.LICENSE.txt +26 -0
- package/dist/manifest-plugin.js +1 -0
- package/dist/memfs.js +1 -0
- package/dist/mergeConfig.d.ts +7 -0
- package/dist/open.js +2 -0
- package/dist/pluginHelper.d.ts +4 -0
- package/dist/pluginManager.d.ts +19 -0
- package/dist/plugins/appIcon.d.ts +2 -0
- package/dist/plugins/asset.d.ts +3 -0
- package/dist/plugins/basic.d.ts +4 -0
- package/dist/plugins/cache.d.ts +2 -0
- package/dist/plugins/cleanOutput.d.ts +2 -0
- package/dist/plugins/css.d.ts +8 -0
- package/dist/plugins/define.d.ts +2 -0
- package/dist/plugins/entry.d.ts +2 -0
- package/dist/plugins/externals.d.ts +9 -0
- package/dist/plugins/fileSize.d.ts +7 -0
- package/dist/plugins/html.d.ts +9 -0
- package/dist/plugins/inlineChunk.d.ts +6 -0
- package/dist/plugins/lazyCompilation.d.ts +2 -0
- package/dist/plugins/manifest.d.ts +2 -0
- package/dist/plugins/minimize.d.ts +10 -0
- package/dist/plugins/moduleFederation.d.ts +2 -0
- package/dist/plugins/nodeAddons.d.ts +2 -0
- package/dist/plugins/nonce.d.ts +2 -0
- package/dist/plugins/output.d.ts +2 -0
- package/dist/plugins/progress.d.ts +2 -0
- package/dist/plugins/resolve.d.ts +2 -0
- package/dist/plugins/resourceHints.d.ts +2 -0
- package/dist/plugins/rsdoctor.d.ts +2 -0
- package/dist/plugins/rspackProfile.d.ts +4 -0
- package/dist/plugins/server.d.ts +3 -0
- package/dist/plugins/sourceMap.d.ts +2 -0
- package/dist/plugins/splitChunks.d.ts +4 -0
- package/dist/plugins/sri.d.ts +2 -0
- package/dist/plugins/swc.d.ts +4 -0
- package/dist/plugins/target.d.ts +2 -0
- package/dist/plugins/wasm.d.ts +2 -0
- package/dist/plugins/worker.d.ts +2 -0
- package/dist/r.js +7 -0
- package/dist/range-parser.js +55 -0
- package/dist/range-parser.js.LICENSE.txt +6 -0
- package/dist/remapping.js +201 -0
- package/dist/restart.d.ts +15 -0
- package/dist/rslib-runtime.js +49 -0
- package/dist/rspack-plugins/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +36 -0
- package/dist/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +27 -0
- package/dist/rspack-plugins/resource-hints/extractChunks.d.ts +22 -0
- package/dist/rspack-plugins/resource-hints/getResourceType.d.ts +21 -0
- package/dist/rspackConfig.d.ts +8 -0
- package/dist/server/ansiHTML.d.ts +3 -0
- package/dist/server/assets-middleware/getFileFromUrl.d.ts +11 -0
- package/dist/server/assets-middleware/index.d.ts +35 -0
- package/dist/server/assets-middleware/memoryFileSystem.d.ts +2 -0
- package/dist/server/assets-middleware/middleware.d.ts +7 -0
- package/dist/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist/server/browserLogs.d.ts +8 -0
- package/dist/server/buildManager.d.ts +32 -0
- package/dist/server/cliShortcuts.d.ts +19 -0
- package/dist/server/compileState.d.ts +5 -0
- package/dist/server/devMiddlewares.d.ts +18 -0
- package/dist/server/devServer.d.ts +47 -0
- package/dist/server/environment.d.ts +8 -0
- package/dist/server/gracefulShutdown.d.ts +8 -0
- package/dist/server/gzipMiddleware.d.ts +2 -0
- package/dist/server/helper.d.ts +118 -0
- package/dist/server/historyApiFallback.d.ts +10 -0
- package/dist/server/hmrFallback.d.ts +1 -0
- package/dist/server/httpServer.d.ts +7 -0
- package/dist/server/middlewares.d.ts +31 -0
- package/dist/server/open.d.ts +12 -0
- package/dist/server/overlay.d.ts +3 -0
- package/dist/server/previewServer.d.ts +4 -0
- package/dist/server/proxy.d.ts +7 -0
- package/dist/server/publicPathnames.d.ts +2 -0
- package/dist/server/runner/asModule.d.ts +2 -0
- package/dist/server/runner/basic.d.ts +25 -0
- package/dist/server/runner/cjs.d.ts +10 -0
- package/dist/server/runner/esm.d.ts +6 -0
- package/dist/server/runner/index.d.ts +6 -0
- package/dist/server/runner/type.d.ts +42 -0
- package/dist/server/serverSetup.d.ts +2 -0
- package/dist/server/socketServer.d.ts +113 -0
- package/dist/server/watchFiles.d.ts +15 -0
- package/dist/sirv.js +122 -0
- package/dist/tinyglobby.js +1 -0
- package/dist/trace-mapping.js +548 -0
- package/dist/transformLoader.mjs +36 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist/types/config.d.ts +1796 -0
- package/dist/types/context.d.ts +89 -0
- package/dist/types/hooks.d.ts +261 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/plugin.d.ts +479 -0
- package/dist/types/rsbuild.d.ts +241 -0
- package/dist/types/rspack.d.ts +10 -0
- package/dist/types/thirdParty.d.ts +161 -0
- package/dist/types/utils.d.ts +16 -0
- package/dist/workerLoader.mjs +94 -0
- package/dist/ws.js +2 -0
- package/package.json +107 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +422 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/* This loader renders the template with lodash.template if no other loader was found */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is a minimal implementation of `lodash.template`
|
|
6
|
+
* Modified based on lodash v4.17.21
|
|
7
|
+
* License: https://github.com/lodash/lodash/blob/main/LICENSE
|
|
8
|
+
*/
|
|
9
|
+
/** Used to match template delimiters. */
|
|
10
|
+
const reEscape = /<%-([\s\S]+?)%>/g;
|
|
11
|
+
/** Used to match template delimiters. */
|
|
12
|
+
const reEvaluate = /<%([\s\S]+?)%>/g;
|
|
13
|
+
/** Used to match template delimiters. */
|
|
14
|
+
const reInterpolate = /<%=([\s\S]+?)%>/g;
|
|
15
|
+
/** Used to match empty string literals in compiled template source. */
|
|
16
|
+
const reEmptyStringLeading = /\b__p \+= '';/g,
|
|
17
|
+
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
|
18
|
+
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
|
19
|
+
|
|
20
|
+
/** Used to match unescaped characters in compiled string literals. */
|
|
21
|
+
const reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
|
22
|
+
|
|
23
|
+
/** Used to escape characters for inclusion in compiled string literals. */
|
|
24
|
+
const stringEscapes = {
|
|
25
|
+
'\\': '\\',
|
|
26
|
+
"'": "'",
|
|
27
|
+
'\n': 'n',
|
|
28
|
+
'\r': 'r',
|
|
29
|
+
'\u2028': 'u2028',
|
|
30
|
+
'\u2029': 'u2029',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const WITH_PLACEHOLDER = 'function __with_placeholder__';
|
|
34
|
+
const escapeStringChar = (chr) => '\\' + stringEscapes[chr];
|
|
35
|
+
|
|
36
|
+
function template(string, interpolate = reInterpolate) {
|
|
37
|
+
let isEscaping;
|
|
38
|
+
let isEvaluating;
|
|
39
|
+
let index = 0;
|
|
40
|
+
let source = "__p += '";
|
|
41
|
+
|
|
42
|
+
// Compile the regexp to match each delimiter.
|
|
43
|
+
const reDelimiters = RegExp(
|
|
44
|
+
reEscape.source + '|' + interpolate.source + '|' + reEvaluate.source + '|$',
|
|
45
|
+
'g',
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
string.replace(
|
|
49
|
+
reDelimiters,
|
|
50
|
+
function (match, escapeValue, interpolateValue, evaluateValue, offset) {
|
|
51
|
+
// Escape characters that can't be included in string literals.
|
|
52
|
+
source += string
|
|
53
|
+
.slice(index, offset)
|
|
54
|
+
.replace(reUnescapedString, escapeStringChar);
|
|
55
|
+
|
|
56
|
+
// Replace delimiters with snippets.
|
|
57
|
+
if (escapeValue) {
|
|
58
|
+
isEscaping = true;
|
|
59
|
+
source += "' +\n__e(" + escapeValue + ") +\n'";
|
|
60
|
+
}
|
|
61
|
+
if (evaluateValue) {
|
|
62
|
+
isEvaluating = true;
|
|
63
|
+
source += "';\n" + evaluateValue + ";\n__p += '";
|
|
64
|
+
}
|
|
65
|
+
if (interpolateValue) {
|
|
66
|
+
source +=
|
|
67
|
+
"' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
|
68
|
+
}
|
|
69
|
+
index = offset + match.length;
|
|
70
|
+
|
|
71
|
+
// The JS engine embedded in Adobe products needs `match` returned in
|
|
72
|
+
// order to produce the correct `offset` value.
|
|
73
|
+
return match;
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
source += "';\n";
|
|
78
|
+
|
|
79
|
+
// Cleanup code by stripping empty strings.
|
|
80
|
+
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
|
81
|
+
.replace(reEmptyStringMiddle, '$1')
|
|
82
|
+
.replace(reEmptyStringTrailing, '$1;');
|
|
83
|
+
|
|
84
|
+
// Frame code as the function body.
|
|
85
|
+
source =
|
|
86
|
+
'function(' +
|
|
87
|
+
'data' +
|
|
88
|
+
') {\n' +
|
|
89
|
+
"let __t, __p = ''" +
|
|
90
|
+
(isEscaping ? ', __e = lodashEscape' : '') +
|
|
91
|
+
(isEvaluating
|
|
92
|
+
? ', __j = Array.prototype.join;\n' +
|
|
93
|
+
"function print() { __p += __j.call(arguments, '') }\n"
|
|
94
|
+
: ';\n') +
|
|
95
|
+
source +
|
|
96
|
+
'return __p\n}';
|
|
97
|
+
|
|
98
|
+
return { compiled: source, isEscaping };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = function (source) {
|
|
102
|
+
const options = this.getOptions();
|
|
103
|
+
const force = options.force || false;
|
|
104
|
+
const allLoadersButThisOne = this.loaders.filter(
|
|
105
|
+
(loader) => loader.normal !== module.exports,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// This loader shouldn't kick in if there is any other loader
|
|
109
|
+
if (allLoadersButThisOne.length > 0 && !force) {
|
|
110
|
+
return source;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Allow only one html-webpack-plugin loader to allow loader options in the webpack config
|
|
114
|
+
const htmlWebpackPluginLoaders = this.loaders.filter(
|
|
115
|
+
(loader) => loader.normal === module.exports,
|
|
116
|
+
);
|
|
117
|
+
const lastHtmlRspackPluginLoader =
|
|
118
|
+
htmlWebpackPluginLoaders[htmlWebpackPluginLoaders.length - 1];
|
|
119
|
+
if (this.loaders[this.loaderIndex] !== lastHtmlRspackPluginLoader) {
|
|
120
|
+
return source;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (/\.(c|m)?js$/.test(this.resourcePath) && !force) {
|
|
124
|
+
return source;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const escapeCode = `const htmlEscapes = {
|
|
128
|
+
"&": "&",
|
|
129
|
+
"<": "<",
|
|
130
|
+
">": ">",
|
|
131
|
+
'"': """,
|
|
132
|
+
"'": "'",
|
|
133
|
+
};
|
|
134
|
+
const escapeHtmlChar = (key) => htmlEscapes[key];
|
|
135
|
+
const reUnescapedHtml = /[&<>"']/g, reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
136
|
+
|
|
137
|
+
function lodashEscape(input) {
|
|
138
|
+
if (input === null || input === undefined) {
|
|
139
|
+
return '';
|
|
140
|
+
}
|
|
141
|
+
const string = typeof input === 'string' ? input : String(input);
|
|
142
|
+
return string && reHasUnescapedHtml.test(string)
|
|
143
|
+
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
|
144
|
+
: string;
|
|
145
|
+
};`;
|
|
146
|
+
|
|
147
|
+
// The following part renders the template with lodash as a minimalistic loader
|
|
148
|
+
// The WITH_PLACEHOLDER will be replaced with `with` in the next step
|
|
149
|
+
// to make the code compatible with SWC strict mode
|
|
150
|
+
const { compiled, isEscaping } = template(source, options.interpolate);
|
|
151
|
+
return `
|
|
152
|
+
module.exports = function (templateParams) { ${WITH_PLACEHOLDER}(templateParams) {
|
|
153
|
+
${isEscaping ? escapeCode : ''}
|
|
154
|
+
// Execute the lodash template
|
|
155
|
+
return (${compiled})();
|
|
156
|
+
}}`;
|
|
157
|
+
};
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { Compiler, Compilation } from '@rspack/core';
|
|
2
|
+
|
|
3
|
+
type FixedSizeArray<T extends number, U> = T extends 0 ? undefined[] : ReadonlyArray<U> & {
|
|
4
|
+
0: U;
|
|
5
|
+
length: T;
|
|
6
|
+
};
|
|
7
|
+
type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never;
|
|
8
|
+
type Append<T extends any[], U> = {
|
|
9
|
+
0: [U];
|
|
10
|
+
1: [T[0], U];
|
|
11
|
+
2: [T[0], T[1], U];
|
|
12
|
+
3: [T[0], T[1], T[2], U];
|
|
13
|
+
4: [T[0], T[1], T[2], T[3], U];
|
|
14
|
+
5: [T[0], T[1], T[2], T[3], T[4], U];
|
|
15
|
+
6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
|
|
16
|
+
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
|
|
17
|
+
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
|
|
18
|
+
}[Measure<T['length']>];
|
|
19
|
+
type AsArray<T> = T extends any[] ? T : [T];
|
|
20
|
+
type Fn<T, R> = (...args: AsArray<T>) => R;
|
|
21
|
+
type FnAsync<T, R> = (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void;
|
|
22
|
+
type FnPromise<T, R> = (...args: AsArray<T>) => Promise<R>;
|
|
23
|
+
type TapFunction = (...args: any[]) => any;
|
|
24
|
+
type UnsetAdditionalOptions = {
|
|
25
|
+
_UnsetAdditionalOptions: true;
|
|
26
|
+
};
|
|
27
|
+
type IfSet<X> = X extends UnsetAdditionalOptions ? unknown : X;
|
|
28
|
+
type Callback<E, T> = (error: E | null, result?: T) => void;
|
|
29
|
+
type InnerCallback<E, T> = (error?: E | null | false, result?: T) => void;
|
|
30
|
+
type FullTap = Tap & {
|
|
31
|
+
type: 'sync' | 'async' | 'promise';
|
|
32
|
+
fn: TapFunction;
|
|
33
|
+
};
|
|
34
|
+
type Tap = TapOptions & {
|
|
35
|
+
name: string;
|
|
36
|
+
};
|
|
37
|
+
type TapOptions = {
|
|
38
|
+
before?: string;
|
|
39
|
+
stage?: number;
|
|
40
|
+
};
|
|
41
|
+
type Options<AdditionalOptions = UnsetAdditionalOptions> = string | (Tap & IfSet<AdditionalOptions>);
|
|
42
|
+
interface HookInterceptor<_T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
43
|
+
name?: string;
|
|
44
|
+
tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
|
45
|
+
call?: (...args: any[]) => void;
|
|
46
|
+
loop?: (...args: any[]) => void;
|
|
47
|
+
error?: (err: Error) => void;
|
|
48
|
+
result?: (result: R) => void;
|
|
49
|
+
done?: () => void;
|
|
50
|
+
register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
51
|
+
}
|
|
52
|
+
type ArgumentNames<T extends any[]> = FixedSizeArray<T['length'], string>;
|
|
53
|
+
interface Hook<T = any, R = any, AdditionalOptions = UnsetAdditionalOptions> {
|
|
54
|
+
name?: string;
|
|
55
|
+
tap(opt: Options<AdditionalOptions>, fn: Fn<T, R>): void;
|
|
56
|
+
tapAsync(opt: Options<AdditionalOptions>, fn: FnAsync<T, R>): void;
|
|
57
|
+
tapPromise(opt: Options<AdditionalOptions>, fn: FnPromise<T, R>): void;
|
|
58
|
+
intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
|
|
59
|
+
isUsed(): boolean;
|
|
60
|
+
withOptions(opt: TapOptions & IfSet<AdditionalOptions>): Hook<T, R, AdditionalOptions>;
|
|
61
|
+
queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
|
|
62
|
+
}
|
|
63
|
+
declare class HookBase<T, R, AdditionalOptions = UnsetAdditionalOptions> implements Hook<T, R, AdditionalOptions> {
|
|
64
|
+
args: ArgumentNames<AsArray<T>>;
|
|
65
|
+
name?: string;
|
|
66
|
+
taps: (FullTap & IfSet<AdditionalOptions>)[];
|
|
67
|
+
interceptors: HookInterceptor<T, R, AdditionalOptions>[];
|
|
68
|
+
constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
|
|
69
|
+
intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
|
|
70
|
+
_runRegisterInterceptors(options: FullTap & IfSet<AdditionalOptions>): FullTap & IfSet<AdditionalOptions>;
|
|
71
|
+
_runCallInterceptors(...args: any[]): void;
|
|
72
|
+
_runErrorInterceptors(e: Error): void;
|
|
73
|
+
_runTapInterceptors(tap: FullTap & IfSet<AdditionalOptions>): void;
|
|
74
|
+
_runDoneInterceptors(): void;
|
|
75
|
+
_runResultInterceptors(r: R): void;
|
|
76
|
+
withOptions(options: TapOptions & IfSet<AdditionalOptions>): Hook<T, R, AdditionalOptions>;
|
|
77
|
+
isUsed(): boolean;
|
|
78
|
+
queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
|
|
79
|
+
callAsyncStageRange(_queried: QueriedHook<T, R, AdditionalOptions>, ..._args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
80
|
+
callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
81
|
+
promiseStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): Promise<R>;
|
|
82
|
+
promise(...args: AsArray<T>): Promise<R>;
|
|
83
|
+
tap(options: Options<AdditionalOptions>, fn: Fn<T, R>): void;
|
|
84
|
+
tapAsync(options: Options<AdditionalOptions>, fn: FnAsync<T, R>): void;
|
|
85
|
+
tapPromise(options: Options<AdditionalOptions>, fn: FnPromise<T, R>): void;
|
|
86
|
+
_tap(type: 'sync' | 'async' | 'promise', options: Options<AdditionalOptions>, fn: TapFunction): void;
|
|
87
|
+
_insert(item: FullTap & IfSet<AdditionalOptions>): void;
|
|
88
|
+
_prepareArgs(args: AsArray<T>): (T | undefined)[];
|
|
89
|
+
}
|
|
90
|
+
type StageRange = readonly [number, number];
|
|
91
|
+
declare class QueriedHook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
92
|
+
stageRange: StageRange;
|
|
93
|
+
hook: HookBase<T, R, AdditionalOptions>;
|
|
94
|
+
tapsInRange: (FullTap & IfSet<AdditionalOptions>)[];
|
|
95
|
+
constructor(stageRange: StageRange, hook: HookBase<T, R, AdditionalOptions>);
|
|
96
|
+
isUsed(): boolean;
|
|
97
|
+
call(...args: AsArray<T>): R;
|
|
98
|
+
callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
99
|
+
promise(...args: AsArray<T>): Promise<R>;
|
|
100
|
+
}
|
|
101
|
+
declare class AsyncSeriesWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends HookBase<T, AsArray<T>[0], AdditionalOptions> {
|
|
102
|
+
constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
|
|
103
|
+
callAsyncStageRange(queried: QueriedHook<T, AsArray<T>[0], AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, AsArray<T>[0]>>): void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare class HtmlRspackPlugin {
|
|
107
|
+
constructor(options?: HtmlRspackPlugin.Options);
|
|
108
|
+
|
|
109
|
+
/** Current HtmlRspackPlugin Major */
|
|
110
|
+
version: number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Options after html-webpack-plugin has been initialized with defaults
|
|
114
|
+
*/
|
|
115
|
+
options?: HtmlRspackPlugin.ProcessedOptions;
|
|
116
|
+
|
|
117
|
+
apply(compiler: Compiler): void;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated use `getCompilationHooks` instead
|
|
121
|
+
*/
|
|
122
|
+
static getHooks(compilation: Compilation): HtmlRspackPlugin.Hooks;
|
|
123
|
+
|
|
124
|
+
static getCompilationHooks(compilation: Compilation): HtmlRspackPlugin.Hooks;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Static helper to create a tag object to be get injected into the dom
|
|
128
|
+
*/
|
|
129
|
+
static createHtmlTagObject(
|
|
130
|
+
tagName: string,
|
|
131
|
+
attributes?: { [attributeName: string]: string | boolean },
|
|
132
|
+
innerHTML?: string,
|
|
133
|
+
): HtmlRspackPlugin.HtmlTagObject;
|
|
134
|
+
|
|
135
|
+
static readonly version: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare namespace HtmlRspackPlugin {
|
|
139
|
+
interface Options {
|
|
140
|
+
/**
|
|
141
|
+
* Emit the file only if it was changed.
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
cache?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* List all entries which should be injected
|
|
147
|
+
*/
|
|
148
|
+
chunks?: 'all' | string[];
|
|
149
|
+
/**
|
|
150
|
+
* Allows to control how chunks should be sorted before they are included to the html.
|
|
151
|
+
* @default 'auto'
|
|
152
|
+
*/
|
|
153
|
+
chunksSortMode?:
|
|
154
|
+
| 'auto'
|
|
155
|
+
// `none` is deprecated and an alias for `auto` now.
|
|
156
|
+
| 'none'
|
|
157
|
+
| 'manual'
|
|
158
|
+
| ((entryNameA: string, entryNameB: string) => number);
|
|
159
|
+
/**
|
|
160
|
+
* List all entries which should not be injected
|
|
161
|
+
*/
|
|
162
|
+
excludeChunks?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* Path to the favicon icon
|
|
165
|
+
*/
|
|
166
|
+
favicon?: false | string;
|
|
167
|
+
/**
|
|
168
|
+
* The file to write the HTML to.
|
|
169
|
+
* Supports subdirectories eg: `assets/admin.html`
|
|
170
|
+
* [name] will be replaced by the entry name
|
|
171
|
+
* Supports a function to generate the name
|
|
172
|
+
*
|
|
173
|
+
* @default 'index.html'
|
|
174
|
+
*/
|
|
175
|
+
filename?: string | ((entryName: string) => string);
|
|
176
|
+
/**
|
|
177
|
+
* By default the public path is set to `auto` - that way the html-webpack-plugin will try
|
|
178
|
+
* to set the publicPath according to the current filename and the webpack publicPath setting
|
|
179
|
+
*/
|
|
180
|
+
publicPath?: string | 'auto';
|
|
181
|
+
/**
|
|
182
|
+
* If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files.
|
|
183
|
+
* This is useful for cache busting
|
|
184
|
+
*/
|
|
185
|
+
hash?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Inject all assets into the given `template` or `templateContent`.
|
|
188
|
+
*/
|
|
189
|
+
inject?:
|
|
190
|
+
| false // Don't inject scripts
|
|
191
|
+
| true // Inject scripts into body
|
|
192
|
+
| 'body' // Inject scripts into body
|
|
193
|
+
| 'head'; // Inject scripts into head
|
|
194
|
+
/**
|
|
195
|
+
* Set up script loading
|
|
196
|
+
* blocking will result in <script src="..."></script>
|
|
197
|
+
* defer will result in <script defer src="..."></script>
|
|
198
|
+
*
|
|
199
|
+
* @default 'defer'
|
|
200
|
+
*/
|
|
201
|
+
scriptLoading?: 'blocking' | 'defer' | 'module' | 'systemjs-module';
|
|
202
|
+
/**
|
|
203
|
+
* Inject meta tags
|
|
204
|
+
*/
|
|
205
|
+
meta?:
|
|
206
|
+
| false // Disable injection
|
|
207
|
+
| {
|
|
208
|
+
[name: string]:
|
|
209
|
+
| string
|
|
210
|
+
| false // name content pair e.g. {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`
|
|
211
|
+
| { [attributeName: string]: string | boolean }; // custom properties e.g. { name:"viewport" content:"width=500, initial-scale=1" }
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* A function to minify the HTML
|
|
215
|
+
*/
|
|
216
|
+
minify?: (html: string) => string | Promise<string>;
|
|
217
|
+
/**
|
|
218
|
+
* Render errors into the HTML page
|
|
219
|
+
*/
|
|
220
|
+
showErrors?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* The `webpack` require path to the template.
|
|
223
|
+
* @see https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md
|
|
224
|
+
*/
|
|
225
|
+
template?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Allow to use a html string instead of reading from a file
|
|
228
|
+
*/
|
|
229
|
+
templateContent?:
|
|
230
|
+
| false // Use the template option instead to load a file
|
|
231
|
+
| string
|
|
232
|
+
| ((templateParameters: {
|
|
233
|
+
[option: string]: any;
|
|
234
|
+
}) => string | Promise<string>)
|
|
235
|
+
| Promise<string>;
|
|
236
|
+
/**
|
|
237
|
+
* Allows to overwrite the parameters used in the template
|
|
238
|
+
*/
|
|
239
|
+
templateParameters?:
|
|
240
|
+
| false // Pass an empty object to the template function
|
|
241
|
+
| ((
|
|
242
|
+
compilation: Compilation,
|
|
243
|
+
assets: {
|
|
244
|
+
publicPath: string;
|
|
245
|
+
js: Array<string>;
|
|
246
|
+
css: Array<string>;
|
|
247
|
+
favicon?: string;
|
|
248
|
+
},
|
|
249
|
+
assetTags: {
|
|
250
|
+
headTags: HtmlTagObject[];
|
|
251
|
+
bodyTags: HtmlTagObject[];
|
|
252
|
+
},
|
|
253
|
+
options: ProcessedOptions,
|
|
254
|
+
) => { [option: string]: any } | Promise<{ [option: string]: any }>)
|
|
255
|
+
| { [option: string]: any };
|
|
256
|
+
/**
|
|
257
|
+
* The title to use for the generated HTML document
|
|
258
|
+
*/
|
|
259
|
+
title?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Enforce self closing tags e.g. <link />
|
|
262
|
+
*/
|
|
263
|
+
xhtml?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through
|
|
266
|
+
* to your template.
|
|
267
|
+
*/
|
|
268
|
+
[option: string]: any;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The plugin options after adding default values
|
|
273
|
+
*/
|
|
274
|
+
type ProcessedOptions = {
|
|
275
|
+
// Preserve named properties alongside the index signature in Options.
|
|
276
|
+
[K in keyof Options as Exclude<K, 'minify'>]-?: Options[K];
|
|
277
|
+
} & Pick<Options, 'minify'>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The values which are available during template execution
|
|
281
|
+
*
|
|
282
|
+
* Please keep in mind that the `templateParameter` options allows to change them
|
|
283
|
+
*/
|
|
284
|
+
interface TemplateParameter {
|
|
285
|
+
compilation: Compilation;
|
|
286
|
+
htmlWebpackPlugin: {
|
|
287
|
+
tags: {
|
|
288
|
+
headTags: HtmlTagObject[];
|
|
289
|
+
bodyTags: HtmlTagObject[];
|
|
290
|
+
};
|
|
291
|
+
files: {
|
|
292
|
+
publicPath: string;
|
|
293
|
+
js: Array<string>;
|
|
294
|
+
css: Array<string>;
|
|
295
|
+
favicon?: string;
|
|
296
|
+
};
|
|
297
|
+
options: Options;
|
|
298
|
+
};
|
|
299
|
+
webpackConfig: any;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface AlterAssetTagsData {
|
|
303
|
+
assetTags: {
|
|
304
|
+
scripts: HtmlTagObject[];
|
|
305
|
+
styles: HtmlTagObject[];
|
|
306
|
+
meta: HtmlTagObject[];
|
|
307
|
+
};
|
|
308
|
+
publicPath: string;
|
|
309
|
+
outputName: string;
|
|
310
|
+
plugin: HtmlRspackPlugin;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface AlterAssetTagGroupsData {
|
|
314
|
+
headTags: HtmlTagObject[];
|
|
315
|
+
bodyTags: HtmlTagObject[];
|
|
316
|
+
outputName: string;
|
|
317
|
+
publicPath: string;
|
|
318
|
+
plugin: HtmlRspackPlugin;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
interface AfterTemplateExecutionData {
|
|
322
|
+
html: string;
|
|
323
|
+
headTags: HtmlTagObject[];
|
|
324
|
+
bodyTags: HtmlTagObject[];
|
|
325
|
+
outputName: string;
|
|
326
|
+
plugin: HtmlRspackPlugin;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface BeforeAssetTagGenerationData {
|
|
330
|
+
assets: {
|
|
331
|
+
publicPath: string;
|
|
332
|
+
js: Array<string>;
|
|
333
|
+
css: Array<string>;
|
|
334
|
+
favicon?: string;
|
|
335
|
+
};
|
|
336
|
+
outputName: string;
|
|
337
|
+
plugin: HtmlRspackPlugin;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface BeforeEmitData {
|
|
341
|
+
html: string;
|
|
342
|
+
outputName: string;
|
|
343
|
+
plugin: HtmlRspackPlugin;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
interface AfterEmitData {
|
|
347
|
+
outputName: string;
|
|
348
|
+
plugin: HtmlRspackPlugin;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface Hooks {
|
|
352
|
+
alterAssetTags: AsyncSeriesWaterfallHook<AlterAssetTagsData>;
|
|
353
|
+
alterAssetTagGroups: AsyncSeriesWaterfallHook<AlterAssetTagGroupsData>;
|
|
354
|
+
afterTemplateExecution: AsyncSeriesWaterfallHook<AfterTemplateExecutionData>;
|
|
355
|
+
beforeAssetTagGeneration: AsyncSeriesWaterfallHook<BeforeAssetTagGenerationData>;
|
|
356
|
+
beforeEmit: AsyncSeriesWaterfallHook<BeforeEmitData>;
|
|
357
|
+
afterEmit: AsyncSeriesWaterfallHook<AfterEmitData>;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* A tag element according to the htmlWebpackPlugin object notation
|
|
362
|
+
*/
|
|
363
|
+
interface HtmlTagObject {
|
|
364
|
+
/**
|
|
365
|
+
* Attributes of the html tag
|
|
366
|
+
* E.g. `{'disabled': true, 'value': 'demo'}`
|
|
367
|
+
*/
|
|
368
|
+
attributes: {
|
|
369
|
+
[attributeName: string]: string | boolean | null | undefined;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* The tag name e.g. `'div'`
|
|
373
|
+
*/
|
|
374
|
+
tagName: string;
|
|
375
|
+
/**
|
|
376
|
+
* The inner HTML
|
|
377
|
+
*/
|
|
378
|
+
innerHTML?: string;
|
|
379
|
+
/**
|
|
380
|
+
* Whether this html must not contain innerHTML
|
|
381
|
+
* @see https://www.w3.org/TR/html5/syntax.html#void-elements
|
|
382
|
+
*/
|
|
383
|
+
voidTag: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Meta information about the tag
|
|
386
|
+
* E.g. `{'plugin': 'html-webpack-plugin'}`
|
|
387
|
+
*/
|
|
388
|
+
meta: {
|
|
389
|
+
plugin?: string;
|
|
390
|
+
[metaAttributeName: string]: any;
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export = HtmlRspackPlugin;
|