@file-viewer/vite-plugin 2.1.6 → 2.1.8
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.js +15 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -946,6 +946,7 @@ function reportAssetCopy(results, targetRoot, mode) {
|
|
|
946
946
|
export function fileViewerRenderers(options = {}) {
|
|
947
947
|
const moduleId = options.moduleId || virtualModuleId;
|
|
948
948
|
const resolvedModuleId = `\0${moduleId}`;
|
|
949
|
+
const injectedModulePath = moduleId.startsWith('/') ? moduleId : `/${moduleId}`;
|
|
949
950
|
const missingMode = options.missingRenderer || 'error';
|
|
950
951
|
const explicitFormats = [...(options.formats || []), ...(options.renderers || [])]
|
|
951
952
|
.map(normalizeToken)
|
|
@@ -1015,18 +1016,20 @@ export function fileViewerRenderers(options = {}) {
|
|
|
1015
1016
|
const results = await copyKnownRendererAssets(targetRoot, collectAssetRendererIds(selection, autoPresetIds));
|
|
1016
1017
|
reportAssetCopy(results, targetRoot, missingMode);
|
|
1017
1018
|
},
|
|
1018
|
-
transformIndexHtml
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
{
|
|
1024
|
-
tag: 'script',
|
|
1025
|
-
attrs: { type: 'module' },
|
|
1026
|
-
children: `import ${JSON.stringify(moduleId)};`,
|
|
1027
|
-
injectTo: 'head'
|
|
1019
|
+
transformIndexHtml: {
|
|
1020
|
+
order: 'pre',
|
|
1021
|
+
handler() {
|
|
1022
|
+
if (options.inject === false || !hasConfiguredRenderers()) {
|
|
1023
|
+
return undefined;
|
|
1028
1024
|
}
|
|
1029
|
-
|
|
1025
|
+
return [
|
|
1026
|
+
{
|
|
1027
|
+
tag: 'script',
|
|
1028
|
+
attrs: { type: 'module', src: injectedModulePath },
|
|
1029
|
+
injectTo: 'head'
|
|
1030
|
+
}
|
|
1031
|
+
];
|
|
1032
|
+
}
|
|
1030
1033
|
},
|
|
1031
1034
|
handleHotUpdate(context) {
|
|
1032
1035
|
if (!options.scan || !resolvedConfig) {
|
|
@@ -1061,7 +1064,7 @@ export function fileViewerRenderers(options = {}) {
|
|
|
1061
1064
|
reportAssetCopy(results, targetRoot, missingMode);
|
|
1062
1065
|
},
|
|
1063
1066
|
resolveId(id) {
|
|
1064
|
-
if (id === moduleId || id === virtualModuleId) {
|
|
1067
|
+
if (id === moduleId || id === virtualModuleId || id === injectedModulePath) {
|
|
1065
1068
|
return id === virtualModuleId ? resolvedVirtualModuleId : resolvedModuleId;
|
|
1066
1069
|
}
|
|
1067
1070
|
return undefined;
|
package/package.json
CHANGED