@bddjr/vite-plugin-singlefile 3.0.1 → 3.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -15
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -91,20 +91,17 @@ async function generateBundle(bundle, config, options) {
91
91
  linkStylesheet[0].before(e);
92
92
  for (const e of linkStylesheet) e.remove();
93
93
  }
94
- const assetsDataURL = {};
95
94
  if (options.tryInlineHtmlAssets) for (const element of document.querySelectorAll(assetsSrcSelector)) {
96
95
  const name = cutPrefix(element.src, assetsDirWithBase);
97
96
  if (/\.js$/i.test(name)) continue;
98
- if (!Object.prototype.hasOwnProperty.call(assetsDataURL, name)) {
99
- const bundleName = assetsDir + name;
100
- const a = bundle[bundleName];
101
- if (!a) continue;
102
- thisDel.add(bundleName);
103
- let dataURL;
104
- if (Object.prototype.hasOwnProperty.call(globalAssetsDataURL, name)) dataURL = globalAssetsDataURL[name];
105
- else globalAssetsDataURL[name] = dataURL = bufferToDataURL(name, Buffer.from(a.source));
106
- element.src = dataURL;
107
- }
97
+ const bundleName = assetsDir + name;
98
+ const a = bundle[bundleName];
99
+ if (!a) continue;
100
+ thisDel.add(bundleName);
101
+ let dataURL;
102
+ if (Object.prototype.hasOwnProperty.call(globalAssetsDataURL, name)) dataURL = globalAssetsDataURL[name];
103
+ else globalAssetsDataURL[name] = dataURL = bufferToDataURL(name, Buffer.from(a.source));
104
+ element.src = dataURL;
108
105
  }
109
106
  if (options.tryInlineHtmlPublicIcon) {
110
107
  let needInline = true;
@@ -145,10 +142,7 @@ async function generateBundle(bundle, config, options) {
145
142
  code = code.replace(/;?\n?$/, "");
146
143
  for (const name of bundleAssetsNames) {
147
144
  const assetName = name.slice(assetsDir.length);
148
- if (code.includes(assetName)) {
149
- globalDoNotDelete.add(name);
150
- delete assetsDataURL[assetName];
151
- }
145
+ if (code.includes(assetName)) globalDoNotDelete.add(name);
152
146
  }
153
147
  let outputScript = code.replaceAll("<\/script", "<\\/script");
154
148
  if (/\b__VITE_PRELOAD__\b/.test(code)) outputScript = "var __VITE_PRELOAD__;" + outputScript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bddjr/vite-plugin-singlefile",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "author": "bddjr",
5
5
  "license": "MIT",
6
6
  "description": "Embed all assets into dist/index.html",
@@ -44,7 +44,6 @@
44
44
  "vite-plugin-singlefile"
45
45
  ],
46
46
  "dependencies": {
47
- "@types/node": "*",
48
47
  "jsdom": ">=28.1.0",
49
48
  "mime": ">=4.1.0",
50
49
  "mini-svg-data-uri": ">=1.4.4",