@rollup-extras/plugin-html 2.1.0 → 2.1.2
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 +2 -0
- package/asset-factories.js +9 -4
- package/index.js +18 -14
- package/package.json +1 -1
package/README.md
CHANGED
package/asset-factories.js
CHANGED
|
@@ -35,10 +35,15 @@ export function simpleModuleScript(predicateSource) {
|
|
|
35
35
|
|
|
36
36
|
export function combineAssetFactories(...factories) {
|
|
37
37
|
return (fileName, content, type) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
return next(0);
|
|
39
|
+
|
|
40
|
+
function next(start) {
|
|
41
|
+
for (let index = start; index < factories.length; index++) {
|
|
42
|
+
const result = factories[index](fileName, content, type);
|
|
43
|
+
if (result instanceof Promise) {
|
|
44
|
+
return result.then(asset => asset || next(index + 1));
|
|
45
|
+
}
|
|
46
|
+
if (result) return result;
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
};
|
package/index.js
CHANGED
|
@@ -79,18 +79,18 @@ export default function (options = {}) {
|
|
|
79
79
|
handleTemplateReadError(e);
|
|
80
80
|
}
|
|
81
81
|
} else {
|
|
82
|
-
templateString =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
templateString = readFile(template, { encoding: 'utf8' })
|
|
83
|
+
.then(newTemplateString => {
|
|
84
|
+
if (!isUsableByDefaultTemplateFactory(newTemplateString) && !hasCustomTemplateFactory) {
|
|
85
|
+
warnAboutUsingDefaultTemplate();
|
|
86
|
+
return defaultTemplate;
|
|
87
|
+
}
|
|
88
|
+
return newTemplateString;
|
|
89
|
+
})
|
|
90
|
+
.catch(e => {
|
|
91
|
+
handleTemplateReadError(e);
|
|
92
|
+
return defaultTemplate;
|
|
93
|
+
});
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -245,7 +245,7 @@ export default function (options = {}) {
|
|
|
245
245
|
const dir = options.dir ?? '';
|
|
246
246
|
for (const fileName of Object.keys(bundle)) {
|
|
247
247
|
const relativeToRootAssetPath = join(dir, fileName);
|
|
248
|
-
const assetPath =
|
|
248
|
+
const assetPath = getAssetPath(relativeToRootAssetPath);
|
|
249
249
|
if (ignore(relativeToRootAssetPath) || processedFiles.has(relativeToRootAssetPath)) {
|
|
250
250
|
continue;
|
|
251
251
|
}
|
|
@@ -285,7 +285,7 @@ export default function (options = {}) {
|
|
|
285
285
|
if (modulepreload && options.format === 'es') {
|
|
286
286
|
const transitiveImports = collectTransitiveImports(bundle, fileName);
|
|
287
287
|
for (const importFileName of transitiveImports) {
|
|
288
|
-
const importAssetPath =
|
|
288
|
+
const importAssetPath = getAssetPath(join(dir, importFileName));
|
|
289
289
|
(assets.asset).push({
|
|
290
290
|
html: getModulePreloadElement(importAssetPath),
|
|
291
291
|
head: true,
|
|
@@ -298,6 +298,10 @@ export default function (options = {}) {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
function getAssetPath(fileName) {
|
|
302
|
+
return relative(dirname(fileNameInInitialDir), fileName).replaceAll('\\', '/');
|
|
303
|
+
}
|
|
304
|
+
|
|
301
305
|
async function useAssetFactory(fileName, relativeToRootAssetPath, source, format) {
|
|
302
306
|
if (assetsFactory) {
|
|
303
307
|
try {
|
package/package.json
CHANGED