-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with writing addon with Svelte and Storybook #9421
Comments
@shilman it looks like it is treating a file that ends in |
@tmeasday yes..yes i am...i'm running windows 10. Also to add a bit more context it seems that using the naming scheme provided in the documentation will yeld the same result. |
@tmeasday @jonniebigodes I think the parsing code has a problem with relative paths. Open PR here, which I'll get merged/released today: #9454 |
@shilman thanks for the speedy fix. I'll be on the lookout and check this pr and when i'ts merged bump Storybook version to check it out. |
I've checked that a new pr went through and a new Storybook version was released and i updated my version to 5.3.4 and the issue still persists, still getting the same error. As a test i changed module.exports = {
stories: ["../src/components/**/*.stories.js"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-knobs",
require.resolve('./addons/register.js')
]
}; to: module.exports = {
stories: ["../src/components/**/*.stories.js"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-knobs",
"./addons/register.js"
]
}; and running WARN force closed preview build
ModuleNotFoundError: Module not found: Error: Can't resolve './addons/register.js' in '\learnstorybook_with_svelte\taskbox-storybook-uniconfig'
at factory.create (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\webpack\lib\Compilation.js:925:10)
at factory (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\webpack\lib\NormalModuleFactory.js:401:22)
at resolver (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\webpack\lib\NormalModuleFactory.js:130:21)
at asyncLib.parallel (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\webpack\lib\NormalModuleFactory.js:224:22)
at \learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\neo-async\async.js:2830:7
at \learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\neo-async\async.js:6877:13
at normalResolver.resolve (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\webpack\lib\NormalModuleFactory.js:214:25)
at doResolve (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\Resolver.js:213:14)
at hook.callAsync (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\Resolver.js:285:5)
at _fn0 (eval at create (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
at resolver.doResolve (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:44:7)
at hook.callAsync (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\Resolver.js:285:5)
at _fn0 (eval at create (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
at hook.callAsync (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\Resolver.js:285:5)
at _fn0 (eval at create (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:27:1)
at resolver.doResolve (\learnstorybook_with_svelte\taskbox-storybook-uniconfig\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:67:43)
resolve './addons/register.js' in '\learnstorybook_with_svelte\taskbox-storybook-uniconfig'
using description file: \learnstorybook_with_svelte\taskbox-storybook-uniconfig\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: \learnstorybook_with_svelte\taskbox-storybook-uniconfig\package.json (relative path: ./addons/register.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js.js doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js.jsx doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js.json doesn't exist
as directory
\learnstorybook_with_svelte\taskbox-storybook-uniconfig\addons\register.js doesn't exist
WARN FATAL broken build!, will close the process,
WARN Fix the error below and restart storybook.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] storybook: `start-storybook -p 6006 -s public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] storybook script. |
@ndelangen any idea what's going on here? |
Just did @shilman, removed {
...
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-react": "^7.8.3",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^6.0.0",
"@storybook/addon-actions": "^5.3.4",
"@storybook/addon-knobs": "^5.3.4",
"@storybook/addon-links": "^5.3.4",
"@storybook/addon-storyshots": "^5.3.4",
"@storybook/addons": "^5.3.4",
"@storybook/api": "^5.3.4",
"@storybook/components": "^5.3.4",
"@storybook/svelte": "^5.3.4",
"@storybook/theming": "^5.3.4",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/svelte": "^1.11.0",
"babel-loader": "^8.0.6",
"jest": "^24.9.0",
"jest-transform-svelte": "^2.1.0",
"rollup": "^1.20.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"storybook-chromatic": "^3.4.1",
"svelte": "^3.17.0",
"svelte-loader": "^2.13.6"
},
} Ran |
To add more context, while working on the updates for the angular documentation, the same issue is present. And this is based on version |
I'll add this to my todo list, @jonniebigodes is this repo the way to reproduce the problem?: |
@ndelangen yes, the code in the repo was the one used for the updates on the documentation for >=5.3 |
PR is open! |
@ndelangen thank you for the time and effort you put into this. |
Thanks, if you'd like to help. the PR could use a review ;) |
We are also having problems with relative paths and using path.resolve() for register and presets. Would be great if a fix could be merged ASAP. |
Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.7 containing PR #9648 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
@shilman and @ndelangen sorry for not responding sooner. I'm going to re-run the code again with this alpha version and check if everything is ok and we proceed from there. Sounds good? |
@shilman and @ndelangen just just updated everything related to Storybook to the alpha version mentioned, so now my package.json file looks like the following: {
"rest of the configuration is ommited for brevity":"",
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-react": "^7.8.3",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^6.0.0",
"@storybook/addon-actions": "^6.0.0-alpha.8",
"@storybook/addon-knobs": "^6.0.0-alpha.8",
"@storybook/addon-links": "^6.0.0-alpha.8",
"@storybook/addon-storyshots": "^6.0.0-alpha.8",
"@storybook/addons": "^6.0.0-alpha.8",
"@storybook/api": "^6.0.0-alpha.8",
"@storybook/components": "^6.0.0-alpha.8",
"@storybook/svelte": "^6.0.0-alpha.8",
"@storybook/theming": "^6.0.0-alpha.8",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/svelte": "^1.11.0",
"babel-loader": "^8.0.6",
"jest": "^24.9.0",
"jest-transform-svelte": "^2.1.0",
"rollup": "^1.20.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"storybook-chromatic": "^3.4.1",
"svelte": "^3.17.0",
"svelte-loader": "^2.13.6"
},
} Issuing Failed to load preset: " \\taskbox-storybook-uniconfig\\.storybook\\addons\\register.js" on level 1
ERR! taskbox-storybook-uniconfig\.storybook\addons\register.js:1
ERR! import React, { Fragment } from "react";
ERR! ^^^^^^
ERR!
ERR! SyntaxError: Cannot use import statement outside a module
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25)
ERR! taskbox-storybook-uniconfig\.storybook\addons\register.js:1
ERR! import React, { Fragment } from "react";
ERR! ^^^^^^
ERR!
ERR! SyntaxError: Cannot use import statement outside a module
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25) {
ERR! stack: ' \\taskbox-storybook-uniconfig\\.storybook\\addons\\register.js:1\n' +
ERR! 'import React, { Fragment } from "react";\n' +
ERR! '^^^^^^\n' +
ERR! '\n' +
ERR! 'SyntaxError: Cannot use import statement outside a module\n' +
ERR! ' at Module._compile (internal/modules/cjs/loader.js:891:18)\n' +
ERR! ' at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)\n' +
ERR! ' at Module.load (internal/modules/cjs/loader.js:811:32)\n' +
ERR! ' at Function.Module._load (internal/modules/cjs/loader.js:723:14)\n' +
ERR! ' at Module.require (internal/modules/cjs/loader.js:848:19)\n' +
ERR! ' at require (internal/modules/cjs/helpers.js:74:18)\n' +
ERR! ' at interopRequireDefault ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:164:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:174:22)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:194:18)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at getPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:279:25)'
ERR! }
info => Loading presets
WARN Failed to load preset: " \\taskbox-storybook-uniconfig\\.storybook\\addons\\register.js" on level 1
ERR! taskbox-storybook-uniconfig\.storybook\addons\register.js:1
ERR! import React, { Fragment } from "react";
ERR! ^^^^^^
ERR!
ERR! SyntaxError: Cannot use import statement outside a module
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25)
ERR! taskbox-storybook-uniconfig\.storybook\addons\register.js:1
ERR! import React, { Fragment } from "react";
ERR! ^^^^^^
ERR!
ERR! SyntaxError: Cannot use import statement outside a module
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25) {
ERR! stack: ' \\taskbox-storybook-uniconfig\\.storybook\\addons\\register.js:1\n' +
ERR! 'import React, { Fragment } from "react";\n' +
ERR! '^^^^^^\n' +
ERR! '\n' +
ERR! 'SyntaxError: Cannot use import statement outside a module\n' +
ERR! ' at Module._compile (internal/modules/cjs/loader.js:891:18)\n' +
ERR! ' at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)\n' +
ERR! ' at Module.load (internal/modules/cjs/loader.js:811:32)\n' +
ERR! ' at Function.Module._load (internal/modules/cjs/loader.js:723:14)\n' +
ERR! ' at Module.require (internal/modules/cjs/loader.js:848:19)\n' +
ERR! ' at require (internal/modules/cjs/helpers.js:74:18)\n' +
ERR! ' at interopRequireDefault ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:164:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:174:22)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:194:18)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at getPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:279:25)'
ERR! }
info => Loading config/preview file in "./.storybook".
info => Adding stories defined in ".storybook\main.js". Created a new addon in a new file called const React = require("react");
const {
useParameter,
useStorybookState,
useAddonState
} = require("@storybook/api");
const { addons, types } = require("@storybook/addons");
const { AddonPanel, ActionBar } = require("@storybook/components");
const { styled } = require("@storybook/theming");
const getUrl = input => {
return typeof input === "string" ? input : input.url;
};
const Iframe = styled.iframe({
width: "100%",
height: "100%",
border: "0 none"
});
const Img = styled.img({
width: "100%",
height: "100%",
border: "0 none",
objectFit: "contain"
});
const Asset = ({ url }) => {
if (!url) {
return null;
}
if (url.match(/\.(png|gif|jpeg|tiff|svg|anpg|webp)/)) {
return <Img alt="" src={url} />;
}
return <Iframe title={url} src={url} />;
};
export const Content = () => {
const results = useParameter("assets", []); // story's parameter being retrieved here
const [selected, setSelected] = useAddonState("my/design-assets", 0); // addon state being persisted here
const { storyId } = useStorybookState(); // the story«s unique identifier being retrieved from Storybook global state
if (results.length === 0) {
return null;
}
if (results.length && !results[selected]) {
setSelected(0);
return null;
}
const url = getUrl(results[selected]).replace("{id}", storyId);
return (
<React.Fragment>
<Asset url={url} />
{results.length > 1 ? (
<ActionBar
actionItems={results.map((i, index) => ({
title: typeof i === "string" ? `asset #${index + 1}` : i.name,
onClick: () => setSelected(index)
}))}
/>
) : null}
</React.Fragment>
);
};
addons.register("my/design-assets", () => {
addons.add("design-assets/panel", {
title: "assets",
type: types.PANEL,
render: ({ active, key }) => (
<AddonPanel active={active} key={key}>
<Content />
</AddonPanel>
)
});
}); Changed module.exports = {
stories: ["../src/components/**/*.stories.js"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-knobs",
require.resolve('./addons/example-addon.js')
]
}; Issuing WARN Failed to load preset: " \\taskbox-storybook-uniconfig\\.storybook\\addons\\example-addon.js" on level 1
ERR! taskbox-storybook-uniconfig\.storybook\addons\example-addon.js:31
ERR! return <Img alt="" src={url} />;
ERR! ^
ERR!
ERR! SyntaxError: Unexpected token '<'
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25)
ERR! taskbox-storybook-uniconfig\.storybook\addons\example-addon.js:31
ERR! return <Img alt="" src={url} />;
ERR! ^
ERR!
ERR! SyntaxError: Unexpected token '<'
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25) {
ERR! stack: ' \\taskbox-storybook-uniconfig\\.storybook\\addons\\example-addon.js:31\n' +
ERR! ' return <Img alt="" src={url} />;\n' +
ERR! ' ^\n' +
ERR! '\n' +
ERR! "SyntaxError: Unexpected token '<'\n" +
ERR! ' at Module._compile (internal/modules/cjs/loader.js:891:18)\n' +
ERR! ' at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)\n' +
ERR! ' at Module.load (internal/modules/cjs/loader.js:811:32)\n' +
ERR! ' at Function.Module._load (internal/modules/cjs/loader.js:723:14)\n' +
ERR! ' at Module.require (internal/modules/cjs/loader.js:848:19)\n' +
ERR! ' at require (internal/modules/cjs/helpers.js:74:18)\n' +
ERR! ' at interopRequireDefault ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:164:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:174:22)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:194:18)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at getPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:279:25)'
ERR! }
info => Loading presets
WARN Failed to load preset: " \\taskbox-storybook-uniconfig\\.storybook\\addons\\example-addon.js" on level 1
ERR! taskbox-storybook-uniconfig\.storybook\addons\example-addon.js:31
ERR! return <Img alt="" src={url} />;
ERR! ^
ERR!
ERR! SyntaxError: Unexpected token '<'
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25)
ERR! taskbox-storybook-uniconfig\.storybook\addons\example-addon.js:31
ERR! return <Img alt="" src={url} />;
ERR! ^
ERR!
ERR! SyntaxError: Unexpected token '<'
ERR! at Module._compile (internal/modules/cjs/loader.js:891:18)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
ERR! at Module.load (internal/modules/cjs/loader.js:811:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:723:14)
ERR! at Module.require (internal/modules/cjs/loader.js:848:19)
ERR! at require (internal/modules/cjs/helpers.js:74:18)
ERR! at interopRequireDefault ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:164:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:174:22)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at loadPreset ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:194:18)
ERR! at taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:230:20
ERR! at Array.reduce (<anonymous>)
ERR! at loadPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:229:18)
ERR! at getPresets ( taskbox-storybook-uniconfig\node_modules\@storybook\svelte\node_modules\@storybook\core\dist\server\presets.js:279:25) {
ERR! stack: ' \\taskbox-storybook-uniconfig\\.storybook\\addons\\example-addon.js:31\n' +
ERR! ' return <Img alt="" src={url} />;\n' +
ERR! ' ^\n' +
ERR! '\n' +
ERR! "SyntaxError: Unexpected token '<'\n" +
ERR! ' at Module._compile (internal/modules/cjs/loader.js:891:18)\n' +
ERR! ' at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)\n' +
ERR! ' at Module.load (internal/modules/cjs/loader.js:811:32)\n' +
ERR! ' at Function.Module._load (internal/modules/cjs/loader.js:723:14)\n' +
ERR! ' at Module.require (internal/modules/cjs/loader.js:848:19)\n' +
ERR! ' at require (internal/modules/cjs/helpers.js:74:18)\n' +
ERR! ' at interopRequireDefault ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:164:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:174:22)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at loadPreset ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:194:18)\n' +
ERR! ' at \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:230:20\n' +
ERR! ' at Array.reduce (<anonymous>)\n' +
ERR! ' at loadPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:229:18)\n' +
ERR! ' at getPresets ( \\taskbox-storybook-uniconfig\\node_modules\\@storybook\\svelte\\node_modules\\@storybook\\core\\dist\\server\\presets.js:279:25)'
ERR! }
info => Loading config/preview file in "./.storybook".
info => Adding stories defined in ".storybook\main.js".
info => Using default Webpack setup.
webpack built cc9eb291906723a2bc43 in 13668ms
╭────────────────────────────────────────────────────╮
│ │
│ Storybook 6.0.0-alpha.8 started │
│ 16 s for manager and 15 s for preview │
│ │
│ Local: http://localhost:6006/ │
│ On your network: http://192.168.0.144:6006/ │
│ │
╰────────────────────────────────────────────────────╯
Feel free to provide feedback! |
@jonniebigodes Possibly relevant? #9773 |
@shilman that was spot on! i've updated my module.exports = {
stories: ["../src/components/**/*.stories.js"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-knobs",
'./.storybook/addons/register.js'
]
}; Issued It buit and the addon is working as expected. A quick question if you don't mind. Will this be only available on version 6 or will it be featured in a minor version of 5.3? I'm asking this so that i can make the changes to the documentation accordingly. Feel free to provide feedback and it goes without saying, thank you for the quick fix and also to @ndelangen for the work he put into this. |
Awesome, glad that it works. Let me figure out with @ndelangen whether we'll patch this into 5.3 and I'll let you know! |
@shilman am I correct that fix should work properly for loading addons for any framewoork not just Svelte? I use
@jonniebigodes could you please confirm that |
@andrei-ilyukovich the point of #9773 is not that the relative path convention is inconsistent in |
@andrei-ilyukovich i can confirm the issue is fixed, i got it deployed in here, if you select the default task story you'll see that the assets tab is there and the images are displayed, so the custom addon is working as it should, I need to check on the angular code base i have, on which i was using for updating the documentation to see if the issue is fixed as well. |
short answer: long answer: |
@jonniebigodes I'd be super glad to have some help documenting. You can target the |
@shilman and @ndelangen once again thanks for the help in triaging this. If you both don't mind i'm going to close the issue as it's answered |
Describe the bug
While updating the Svelte documentation for the LearnStorybook tutorial, to match the recent changes introduced in Storybook 5.3 all was going well up until the Creating addons section.
After following the steps provided by the tutorial and installing necessary packages, running
npm run storybook
yelds the following resultTo Reproduce
Steps to reproduce the behavior:
npm storybook
Expected behavior
The addon should be registered correctly and function properly.
Additional context
The code that is being used to back the documentation is located here
Any help would be appreciated.
The text was updated successfully, but these errors were encountered: