Actually, I'm not sure whether it's a bug of Histoire or not. But I really have no idea and have to assume it is for now.
I'm currently making a UI component library which is a secondary packaging for other component libraries. I'd like to use Histoire to help me testing. However, when I imported a component library built by Webpack into Histoire, an error occured. The following is the report:
Error while collecting story C:/Users/H-VISIONS/Desktop/histoire-vue3/src/PdfPreviewButton.story.vue:
Error: Automatic publicPath is not supported in this browser
at C:\Users\H-VISIONS\Desktop\histoire-vue3\node_modules\pdf-viewer-vue\dist\vue3-pdf-viewer.js:1:387870
at C:\Users\H-VISIONS\Desktop\histoire-vue3\node_modules\pdf-viewer-vue\dist\vue3-pdf-viewer.js:1:388030
at C:\Users\H-VISIONS\Desktop\histoire-vue3\node_modules\pdf-viewer-vue\dist\vue3-pdf-viewer.js:1:1216179
at C:\Users\H-VISIONS\Desktop\histoire-vue3\node_modules\pdf-viewer-vue\dist\vue3-pdf-viewer.js:1:81
at Object.<anonymous> (C:\Users\H-VISIONS\Desktop\histoire-vue3\node_modules\pdf-viewer-vue\dist\vue3-pdf-viewer.js:1:253)
at Module._compile (node:internal/modules/cjs/loader:1226:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)
at Module.load (node:internal/modules/cjs/loader:1089:32)
at Module._load (node:internal/modules/cjs/loader:930:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
This component is working fine in a standard Vite + Vue enviroment. I also tested it in Storybook and it has no issues. Therefore, I can only guess that this is a bug caused by Histoire when collecting stories. I cannot confirm that all component libraries built by Webpack will have this problem. It seems that Webpack added some codes during building to detect publicPath support, which caused this error, based on the uglified code for this component I'm currently using.
var e;__webpack_require__.g.importScripts&&(e=__webpack_require__.g.location+"");
var t=__webpack_require__.g.document;
if(!e&&t&&((e=t.currentScript?t.currentScript.src:e)||(t=t.getElementsByTagName("script")).length&&(e=t[t.length-1].src)),!e)
throw new Error("Automatic publicPath is not supported in this browser");
Describe the bug
Actually, I'm not sure whether it's a bug of Histoire or not. But I really have no idea and have to assume it is for now.
I'm currently making a UI component library which is a secondary packaging for other component libraries. I'd like to use Histoire to help me testing. However, when I imported a component library built by Webpack into Histoire, an error occured. The following is the report:
This component is working fine in a standard Vite + Vue enviroment. I also tested it in Storybook and it has no issues. Therefore, I can only guess that this is a bug caused by Histoire when collecting stories. I cannot confirm that all component libraries built by Webpack will have this problem. It seems that Webpack added some codes during building to detect
publicPath
support, which caused this error, based on the uglified code for this component I'm currently using.Reproduction
Here is a Stackblitz containing a minimal reproduction. https://stackblitz.com/edit/histoire-vue3-starter-89rkjd?file=src/PdfPreviewButton.story.vue
Here is a Stackblitz of a Vite + Vue project that includes this component. https://stackblitz.com/edit/vitejs-vite-r6hmfc?file=src/App.vue
System Info
Used Package Manager
npm
Validations