@rsbuild/plugin-assets-retry 0.7.7 → 0.7.9

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/index.cjs CHANGED
@@ -58,11 +58,12 @@ var AssetsRetryPlugin_exports = {};
58
58
  __export(AssetsRetryPlugin_exports, {
59
59
  AssetsRetryPlugin: () => AssetsRetryPlugin
60
60
  });
61
- var import_node_path, import_shared, _retryOptions, AssetsRetryPlugin;
61
+ var import_node_path, import_core, import_shared, _retryOptions, AssetsRetryPlugin;
62
62
  var init_AssetsRetryPlugin = __esm({
63
63
  "src/AssetsRetryPlugin.ts"() {
64
64
  "use strict";
65
65
  import_node_path = __toESM(require("path"));
66
+ import_core = require("@rsbuild/core");
66
67
  import_shared = require("@rsbuild/shared");
67
68
  AssetsRetryPlugin = class {
68
69
  constructor(options) {
@@ -105,7 +106,7 @@ var init_AssetsRetryPlugin = __esm({
105
106
  if (!this.scriptPath) {
106
107
  this.scriptPath = import_node_path.default.posix.join(
107
108
  this.distDir,
108
- `assets-retry.${"0.7.7"}.js`
109
+ `assets-retry.${"0.7.9"}.js`
109
110
  );
110
111
  }
111
112
  return this.scriptPath;
@@ -136,7 +137,14 @@ var init_AssetsRetryPlugin = __esm({
136
137
  this.HtmlPlugin.getHooks(compilation).alterAssetTagGroups.tapPromise(
137
138
  this.name,
138
139
  async (data) => {
139
- const scriptTag = (0, import_shared.generateScriptTag)();
140
+ const scriptTag = {
141
+ tagName: "script",
142
+ attributes: {
143
+ type: "text/javascript"
144
+ },
145
+ voidTag: false,
146
+ meta: {}
147
+ };
140
148
  if (this.inlineScript) {
141
149
  data.headTags.unshift({
142
150
  ...scriptTag,
@@ -144,7 +152,10 @@ var init_AssetsRetryPlugin = __esm({
144
152
  });
145
153
  } else {
146
154
  const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
147
- const url = (0, import_shared.withPublicPath)(await this.getScriptPath(), publicPath);
155
+ const url = (0, import_core.ensureAssetPrefix)(
156
+ await this.getScriptPath(),
157
+ publicPath
158
+ );
148
159
  data.headTags.unshift({
149
160
  ...scriptTag,
150
161
  attributes: {
@@ -188,12 +199,23 @@ ${appendSource}`, "utf-8");
188
199
  throw err;
189
200
  }
190
201
  }
191
- var import_node_path2, import_core, import_shared2, import_serialize_javascript, AsyncChunkRetryPlugin;
202
+ function pick(obj, keys) {
203
+ return keys.reduce(
204
+ (ret, key) => {
205
+ if (obj[key] !== void 0) {
206
+ ret[key] = obj[key];
207
+ }
208
+ return ret;
209
+ },
210
+ {}
211
+ );
212
+ }
213
+ var import_node_path2, import_core2, import_shared2, import_serialize_javascript, AsyncChunkRetryPlugin;
192
214
  var init_AsyncChunkRetryPlugin = __esm({
193
215
  "src/AsyncChunkRetryPlugin.ts"() {
194
216
  "use strict";
195
217
  import_node_path2 = __toESM(require("path"));
196
- import_core = require("@rsbuild/core");
218
+ import_core2 = require("@rsbuild/core");
197
219
  import_shared2 = require("@rsbuild/shared");
198
220
  import_serialize_javascript = __toESM(require("serialize-javascript"));
199
221
  AsyncChunkRetryPlugin = class {
@@ -202,7 +224,7 @@ var init_AsyncChunkRetryPlugin = __esm({
202
224
  __publicField(this, "options");
203
225
  __publicField(this, "runtimeOptions");
204
226
  this.options = options;
205
- this.runtimeOptions = (0, import_shared2.pick)(options, [
227
+ this.runtimeOptions = pick(options, [
206
228
  "domain",
207
229
  "max",
208
230
  "onRetry",
@@ -213,7 +235,7 @@ var init_AsyncChunkRetryPlugin = __esm({
213
235
  ]);
214
236
  }
215
237
  getRawRuntimeRetryCode() {
216
- const { RuntimeGlobals } = import_core.rspack;
238
+ const { RuntimeGlobals } = import_core2.rspack;
217
239
  const filename = "asyncChunkRetry";
218
240
  const runtimeFilePath = import_node_path2.default.join(
219
241
  __dirname,
@@ -271,7 +293,7 @@ var pluginAssetsRetry = (options = {}) => ({
271
293
  }
272
294
  const { AssetsRetryPlugin: AssetsRetryPlugin2 } = await Promise.resolve().then(() => (init_AssetsRetryPlugin(), AssetsRetryPlugin_exports));
273
295
  const { AsyncChunkRetryPlugin: AsyncChunkRetryPlugin2 } = await Promise.resolve().then(() => (init_AsyncChunkRetryPlugin(), AsyncChunkRetryPlugin_exports));
274
- const distDir = (0, import_shared3.getDistPath)(config, "js");
296
+ const distDir = config.output.distPath.js;
275
297
  if (options.crossOrigin === void 0) {
276
298
  options.crossOrigin = config.html.crossorigin;
277
299
  }
package/dist/index.js CHANGED
@@ -34,12 +34,12 @@ var __privateSet = (obj, member, value, setter) => {
34
34
  return value;
35
35
  };
36
36
 
37
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
37
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.5.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
38
38
  import { fileURLToPath } from "url";
39
39
  import path from "path";
40
40
  var getFilename, getDirname, __dirname;
41
41
  var init_esm = __esm({
42
- "../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
42
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.5.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
43
43
  "use strict";
44
44
  getFilename = () => fileURLToPath(import.meta.url);
45
45
  getDirname = () => path.dirname(getFilename());
@@ -53,12 +53,8 @@ __export(AssetsRetryPlugin_exports, {
53
53
  AssetsRetryPlugin: () => AssetsRetryPlugin
54
54
  });
55
55
  import path2 from "path";
56
- import {
57
- fse,
58
- generateScriptTag,
59
- getPublicPathFromCompiler,
60
- withPublicPath
61
- } from "@rsbuild/shared";
56
+ import { ensureAssetPrefix } from "@rsbuild/core";
57
+ import { fse, getPublicPathFromCompiler } from "@rsbuild/shared";
62
58
  var _retryOptions, AssetsRetryPlugin;
63
59
  var init_AssetsRetryPlugin = __esm({
64
60
  "src/AssetsRetryPlugin.ts"() {
@@ -105,7 +101,7 @@ var init_AssetsRetryPlugin = __esm({
105
101
  if (!this.scriptPath) {
106
102
  this.scriptPath = path2.posix.join(
107
103
  this.distDir,
108
- `assets-retry.${"0.7.7"}.js`
104
+ `assets-retry.${"0.7.9"}.js`
109
105
  );
110
106
  }
111
107
  return this.scriptPath;
@@ -136,7 +132,14 @@ var init_AssetsRetryPlugin = __esm({
136
132
  this.HtmlPlugin.getHooks(compilation).alterAssetTagGroups.tapPromise(
137
133
  this.name,
138
134
  async (data) => {
139
- const scriptTag = generateScriptTag();
135
+ const scriptTag = {
136
+ tagName: "script",
137
+ attributes: {
138
+ type: "text/javascript"
139
+ },
140
+ voidTag: false,
141
+ meta: {}
142
+ };
140
143
  if (this.inlineScript) {
141
144
  data.headTags.unshift({
142
145
  ...scriptTag,
@@ -144,7 +147,10 @@ var init_AssetsRetryPlugin = __esm({
144
147
  });
145
148
  } else {
146
149
  const publicPath = getPublicPathFromCompiler(compiler);
147
- const url = withPublicPath(await this.getScriptPath(), publicPath);
150
+ const url = ensureAssetPrefix(
151
+ await this.getScriptPath(),
152
+ publicPath
153
+ );
148
154
  data.headTags.unshift({
149
155
  ...scriptTag,
150
156
  attributes: {
@@ -170,7 +176,7 @@ __export(AsyncChunkRetryPlugin_exports, {
170
176
  });
171
177
  import path3 from "path";
172
178
  import { rspack } from "@rsbuild/core";
173
- import { fse as fse2, pick } from "@rsbuild/shared";
179
+ import { fse as fse2 } from "@rsbuild/shared";
174
180
  import serialize from "serialize-javascript";
175
181
  function appendWebpackScript(module, appendSource) {
176
182
  try {
@@ -192,6 +198,17 @@ ${appendSource}`, "utf-8");
192
198
  throw err;
193
199
  }
194
200
  }
201
+ function pick(obj, keys) {
202
+ return keys.reduce(
203
+ (ret, key) => {
204
+ if (obj[key] !== void 0) {
205
+ ret[key] = obj[key];
206
+ }
207
+ return ret;
208
+ },
209
+ {}
210
+ );
211
+ }
195
212
  var AsyncChunkRetryPlugin;
196
213
  var init_AsyncChunkRetryPlugin = __esm({
197
214
  "src/AsyncChunkRetryPlugin.ts"() {
@@ -254,7 +271,7 @@ var init_AsyncChunkRetryPlugin = __esm({
254
271
 
255
272
  // src/index.ts
256
273
  init_esm();
257
- import { getDistPath, isHtmlDisabled } from "@rsbuild/shared";
274
+ import { isHtmlDisabled } from "@rsbuild/shared";
258
275
  var PLUGIN_ASSETS_RETRY_NAME = "rsbuild:assets-retry";
259
276
  var pluginAssetsRetry = (options = {}) => ({
260
277
  name: PLUGIN_ASSETS_RETRY_NAME,
@@ -267,7 +284,7 @@ var pluginAssetsRetry = (options = {}) => ({
267
284
  }
268
285
  const { AssetsRetryPlugin: AssetsRetryPlugin2 } = await Promise.resolve().then(() => (init_AssetsRetryPlugin(), AssetsRetryPlugin_exports));
269
286
  const { AsyncChunkRetryPlugin: AsyncChunkRetryPlugin2 } = await Promise.resolve().then(() => (init_AsyncChunkRetryPlugin(), AsyncChunkRetryPlugin_exports));
270
- const distDir = getDistPath(config, "js");
287
+ const distDir = config.output.distPath.js;
271
288
  if (options.crossOrigin === void 0) {
272
289
  options.crossOrigin = config.html.crossorigin;
273
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-assets-retry",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "Assets retry plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "serialize-javascript": "^6.0.2",
27
- "@rsbuild/shared": "0.7.7"
27
+ "@rsbuild/shared": "0.7.9"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.24.7",
@@ -34,10 +34,10 @@
34
34
  "html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
35
35
  "terser": "5.31.1",
36
36
  "typescript": "^5.4.2",
37
- "@rsbuild/core": "0.7.7"
37
+ "@rsbuild/core": "0.7.9"
38
38
  },
39
39
  "peerDependencies": {
40
- "@rsbuild/core": "^0.7.7"
40
+ "@rsbuild/core": "^0.7.9"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public",