@rsbuild/plugin-assets-retry 1.0.7 → 1.1.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/README.md +1 -1
- package/dist/index.cjs +47 -24
- package/dist/index.js +57 -35
- package/dist/runtime/asyncChunkRetry.d.ts +6 -3
- package/dist/runtime/asyncChunkRetry.js +209 -200
- package/dist/runtime/asyncChunkRetry.min.js +1 -1
- package/dist/runtime/initialChunkRetry.d.ts +1 -0
- package/dist/runtime/initialChunkRetry.js +233 -274
- package/dist/runtime/initialChunkRetry.min.js +1 -1
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://rsbuild.dev" target="blank"><img src="https://
|
|
2
|
+
<a href="https://rsbuild.dev" target="blank"><img src="https://assets.rspack.dev/rsbuild/rsbuild-banner.png" alt="Rsbuild Logo" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# Rsbuild
|
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __webpack_modules__ = {
|
|
|
27
27
|
});
|
|
28
28
|
var str, functions = [], regexps = [], dates = [], maps = [], sets = [], arrays = [], undefs = [], infinities = [], bigInts = [], urls = [];
|
|
29
29
|
return (options.ignoreFunction && "function" == typeof obj && (obj = void 0), void 0 === obj) ? String(obj) : 'string' != typeof (str = options.isJSON && !options.space ? JSON.stringify(obj) : JSON.stringify(obj, options.isJSON ? null : function(key, value) {
|
|
30
|
-
if (options.ignoreFunction &&
|
|
30
|
+
if (options.ignoreFunction && function(obj) {
|
|
31
31
|
var functionKeys = [];
|
|
32
32
|
for(var key in obj)"function" == typeof obj[key] && functionKeys.push(key);
|
|
33
33
|
for(var i = 0; i < functionKeys.length; i++)delete obj[functionKeys[i]];
|
|
@@ -119,33 +119,41 @@ var __webpack_exports__ = {};
|
|
|
119
119
|
}) : obj[key] = value, obj;
|
|
120
120
|
}
|
|
121
121
|
let AsyncChunkRetryPlugin_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
|
|
122
|
+
function modifyRuntimeModule(module, modifier, isRspack) {
|
|
123
|
+
isRspack ? function(module, modifier) {
|
|
124
|
+
try {
|
|
125
|
+
let originSource = module.source.source.toString();
|
|
126
|
+
module.source.source = Buffer.from(modifier(originSource), 'utf-8');
|
|
127
|
+
} catch (err) {
|
|
128
|
+
throw console.error('Failed to modify Rspack RuntimeModule'), err;
|
|
129
|
+
}
|
|
130
|
+
}(module, modifier) : function(module, modifier) {
|
|
131
|
+
try {
|
|
132
|
+
let originSource = module.getGeneratedCode();
|
|
133
|
+
module.getGeneratedCode = ()=>modifier(originSource);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
throw console.error('Failed to modify Webpack RuntimeModule'), err;
|
|
136
|
+
}
|
|
137
|
+
}(module, modifier);
|
|
138
|
+
}
|
|
122
139
|
class AsyncChunkRetryPlugin {
|
|
123
140
|
getRawRuntimeRetryCode() {
|
|
124
141
|
let { RuntimeGlobals } = core_namespaceObject.rspack, filename = 'asyncChunkRetry', runtimeFilePath = external_node_path_default().join(AsyncChunkRetryPlugin_dirname, 'runtime', this.options.minify ? `${filename}.min.js` : `${filename}.js`);
|
|
125
|
-
return external_node_fs_default().readFileSync(runtimeFilePath, 'utf-8').replaceAll('__RUNTIME_GLOBALS_REQUIRE__', RuntimeGlobals.require).replaceAll('__RUNTIME_GLOBALS_ENSURE_CHUNK__', RuntimeGlobals.ensureChunk).replaceAll('__RUNTIME_GLOBALS_GET_CHUNK_SCRIPT_FILENAME__', RuntimeGlobals.getChunkScriptFilename).replaceAll('__RUNTIME_GLOBALS_GET_CSS_FILENAME__', RuntimeGlobals.getChunkCssFilename).replaceAll('__RUNTIME_GLOBALS_GET_MINI_CSS_EXTRACT_FILENAME__', '__webpack_require__.miniCssF').replaceAll('__RUNTIME_GLOBALS_PUBLIC_PATH__', RuntimeGlobals.publicPath).replaceAll('__RUNTIME_GLOBALS_LOAD_SCRIPT__', RuntimeGlobals.loadScript).replaceAll('__RETRY_OPTIONS__', serialize_javascript_default()(this.runtimeOptions));
|
|
142
|
+
return external_node_fs_default().readFileSync(runtimeFilePath, 'utf-8').replaceAll('__RUNTIME_GLOBALS_REQUIRE__', RuntimeGlobals.require).replaceAll('__RUNTIME_GLOBALS_ENSURE_CHUNK__', RuntimeGlobals.ensureChunk).replaceAll('__RUNTIME_GLOBALS_GET_CHUNK_SCRIPT_FILENAME__', RuntimeGlobals.getChunkScriptFilename).replaceAll('__RUNTIME_GLOBALS_GET_CSS_FILENAME__', RuntimeGlobals.getChunkCssFilename).replaceAll('__RUNTIME_GLOBALS_GET_MINI_CSS_EXTRACT_FILENAME__', '__webpack_require__.miniCssF').replaceAll('__RUNTIME_GLOBALS_RSBUILD_LOAD_STYLESHEET__', '__webpack_require__.rbLoadStyleSheet').replaceAll('__RUNTIME_GLOBALS_PUBLIC_PATH__', RuntimeGlobals.publicPath).replaceAll('__RUNTIME_GLOBALS_LOAD_SCRIPT__', RuntimeGlobals.loadScript).replaceAll('__RETRY_OPTIONS__', serialize_javascript_default()(this.runtimeOptions));
|
|
126
143
|
}
|
|
127
144
|
apply(compiler) {
|
|
128
145
|
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
129
146
|
compilation.hooks.runtimeModule.tap(this.name, (module)=>{
|
|
130
147
|
var _module_constructor;
|
|
131
148
|
let { isRspack } = this.options, constructorName = isRspack ? module.constructorName : null === (_module_constructor = module.constructor) || void 0 === _module_constructor ? void 0 : _module_constructor.name;
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
}(module, runtimeCode) : !function(module, appendSource) {
|
|
142
|
-
try {
|
|
143
|
-
let originSource = module.getGeneratedCode();
|
|
144
|
-
module.getGeneratedCode = ()=>`${originSource}\n${appendSource}`;
|
|
145
|
-
} catch (err) {
|
|
146
|
-
throw console.error('Failed to modify Webpack RuntimeModule'), err;
|
|
147
|
-
}
|
|
148
|
-
}(module, runtimeCode);
|
|
149
|
+
if ('CssLoadingRuntimeModule' === constructorName) {
|
|
150
|
+
modifyRuntimeModule(module, (originSource)=>originSource.replace('var fullhref = __webpack_require__.p + href;', 'var fullhref = __webpack_require__.rbLoadStyleSheet ? __webpack_require__.rbLoadStyleSheet(href, chunkId) : (__webpack_require__.p + href);'), isRspack);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if ('publicPath' === module.name || 'PublicPathRuntimeModule' === constructorName || 'AutoPublicPathRuntimeModule' === constructorName) {
|
|
154
|
+
let runtimeCode = this.getRawRuntimeRetryCode();
|
|
155
|
+
modifyRuntimeModule(module, (originSource)=>`${originSource}\n${runtimeCode}`, isRspack);
|
|
156
|
+
}
|
|
149
157
|
});
|
|
150
158
|
});
|
|
151
159
|
}
|
|
@@ -165,15 +173,30 @@ var __webpack_exports__ = {};
|
|
|
165
173
|
}
|
|
166
174
|
let src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), PLUGIN_ASSETS_RETRY_NAME = 'rsbuild:assets-retry';
|
|
167
175
|
async function getRetryCode(options) {
|
|
168
|
-
let filename = 'initialChunkRetry', { minify, inlineScript: _, ...restOptions } = options, runtimeFilePath = external_node_path_default().join(src_dirname, 'runtime', minify ? `${filename}.min.js` : `${filename}.js`), runtimeCode = await external_node_fs_default().promises.readFile(runtimeFilePath, 'utf-8')
|
|
169
|
-
|
|
176
|
+
let filename = 'initialChunkRetry', { minify, inlineScript: _, ...restOptions } = options, runtimeFilePath = external_node_path_default().join(src_dirname, 'runtime', minify ? `${filename}.min.js` : `${filename}.js`), runtimeCode = await external_node_fs_default().promises.readFile(runtimeFilePath, 'utf-8'), runtimeOptions = function(userOptions) {
|
|
177
|
+
let defaultOptions = {
|
|
178
|
+
max: 3,
|
|
179
|
+
type: [
|
|
180
|
+
'link',
|
|
181
|
+
"script",
|
|
182
|
+
'img'
|
|
183
|
+
],
|
|
184
|
+
domain: [],
|
|
185
|
+
crossOrigin: !1
|
|
186
|
+
}, result = {
|
|
187
|
+
...defaultOptions,
|
|
188
|
+
...userOptions
|
|
189
|
+
};
|
|
190
|
+
return Array.isArray(result.type) && 0 !== result.type.length || (result.type = defaultOptions.type), Array.isArray(result.domain) && 0 !== result.domain.length || (result.domain = defaultOptions.domain), Array.isArray(result.domain) && (result.domain = result.domain.filter(Boolean)), result;
|
|
191
|
+
}(restOptions);
|
|
192
|
+
return `(function(){${runtimeCode}})()`.replace('__RUNTIME_GLOBALS_OPTIONS__', serialize_javascript_default()(runtimeOptions));
|
|
170
193
|
}
|
|
171
194
|
let pluginAssetsRetry = (userOptions = {})=>({
|
|
172
195
|
name: PLUGIN_ASSETS_RETRY_NAME,
|
|
173
196
|
setup (api) {
|
|
174
197
|
let { inlineScript = !0 } = userOptions, getScriptPath = (environment)=>{
|
|
175
198
|
let distDir = environment.config.output.distPath.js;
|
|
176
|
-
return external_node_path_default().posix.join(distDir, "assets-retry.1-0
|
|
199
|
+
return external_node_path_default().posix.join(distDir, "assets-retry.1-1-0.js");
|
|
177
200
|
}, formatOptions = (config)=>{
|
|
178
201
|
let options = {
|
|
179
202
|
...userOptions
|
|
@@ -188,7 +211,7 @@ var __webpack_exports__ = {};
|
|
|
188
211
|
inlineScript ? api.modifyHTMLTags(async ({ headTags, bodyTags }, { environment })=>{
|
|
189
212
|
let code = await getRetryCode(formatOptions(environment.config));
|
|
190
213
|
return headTags.unshift({
|
|
191
|
-
tag:
|
|
214
|
+
tag: "script",
|
|
192
215
|
attrs: {},
|
|
193
216
|
children: code
|
|
194
217
|
}), {
|
|
@@ -198,7 +221,7 @@ var __webpack_exports__ = {};
|
|
|
198
221
|
}) : (api.modifyHTMLTags(async ({ headTags, bodyTags }, { assetPrefix, environment })=>{
|
|
199
222
|
let scriptPath = getScriptPath(environment), url = (0, core_namespaceObject.ensureAssetPrefix)(scriptPath, assetPrefix);
|
|
200
223
|
return headTags.unshift({
|
|
201
|
-
tag:
|
|
224
|
+
tag: "script",
|
|
202
225
|
attrs: {
|
|
203
226
|
src: url
|
|
204
227
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
6
6
|
var __webpack_modules__ = {
|
|
7
7
|
"../../node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
8
8
|
module.exports = __webpack_require__("crypto").randomBytes;
|
|
@@ -30,7 +30,7 @@ var __webpack_modules__ = {
|
|
|
30
30
|
});
|
|
31
31
|
var str, functions = [], regexps = [], dates = [], maps = [], sets = [], arrays = [], undefs = [], infinities = [], bigInts = [], urls = [];
|
|
32
32
|
return (options.ignoreFunction && "function" == typeof obj && (obj = void 0), void 0 === obj) ? String(obj) : 'string' != typeof (str = options.isJSON && !options.space ? JSON.stringify(obj) : JSON.stringify(obj, options.isJSON ? null : function(key, value) {
|
|
33
|
-
if (options.ignoreFunction &&
|
|
33
|
+
if (options.ignoreFunction && function(obj) {
|
|
34
34
|
var functionKeys = [];
|
|
35
35
|
for(var key in obj)"function" == typeof obj[key] && functionKeys.push(key);
|
|
36
36
|
for(var i = 0; i < functionKeys.length; i++)delete obj[functionKeys[i]];
|
|
@@ -102,40 +102,47 @@ function _define_property(obj, key, value) {
|
|
|
102
102
|
writable: !0
|
|
103
103
|
}) : obj[key] = value, obj;
|
|
104
104
|
}
|
|
105
|
-
let AsyncChunkRetryPlugin_dirname =
|
|
105
|
+
let AsyncChunkRetryPlugin_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url));
|
|
106
|
+
function modifyRuntimeModule(module, modifier, isRspack) {
|
|
107
|
+
isRspack ? function(module, modifier) {
|
|
108
|
+
try {
|
|
109
|
+
let originSource = module.source.source.toString();
|
|
110
|
+
module.source.source = Buffer.from(modifier(originSource), 'utf-8');
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw console.error('Failed to modify Rspack RuntimeModule'), err;
|
|
113
|
+
}
|
|
114
|
+
}(module, modifier) : function(module, modifier) {
|
|
115
|
+
try {
|
|
116
|
+
let originSource = module.getGeneratedCode();
|
|
117
|
+
module.getGeneratedCode = ()=>modifier(originSource);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
throw console.error('Failed to modify Webpack RuntimeModule'), err;
|
|
120
|
+
}
|
|
121
|
+
}(module, modifier);
|
|
122
|
+
}
|
|
106
123
|
class AsyncChunkRetryPlugin {
|
|
107
124
|
getRawRuntimeRetryCode() {
|
|
108
|
-
let { RuntimeGlobals } =
|
|
109
|
-
return
|
|
125
|
+
let { RuntimeGlobals } = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack, filename = 'asyncChunkRetry', runtimeFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(AsyncChunkRetryPlugin_dirname, 'runtime', this.options.minify ? `${filename}.min.js` : `${filename}.js`);
|
|
126
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(runtimeFilePath, 'utf-8').replaceAll('__RUNTIME_GLOBALS_REQUIRE__', RuntimeGlobals.require).replaceAll('__RUNTIME_GLOBALS_ENSURE_CHUNK__', RuntimeGlobals.ensureChunk).replaceAll('__RUNTIME_GLOBALS_GET_CHUNK_SCRIPT_FILENAME__', RuntimeGlobals.getChunkScriptFilename).replaceAll('__RUNTIME_GLOBALS_GET_CSS_FILENAME__', RuntimeGlobals.getChunkCssFilename).replaceAll('__RUNTIME_GLOBALS_GET_MINI_CSS_EXTRACT_FILENAME__', '__webpack_require__.miniCssF').replaceAll('__RUNTIME_GLOBALS_RSBUILD_LOAD_STYLESHEET__', '__webpack_require__.rbLoadStyleSheet').replaceAll('__RUNTIME_GLOBALS_PUBLIC_PATH__', RuntimeGlobals.publicPath).replaceAll('__RUNTIME_GLOBALS_LOAD_SCRIPT__', RuntimeGlobals.loadScript).replaceAll('__RETRY_OPTIONS__', serialize_javascript_default()(this.runtimeOptions));
|
|
110
127
|
}
|
|
111
128
|
apply(compiler) {
|
|
112
129
|
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
113
130
|
compilation.hooks.runtimeModule.tap(this.name, (module)=>{
|
|
114
131
|
var _module_constructor;
|
|
115
132
|
let { isRspack } = this.options, constructorName = isRspack ? module.constructorName : null === (_module_constructor = module.constructor) || void 0 === _module_constructor ? void 0 : _module_constructor.name;
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}(module, runtimeCode) : !function(module, appendSource) {
|
|
126
|
-
try {
|
|
127
|
-
let originSource = module.getGeneratedCode();
|
|
128
|
-
module.getGeneratedCode = ()=>`${originSource}\n${appendSource}`;
|
|
129
|
-
} catch (err) {
|
|
130
|
-
throw console.error('Failed to modify Webpack RuntimeModule'), err;
|
|
131
|
-
}
|
|
132
|
-
}(module, runtimeCode);
|
|
133
|
+
if ('CssLoadingRuntimeModule' === constructorName) {
|
|
134
|
+
modifyRuntimeModule(module, (originSource)=>originSource.replace('var fullhref = __webpack_require__.p + href;', 'var fullhref = __webpack_require__.rbLoadStyleSheet ? __webpack_require__.rbLoadStyleSheet(href, chunkId) : (__webpack_require__.p + href);'), isRspack);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if ('publicPath' === module.name || 'PublicPathRuntimeModule' === constructorName || 'AutoPublicPathRuntimeModule' === constructorName) {
|
|
138
|
+
let runtimeCode = this.getRawRuntimeRetryCode();
|
|
139
|
+
modifyRuntimeModule(module, (originSource)=>`${originSource}\n${runtimeCode}`, isRspack);
|
|
140
|
+
}
|
|
133
141
|
});
|
|
134
142
|
});
|
|
135
143
|
}
|
|
136
144
|
constructor(options){
|
|
137
|
-
|
|
138
|
-
_define_property(this, "name", 'ASYNC_CHUNK_RETRY_PLUGIN'), _define_property(this, "options", void 0), _define_property(this, "runtimeOptions", void 0), this.options = options, this.runtimeOptions = (obj = options, [
|
|
145
|
+
_define_property(this, "name", 'ASYNC_CHUNK_RETRY_PLUGIN'), _define_property(this, "options", void 0), _define_property(this, "runtimeOptions", void 0), this.options = options, this.runtimeOptions = [
|
|
139
146
|
'domain',
|
|
140
147
|
'max',
|
|
141
148
|
'onRetry',
|
|
@@ -143,20 +150,35 @@ class AsyncChunkRetryPlugin {
|
|
|
143
150
|
'onFail',
|
|
144
151
|
'addQuery',
|
|
145
152
|
'test'
|
|
146
|
-
].reduce((ret, key)=>(void 0 !==
|
|
153
|
+
].reduce((ret, key)=>(void 0 !== options[key] && (ret[key] = options[key]), ret), {});
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
|
-
let src_dirname =
|
|
156
|
+
let src_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url)), PLUGIN_ASSETS_RETRY_NAME = 'rsbuild:assets-retry';
|
|
150
157
|
async function getRetryCode(options) {
|
|
151
|
-
let filename = 'initialChunkRetry', { minify, inlineScript: _, ...restOptions } = options, runtimeFilePath =
|
|
152
|
-
|
|
158
|
+
let filename = 'initialChunkRetry', { minify, inlineScript: _, ...restOptions } = options, runtimeFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(src_dirname, 'runtime', minify ? `${filename}.min.js` : `${filename}.js`), runtimeCode = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(runtimeFilePath, 'utf-8'), runtimeOptions = function(userOptions) {
|
|
159
|
+
let defaultOptions = {
|
|
160
|
+
max: 3,
|
|
161
|
+
type: [
|
|
162
|
+
'link',
|
|
163
|
+
"script",
|
|
164
|
+
'img'
|
|
165
|
+
],
|
|
166
|
+
domain: [],
|
|
167
|
+
crossOrigin: !1
|
|
168
|
+
}, result = {
|
|
169
|
+
...defaultOptions,
|
|
170
|
+
...userOptions
|
|
171
|
+
};
|
|
172
|
+
return Array.isArray(result.type) && 0 !== result.type.length || (result.type = defaultOptions.type), Array.isArray(result.domain) && 0 !== result.domain.length || (result.domain = defaultOptions.domain), Array.isArray(result.domain) && (result.domain = result.domain.filter(Boolean)), result;
|
|
173
|
+
}(restOptions);
|
|
174
|
+
return `(function(){${runtimeCode}})()`.replace('__RUNTIME_GLOBALS_OPTIONS__', serialize_javascript_default()(runtimeOptions));
|
|
153
175
|
}
|
|
154
176
|
let pluginAssetsRetry = (userOptions = {})=>({
|
|
155
177
|
name: PLUGIN_ASSETS_RETRY_NAME,
|
|
156
178
|
setup (api) {
|
|
157
179
|
let { inlineScript = !0 } = userOptions, getScriptPath = (environment)=>{
|
|
158
180
|
let distDir = environment.config.output.distPath.js;
|
|
159
|
-
return
|
|
181
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.posix.join(distDir, "assets-retry.1-1-0.js");
|
|
160
182
|
}, formatOptions = (config)=>{
|
|
161
183
|
let options = {
|
|
162
184
|
...userOptions
|
|
@@ -171,7 +193,7 @@ let pluginAssetsRetry = (userOptions = {})=>({
|
|
|
171
193
|
inlineScript ? api.modifyHTMLTags(async ({ headTags, bodyTags }, { environment })=>{
|
|
172
194
|
let code = await getRetryCode(formatOptions(environment.config));
|
|
173
195
|
return headTags.unshift({
|
|
174
|
-
tag:
|
|
196
|
+
tag: "script",
|
|
175
197
|
attrs: {},
|
|
176
198
|
children: code
|
|
177
199
|
}), {
|
|
@@ -179,9 +201,9 @@ let pluginAssetsRetry = (userOptions = {})=>({
|
|
|
179
201
|
bodyTags
|
|
180
202
|
};
|
|
181
203
|
}) : (api.modifyHTMLTags(async ({ headTags, bodyTags }, { assetPrefix, environment })=>{
|
|
182
|
-
let scriptPath = getScriptPath(environment), url = (0,
|
|
204
|
+
let scriptPath = getScriptPath(environment), url = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.ensureAssetPrefix)(scriptPath, assetPrefix);
|
|
183
205
|
return headTags.unshift({
|
|
184
|
-
tag:
|
|
206
|
+
tag: "script",
|
|
185
207
|
attrs: {
|
|
186
208
|
src: url
|
|
187
209
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import type { RuntimeRetryOptions } from '../types.js';
|
|
2
1
|
type ChunkId = string;
|
|
3
2
|
type ChunkFilename = string;
|
|
4
3
|
type ChunkSrcUrl = string;
|
|
4
|
+
type EnsureChunk = (chunkId: ChunkId, ...args: unknown[]) => Promise<unknown>;
|
|
5
|
+
type LoadScript = (url: ChunkSrcUrl, done: unknown, key: string, chunkId: ChunkId, ...args: unknown[]) => void;
|
|
6
|
+
type LoadStyleSheet = (href: string, chunkId: ChunkId) => string;
|
|
5
7
|
declare global {
|
|
6
8
|
var __RUNTIME_GLOBALS_REQUIRE__: unknown;
|
|
7
|
-
var __RUNTIME_GLOBALS_ENSURE_CHUNK__:
|
|
9
|
+
var __RUNTIME_GLOBALS_ENSURE_CHUNK__: EnsureChunk;
|
|
8
10
|
var __RUNTIME_GLOBALS_GET_CHUNK_SCRIPT_FILENAME__: (chunkId: ChunkId, ...args: unknown[]) => string;
|
|
9
11
|
var __RUNTIME_GLOBALS_GET_CSS_FILENAME__: ((chunkId: ChunkId, ...args: unknown[]) => string) | undefined;
|
|
10
12
|
var __RUNTIME_GLOBALS_GET_MINI_CSS_EXTRACT_FILENAME__: ((chunkId: ChunkId, ...args: unknown[]) => string) | undefined;
|
|
11
|
-
var __RUNTIME_GLOBALS_LOAD_SCRIPT__:
|
|
13
|
+
var __RUNTIME_GLOBALS_LOAD_SCRIPT__: LoadScript;
|
|
14
|
+
var __RUNTIME_GLOBALS_RSBUILD_LOAD_STYLESHEET__: LoadStyleSheet;
|
|
12
15
|
var __RUNTIME_GLOBALS_PUBLIC_PATH__: string;
|
|
13
16
|
var __RETRY_OPTIONS__: RuntimeRetryOptions;
|
|
14
17
|
var __RB_ASYNC_CHUNKS__: Record<ChunkFilename, boolean>;
|